|
From: Jon O. <jon...@us...> - 2006-07-08 10:23:38
|
Update of /cvsroot/mxbb/mx_pafiledb/pafiledb/admin In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv27191/modules/mx_pafiledb/pafiledb/admin Added Files: admin_cat_manage.php admin_catauth_manage.php admin_custom_manage.php admin_fchecker_manage.php admin_file_manage.php admin_license_manage.php admin_settings.php admin_ug_auth_manage.php Log Message: making all admincp an object :-) --- NEW FILE: admin_cat_manage.php --- <?php /** * * @package mxBB Portal Module - mx_pafiledb * @version $Id: admin_cat_manage.php,v 1.1 2006/07/08 10:23:34 jonohlsson Exp $ * @copyright (c) 2002-2006 [Mohd Basri, PHP Arena, pafileDB, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) || !defined( 'IN_ADMIN' ) ) { die( "Hacking attempt" ); } class pafiledb_cat_manage extends pafiledb_admin { function main( $action ) { global $db, $images, $template, $lang, $phpEx, $pafiledb_functions, $pafiledb_cache, $pafiledb_config, $phpbb_root_path, $module_root_path, $mx_root_path, $mx_request_vars; // // Includes // include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); $mode = ( isset( $_REQUEST['mode'] ) ) ? htmlspecialchars( $_REQUEST['mode'] ) : ''; $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; $cat_id_other = ( isset( $_REQUEST['cat_id_other'] ) ) ? intval( $_REQUEST['cat_id_other'] ) : 0; if ( $mode == 'do_add' && !$cat_id ) { $new_cat_id = $pafiledb->update_add_cat(); $mode = 'add'; if ( !sizeof( $pafiledb->error ) ) { $pafiledb->_pafiledb(); $message = $lang['Catadded'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( "admin_pa_category.$phpEx" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_edit_permissions'], '<a href="' . append_sid( "admin_pa_catauth.$phpEx?cat_id=$new_cat_id" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } $mode = 'add'; } elseif ( $mode == 'do_add' && $cat_id ) { $new_cat_id = $pafiledb->update_add_cat( $cat_id ); if ( !sizeof( $pafiledb->error ) ) { $pafiledb->_pafiledb(); $message = $lang['Catedited'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( "admin_pa_category.$phpEx" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_edit_permissions'], '<a href="' . append_sid( "admin_pa_catauth.$phpEx?cat_id=$new_cat_id" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } $mode = 'edit'; } elseif ( $mode == 'do_delete' ) { $pafiledb->delete_cat( $cat_id ); if ( !sizeof( $pafiledb->error ) ) { $pafiledb->_pafiledb(); $message = $lang['Catsdeleted'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( "admin_pa_category.$phpEx" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_admin_index'], '<a href="' . append_sid( $mx_root_path . "admin/index.$phpEx?pane=right" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } } elseif ( $mode == 'cat_order' ) { $pafiledb->order_cat( $cat_id_other ); } elseif ( $mode == 'sync' ) { $pafiledb->sync( $cat_id_other ); } elseif ( $mode == 'sync_all' ) { $pafiledb->sync_all(); } switch ( $mode ) { case '': case 'cat_order': case 'sync': default: $template_file = 'admin/pa_admin_cat.tpl'; $l_title = $lang['Panel_cat_title']; $l_explain = $lang['Panel_cat_explain']; $s_hidden_fields = '<input type="hidden" name="mode" value="add">'; break; case 'add': $template_file = 'admin/pa_admin_cat_edit.tpl'; $l_title = $lang['Acattitle']; $l_explain = $lang['Catexplain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_add">'; break; case 'edit': $template_file = 'admin/pa_admin_cat_edit.tpl'; $l_title = $lang['Ecattitle']; $l_explain = $lang['Catexplain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_add">'; $s_hidden_fields .= '<input type="hidden" name="cat_id" value="' . $cat_id . '">'; break; case 'delete': $template_file = 'admin/pa_admin_cat_delete.tpl'; $l_title = $lang['Dcattitle']; $l_explain = $lang['Catexplain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_delete">'; break; } $pafiledb_template->set_filenames( array( 'admin' => $template_file ) ); if ( sizeof( $pafiledb->error ) ) $pafiledb_template->assign_block_vars( 'pafiledb_error', array() ); $pafiledb_template->assign_vars( array( 'L_CAT_TITLE' => $l_title, 'L_CAT_EXPLAIN' => $l_explain, 'ERROR' => ( sizeof( $pafiledb->error ) ) ? implode( '<br />', $pafiledb->error ) : '', 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_CAT_ACTION' => append_sid( "admin_pa_category.$phpEx" ) )); if ( $mode == '' || $mode == 'cat_order' || $mode == 'sync' || $mode == 'sync_all' ) { $pafiledb_template->assign_vars( array( 'L_CREATE_CATEGORY' => $lang['Create_category'], 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_MOVE_UP' => $lang['Move_up'], 'L_MOVE_DOWN' => $lang['Move_down'], 'L_SUB_CAT' => $lang['Sub_category'], 'L_RESYNC' => $lang['Resync'] )); admin_cat_main( $cat_id ); } elseif ( $mode == 'add' || $mode == 'edit' ) { if ( $mode == 'add' ) { if ( !$_POST['cat_parent'] ) { $cat_list .= '<option value="0" selected>' . $lang['None'] . '</option>'; } else { $cat_list .= '<option value="0">' . $lang['None'] . '</option>'; } $cat_list .= ( !$_POST['cat_parent'] ) ? $pafiledb->generate_jumpbox() : $pafiledb->generate_jumpbox( 0, 0, array( $_POST['cat_parent'] => 1 ) ); $checked_yes = ( $_POST['cat_allow_file'] ) ? ' checked' : ''; $checked_no = ( !$_POST['cat_allow_file'] ) ? ' checked' : ''; $cat_name = ( !empty( $_POST['cat_name'] ) ) ? $_POST['cat_name'] : ''; $cat_desc = ( !empty( $_POST['cat_desc'] ) ) ? $_POST['cat_desc'] : ''; // // Comments // $use_comments_yes = ""; $use_comments_no = ""; $use_comments_default = "checked=\"checked\""; $internal_comments_internal = ""; $internal_comments_phpbb = ""; $internal_comments_default = "checked=\"checked\""; $autogenerate_comments_yes = ""; $autogenerate_comments_no = ""; $autogenerate_comments_default = "checked=\"checked\""; $comments_forum_id = -1; // // Ratings // $use_ratings_yes = ""; $use_ratings_no = ""; $use_ratings_default = "checked=\"checked\""; // // Instructions // $pretext_show = ""; $pretext_hide = ""; $pretext_default = "checked=\"checked\""; // // Notification // $notify_none = ""; $notify_pm = ""; $notify_email = ""; $notify_default = "checked=\"checked\""; $notify_group_list = mx_get_groups('', 'notify_group'); } else { if ( !$pafiledb->cat_rowset[$cat_id]['cat_parent'] ) { $cat_list .= '<option value="0" selected>' . $lang['None'] . '</option>\n'; } else { $cat_list .= '<option value="0">' . $lang['None'] . '</option>\n'; } $cat_list .= $pafiledb->generate_jumpbox( 0, 0, array( $pafiledb->cat_rowset[$cat_id]['cat_parent'] => 1 ) ); if ( $pafiledb->cat_rowset[$cat_id]['cat_allow_file'] ) { $checked_yes = ' checked'; $checked_no = ''; } else { $checked_yes = ''; $checked_no = ' checked'; } $cat_name = $pafiledb->cat_rowset[$cat_id]['cat_name']; $cat_desc = $pafiledb->cat_rowset[$cat_id]['cat_desc']; // // Comments // $use_comments_yes = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_comments'] == 1 ) ? "checked=\"checked\"" : ""; $use_comments_no = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_comments'] == 0 ) ? "checked=\"checked\"" : ""; $use_comments_default = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_comments'] == -1 ) ? "checked=\"checked\"" : ""; $internal_comments_internal = ( $pafiledb->cat_rowset[$cat_id]['internal_comments'] == 1 ) ? "checked=\"checked\"" : ""; $internal_comments_phpbb = ( $pafiledb->cat_rowset[$cat_id]['internal_comments'] == 0 ) ? "checked=\"checked\"" : ""; $internal_comments_default = ( $pafiledb->cat_rowset[$cat_id]['internal_comments'] == -1 ) ? "checked=\"checked\"" : ""; $comments_forum_id = $pafiledb->cat_rowset[$cat_id]['comments_forum_id']; $autogenerate_comments_yes = ( $pafiledb->cat_rowset[$cat_id]['autogenerate_comments'] == 1 ) ? "checked=\"checked\"" : ""; $autogenerate_comments_no = ( $pafiledb->cat_rowset[$cat_id]['autogenerate_comments'] == 0 ) ? "checked=\"checked\"" : ""; $autogenerate_comments_default = ( $pafiledb->cat_rowset[$cat_id]['autogenerate_comments'] == -1 ) ? "checked=\"checked\"" : ""; // // Ratings // $use_ratings_yes = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_ratings'] == 1 ) ? "checked=\"checked\"" : ""; $use_ratings_no = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_ratings'] == 0 ) ? "checked=\"checked\"" : ""; $use_ratings_default = ( $pafiledb->cat_rowset[$cat_id]['cat_allow_ratings'] == -1 ) ? "checked=\"checked\"" : ""; // // Instructions // $pretext_show = ( $pafiledb->cat_rowset[$cat_id]['show_pretext'] == 1 ) ? "checked=\"checked\"" : ""; $pretext_hide = ( $pafiledb->cat_rowset[$cat_id]['show_pretext'] == 0 ) ? "checked=\"checked\"" : ""; $pretext_default = ( $pafiledb->cat_rowset[$cat_id]['show_pretext'] == -1 ) ? "checked=\"checked\"" : ""; // // Notification // $notify_none = ( $pafiledb->cat_rowset[$cat_id]['notify'] == 0 ) ? "checked=\"checked\"" : ""; $notify_pm = ( $pafiledb->cat_rowset[$cat_id]['notify'] == 1 ) ? "checked=\"checked\"" : ""; $notify_email = ( $pafiledb->cat_rowset[$cat_id]['notify'] == 2 ) ? "checked=\"checked\"" : ""; $notify_default = ( $pafiledb->cat_rowset[$cat_id]['notify'] == -1 ) ? "checked=\"checked\"" : ""; $notify_group_list = mx_get_groups($pafiledb->cat_rowset[$cat_id]['notify_group'], 'notify_group'); } $pafiledb_template->assign_vars( array( 'CAT_NAME' => $cat_name, 'CAT_DESC' => $cat_desc, 'CHECKED_YES' => $checked_yes, 'CHECKED_NO' => $checked_no, // // Comments // 'L_COMMENTS_TITLE' => $lang['Comments_title'], 'L_USE_COMMENTS' => $lang['Use_comments'], 'L_USE_COMMENTS_EXPLAIN' => $lang['Use_comments_explain'], 'S_USE_COMMENTS_YES' => $use_comments_yes, 'S_USE_COMMENTS_NO' => $use_comments_no, 'S_USE_COMMENTS_DEFAULT' => $use_comments_default, 'L_INTERNAL_COMMENTS' => $lang['Internal_comments'], 'L_INTERNAL_COMMENTS_EXPLAIN' => $lang['Internal_comments_explain'], 'S_INTERNAL_COMMENTS_INTERNAL' => $internal_comments_internal, 'S_INTERNAL_COMMENTS_PHPBB' => $internal_comments_phpbb, 'S_INTERNAL_COMMENTS_DEFAULT' => $internal_comments_default, 'L_INTERNAL_COMMENTS_INTERNAL' => $lang['Internal_comments_internal'], 'L_INTERNAL_COMMENTS_PHPBB' => $lang['Internal_comments_phpBB'], 'L_FORUM_ID' => $lang['Forum_id'], 'L_FORUM_ID_EXPLAIN' => $lang['Forum_id_explain'], 'FORUM_LIST' => get_forums( $comments_forum_id, true, 'comments_forum_id' ), 'L_AUTOGENERATE_COMMENTS' => $lang['Autogenerate_comments'], 'L_AUTOGENERATE_COMMENTS_EXPLAIN' => $lang['Autogenerate_comments_explain'], 'S_AUTOGENERATE_COMMENTS_YES' => $autogenerate_comments_yes, 'S_AUTOGENERATE_COMMENTS_NO' => $autogenerate_comments_no, 'S_AUTOGENERATE_COMMENTS_DEFAULT' => $autogenerate_comments_default, // // Ratings // 'L_RATINGS_TITLE' => $lang['Ratings_title'], 'L_USE_RATINGS' => $lang['Use_ratings'], 'L_USE_RATINGS_EXPLAIN' => $lang['Use_ratings_explain'], 'S_USE_RATINGS_YES' => $use_ratings_yes, 'S_USE_RATINGS_NO' => $use_ratings_no, 'S_USE_RATINGS_DEFAULT' => $use_ratings_default, // // Instructions // 'L_INSTRUCTIONS_TITLE' => $lang['Instructions_title'], 'L_PRE_TEXT_NAME' => $lang['Pre_text_name'], 'L_PRE_TEXT_EXPLAIN' => $lang['Pre_text_explain'], 'S_SHOW_PRETEXT' => $pretext_show, 'S_HIDE_PRETEXT' => $pretext_hide, 'S_DEFAULT_PRETEXT' => $pretext_default, 'L_SHOW' => $lang['Show'], 'L_HIDE' => $lang['Hide'], // // Notifications // 'L_NOTIFICATIONS_TITLE' => $lang['Notifications_title'], 'L_NOTIFY' => $lang['Notify'], 'L_NOTIFY_EXPLAIN' => $lang['Notify_explain'], 'L_EMAIL' => $lang['Email'], 'L_PM' => $lang['PM'], 'S_NOTIFY_NONE' => $notify_none, 'S_NOTIFY_EMAIL' => $notify_email, 'S_NOTIFY_PM' => $notify_pm, 'S_NOTIFY_DEFAULT' => $notify_default, 'L_NOTIFY_GROUP' => $lang['Notify_group'], 'L_NOTIFY_GROUP_EXPLAIN' => $lang['Notify_group_explain'], 'NOTIFY_GROUP' => $notify_group_list, 'L_CAT_NAME' => $lang['Catname'], 'L_CAT_NAME_INFO' => $lang['Catnameinfo'], 'L_CAT_DESC' => $lang['Catdesc'], 'L_CAT_DESC_INFO' => $lang['Catdescinfo'], 'L_CAT_PARENT' => $lang['Catparent'], 'L_CAT_PARENT_INFO' => $lang['Catparentinfo'], 'L_CAT_ALLOWFILE' => $lang['Allow_file'], 'L_CAT_ALLOWFILE_INFO' => $lang['Allow_file_info'], 'L_CAT_ALLOWCOMMENTS' => $lang['Allow_comments'], 'L_CAT_ALLOWCOMMENTS_INFO' => $lang['Allow_comments_info'], 'L_CAT_ALLOWRATINGS' => $lang['Allow_ratings'], 'L_CAT_ALLOWRATINGS_INFO' => $lang['Allow_ratings_info'], 'L_DEFAULT' => $lang['Use_default'], 'L_NONE' => $lang['None'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_CAT_NAME_FIELD_EMPTY' => $lang['Cat_name_missing'], 'S_CAT_LIST' => $cat_list ) ); } elseif ( $mode == 'delete' ) { $select_cat = $pafiledb->generate_jumpbox( 0, 0, array( $cat_id => 1 ) ); $file_to_select_cat = $pafiledb->generate_jumpbox( 0, 0, '', true ); $pafiledb_template->assign_vars( array( 'S_SELECT_CAT' => $select_cat, 'S_FILE_SELECT_CAT' => $file_to_select_cat, 'L_DELETE' => $lang['Delete'], 'L_DO_FILE' => $lang['Delfiles'], 'L_DO_CAT' => $lang['Do_cat'], 'L_MOVE_TO' => $lang['Move_to'], 'L_SELECT_CAT' => $lang['Select_a_Category'], 'L_DELETE' => $lang['Delete'], 'L_MOVE' => $lang['Move'] )); } $pafiledb_template->display( 'admin' ); $pafiledb->_pafiledb(); $pafiledb_cache->unload(); } } ?> --- NEW FILE: admin_file_manage.php --- <?php /** * * @package mxBB Portal Module - mx_pafiledb * @version $Id: admin_file_manage.php,v 1.1 2006/07/08 10:23:35 jonohlsson Exp $ * @copyright (c) 2002-2006 [Mohd Basri, PHP Arena, pafileDB, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) || !defined( 'IN_ADMIN' ) ) { die( "Hacking attempt" ); } class pafiledb_file_manage extends pafiledb_admin { function main( $action ) { global $db, $images, $template, $lang, $phpEx, $pafiledb_functions, $pafiledb_cache, $pafiledb_config, $phpbb_root_path, $module_root_path, $mx_root_path, $mx_request_vars; // // Includes // include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); // // Init // $custom_field = new custom_field(); $custom_field->init(); $pafiledb->init(); $cat_id = ( isset( $_REQUEST['cat_id'] ) ) ? intval( $_REQUEST['cat_id'] ) : 0; $file_id = ( isset( $_REQUEST['file_id'] ) ) ? intval( $_REQUEST['file_id'] ) : 0; $file_ids = ( isset( $_POST['file_ids'] ) ) ? array_map( 'intval', $_POST['file_ids'] ) : array(); $start = ( isset( $_REQUEST['start'] ) ) ? intval( $_REQUEST['start'] ) : 0; $mode = ( isset( $_REQUEST['mode'] ) ) ? htmlspecialchars( $_REQUEST['mode'] ) : ''; $mode_notification = ( isset( $_REQUEST['mode'] ) ) ? htmlspecialchars( $_REQUEST['mode'] ) : ''; $mode_js = ( isset( $_REQUEST['mode_js'] ) ) ? htmlspecialchars( $_REQUEST['mode_js'] ) : ''; $mode = ( isset( $_POST['addfile'] ) ) ? 'add' : $mode; $mode = ( isset( $_POST['delete'] ) ) ? 'delete' : $mode; $mode = ( isset( $_POST['approve'] ) ) ? 'do_approve' : $mode; $mode = ( isset( $_POST['unapprove'] ) ) ? 'do_unapprove' : $mode; $mode = ( empty( $mode ) ) ? $mode_js : $mode; $mirrors = ( isset( $_POST['mirrors'] ) ) ? true : 0; if ( isset( $_REQUEST['sort_method'] ) ) { switch ( $_REQUEST['sort_method'] ) { case 'file_name': $sort_method = 'file_name'; break; case 'file_time': $sort_method = 'file_time'; break; case 'file_dls': $sort_method = 'file_dls'; break; case 'file_rating': $sort_method = 'rating'; break; case 'file_update_time': $sort_method = 'file_update_time'; break; default: $sort_method = $pafiledb_config['sort_method']; } } else { $sort_method = $pafiledb_config['sort_method']; } if ( isset( $_REQUEST['sort_order'] ) ) { switch ( $_REQUEST['sort_order'] ) { case 'ASC': $sort_order = 'ASC'; break; case 'DESC': $sort_order = 'DESC'; break; default: $sort_order = $pafiledb_config['sort_order']; } } else { $sort_order = $pafiledb_config['sort_order']; } $s_file_actions = array( 'approved' => $lang['Approved_files'], 'broken' => $lang['Broken_files'], 'file_cat' => $lang['File_cat'], 'all_file' => $lang['All_files'], 'maintenance' => $lang['Maintenance'] ); switch ( $mode ) { case '': case 'approved': case 'broken': case 'do_approve': case 'do_unapprove': case 'delete': case 'file_cat': case 'all_file': default: $template_file = 'admin/pa_admin_file.tpl'; $l_title = $lang['File_manage_title']; $l_explain = $lang['Fileexplain']; // $s_hidden_fields = '<input type="hidden" name="mode" value="add">'; break; case 'add': $template_file = 'admin/pa_admin_file_edit.tpl'; $l_title = $lang['Afiletitle']; $l_explain = $lang['Fileexplain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_add">'; break; case 'edit': case 'do_add': $template_file = 'admin/pa_admin_file_edit.tpl'; $l_title = $lang['Efiletitle']; $l_explain = $lang['Fileexplain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_add">'; $s_hidden_fields .= '<input type="hidden" name="file_id" value="' . $file_id . '">'; break; case 'maintenance': $template_file = 'admin/pa_admin_file_checker.tpl'; $l_title = $lang['File_checker']; $l_explain = $lang['File_checker_explain']; $s_hidden_fields = '<input type="hidden" name="mode" value="do_maintenace">'; break; case 'mirrors': $template_file = 'admin/pa_admin_file_mirrors.tpl'; $l_title = $lang['Mirrors']; $l_explain = $lang['Mirrors_explain']; $s_hidden_fields = '<input type="hidden" name="mode" value="mirrors">'; $s_hidden_fields .= '<input type="hidden" name="file_id" value="' . $file_id . '">'; break; } if ( $mode == 'do_add' && !$file_id ) { $file_id = $pafiledb->update_add_file(); $custom_field->file_update_data( $file_id ); $pafiledb->_pafiledb(); $mode = 'edit'; if ( !$mirrors ) { // // Notification // $pafiledb->update_add_file_notify($file_id, 'add'); $message = $lang['Fileadded'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( "admin_pa_file.php" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } } elseif ( $mode == 'do_add' && $file_id ) { $file_id = $pafiledb->update_add_file( $file_id ); $custom_field->file_update_data( $file_id ); $pafiledb->_pafiledb(); $mode = 'edit'; if ( !$mirrors ) { // // Notification // $pafiledb->update_add_file_notify($file_id, 'edit'); $message = $lang['Fileedited'] . '<br /><br />' . sprintf( $lang['Click_return'], '<a href="' . append_sid( "admin_pa_file.$phpEx" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_admin_index'], '<a href="' . append_sid( $mx_root_path . "admin/index.$phpEx?pane=right" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } } elseif ( $mode == 'delete' ) { if ( is_array( $file_ids ) && !empty( $file_ids ) ) { foreach( $file_ids as $temp_file_id ) { $sql = 'SELECT * FROM ' . PA_FILES_TABLE . " WHERE file_id = $temp_file_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $file_info = $db->sql_fetchrow( $result ); // // Notification // $pafiledb->update_add_file_notify($temp_file_id, 'delete'); // // Comments // if ($pafiledb->comments[$file_info['file_catid']]['activated'] && $pafiledb_config['del_topic']) { if ( $pafiledb->comments[$file_info['file_catid']]['internal_comments'] ) { $sql = 'DELETE FROM ' . PA_COMMENTS_TABLE . " WHERE file_id = '" . $file_id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $file_info['topic_id'] ) { include( $module_root_path . 'pafiledb/includes/functions_comment.' . $phpEx ); $mx_pa_comments = new pafiledb_comments(); $mx_pa_comments->init( $file_info, 'phpbb'); $mx_pa_comments->post('delete_all', $file_info['topic_id']); } } } $pafiledb->delete_files( $temp_file_id ); } } else { $sql = 'SELECT * FROM ' . PA_FILES_TABLE . " WHERE file_id = $file_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $file_info = $db->sql_fetchrow( $result ); // // Notification // $pafiledb->update_add_file_notify($file_id, 'delete'); // // Comments // if ($pafiledb->comments[$file_info['file_catid']]['activated'] && $pafiledb_config['del_topic']) { if ( $pafiledb->comments[$file_info['file_catid']]['internal_comments'] ) { $sql = 'DELETE FROM ' . PA_COMMENTS_TABLE . " WHERE file_id = '" . $file_id . "'"; if ( !( $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt delete comments', '', __LINE__, __FILE__, $sql ); } } else { if ( $file_info['topic_id'] ) { include( $module_root_path . 'pafiledb/includes/functions_comment.' . $phpEx ); $mx_pa_comments = new pafiledb_comments(); $mx_pa_comments->init( $file_info, 'phpbb'); $mx_pa_comments->post('delete_all', $file_info['topic_id']); } } } $pafiledb->delete_files( $file_id ); } $pafiledb->_pafiledb(); } elseif ( $mode == 'do_maintenace' ) { $pafiledb->file_mainenance(); } elseif ( $mode == 'do_approve' || $mode == 'do_unapprove' ) { if ( is_array( $file_ids ) && !empty( $file_ids ) ) { foreach( $file_ids as $temp_file_id ) { $pafiledb->file_approve( $mode, $temp_file_id ); } // // Notification // $pafiledb->update_add_file_notify($file_ids, $mode); } else { $pafiledb->file_approve( $mode, $file_id ); // // Notification // $pafiledb->update_add_file_notify($file_id, $mode); } $pafiledb->_pafiledb(); } $pafiledb_template->set_filenames( array( 'admin' => $template_file ) ); $pafiledb_template->assign_vars( array( 'L_FILE_TITLE' => $l_title, 'L_FILE_EXPLAIN' => $l_explain, 'L_ADD_FILE' => $lang['Afiletitle'], 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_FILE_ACTION' => append_sid( "admin_pa_file.$phpEx" ) )); if ( in_array( $mode, array( '', 'approved', 'broken', 'do_approve', 'do_unapprove', 'delete', 'file_cat', 'all_file' ) ) ) { $mode = ( in_array( $mode, array( 'do_approve', 'do_unapprove', 'delete' ) ) ) ? '' : $mode; if ( $mode != 'approved' && $mode != 'broken' ) { $where_sql = ( $mode == 'file_cat' ) ? "AND file_catid = '$cat_id'" : ''; $sql = "SELECT file_name, file_approved, file_id, file_broken FROM " . PA_FILES_TABLE . " as f1 WHERE file_approved = '1' $where_sql ORDER BY file_time DESC"; if ( $mode == '' || $mode == 'file_cat' || $mode == 'all_file' ) { if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $total_files = $db->sql_numrows( $result ); } if ( !( $result = $pafiledb_functions->sql_query_limit( $sql, $pafiledb_config['pagination'], $start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $all_file_rowset[] = $row; } } if ( $mode == '' || $mode == 'approved' || $mode == 'broken' || $mode == 'file_cat' || $mode == 'all_file' ) { if ( $mode == '' ) { $limit = 5; $temp_start = 0; } else { $limit = $pafiledb_config['pagination']; $temp_start = $start; } if ( $mode == '' || $mode == 'approved' ) { $sql = "SELECT file_name, file_approved, file_id, file_broken FROM " . PA_FILES_TABLE . " WHERE file_approved = '0' ORDER BY file_time DESC"; if ( $mode == 'approved' ) { if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $total_files = $db->sql_numrows( $result ); } if ( !( $result = $pafiledb_functions->sql_query_limit( $sql, $limit, $temp_start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $approved_file_rowset[] = $row; } } if ( $mode == '' || $mode == 'broken' ) { $sql = "SELECT file_name, file_approved, file_id, file_broken FROM " . PA_FILES_TABLE . " WHERE file_broken = '1' ORDER BY file_time DESC"; if ( $mode == 'broken' ) { if ( ( !$result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $total_files = $db->sql_numrows( $result ); } if ( !( $result = $pafiledb_functions->sql_query_limit( $sql, $limit, $temp_start ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } while ( $row = $db->sql_fetchrow( $result ) ) { $broken_file_rowset[] = $row; } } if ( $mode == '' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Approved_files'], 'row_set' => $approved_file_rowset, 'approval' => 'approve' ), 1 => array( 'lang_var' => $lang['Broken_files'], 'row_set' => $broken_file_rowset, 'approval' => 'both' ), 2 => array( 'lang_var' => $lang['All_files'], 'row_set' => $all_file_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'all_file' || $mode == 'file_cat' ) { $global_array = array( 0 => array( 'lang_var' => $lang['All_files'], 'row_set' => $all_file_rowset, 'approval' => 'unapprove' ) ); } elseif ( $mode == 'approved' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Approved_files'], 'row_set' => $approved_file_rowset, 'approval' => 'approve' ) ); } elseif ( $mode == 'broken' ) { $global_array = array( 0 => array( 'lang_var' => $lang['Broken_files'], 'row_set' => $broken_file_rowset, 'approval' => 'both' ) ); } } $s_file_list = ''; foreach( $s_file_actions as $file_mode => $lang_var ) { $s = ''; if ( $mode == $file_mode ) { $s = ' selected="selected"'; } $s_file_list .= '<option value="' . $file_mode . '"' . $s . '>' . $lang_var . '</option>'; } $cat_list = '<select name="cat_id">'; if ( !$pafiledb->cat_rowset[$cat_id]['cat_parent'] ) { $cat_list .= '<option value="0" selected>' . $lang['None'] . '</option>\n'; } else { $cat_list .= '<option value="0">' . $lang['None'] . '</option>\n'; } $cat_list .= $pafiledb->generate_jumpbox( 0, 0, array( $cat_id => 1 ), true ); $cat_list .= '</select>'; $pafiledb_template->assign_vars( array( 'L_EDIT' => $lang['Edit'], 'L_DELETE' => $lang['Delete'], 'L_CATEGORY' => $lang['Category'], 'L_MODE' => $lang['View'], 'L_GO' => $lang['Go'], 'L_DELETE_FILE' => $lang['Delete_selected'], 'L_APPROVE' => $lang['Approve'], 'L_UNAPPROVE' => $lang['Unapprove'], 'L_APPROVE_FILE' => $lang['Approve_selected'], 'L_UNAPPROVE_FILE' => $lang['Unapprove_selected'], 'L_NO_FILES' => $lang['No_file'], 'PAGINATION' => generate_pagination( append_sid( "admin_pa_file.$phpEx?mode=$mode&sort_method=$sort_method&sort_order=$sort_order&cat_id=$cat_id" ), $total_files, $pafiledb_config['pagination'], $start ), 'PAGE_NUMBER' => sprintf( $lang['Page_of'], ( floor( $start / $pafiledb_config['pagination'] ) + 1 ), ceil( $total_files / $pafiledb_config['pagination'] ) ), 'S_CAT_LIST' => $cat_list, 'S_MODE_SELECT' => $s_file_list ) ); if ( $total_files > 0 ) { $template->assign_block_vars( 'pagination', array() ); } foreach( $global_array as $files_data ) { $approve = false; $unapprove = false; if ( $files_data['approval'] == 'both' ) { $approve = $unapprove = true; } elseif ( $files_data['approval'] == 'approve' ) { $approve = true; } elseif ( $files_data['approval'] == 'unapprove' ) { $unapprove = true; } $pafiledb_template->assign_block_vars( 'file_mode', array( 'L_FILE_MODE' => $files_data['lang_var'], 'DATA' => ( isset( $files_data['row_set'] ) ) ? true : false, 'APPROVE' => $approve, 'UNAPPROVE' => $unapprove )); if ( isset( $files_data['row_set'] ) ) { $i = $start + 1; foreach( $files_data['row_set'] as $file_data ) { $approve_mode = ( $file_data['file_approved'] ) ? 'do_unapprove' : 'do_approve'; $pafiledb_template->assign_block_vars( 'file_mode.file_row', array( 'FILE_NAME' => $file_data['file_name'], 'FILE_NUMBER' => $i++, 'FILE_ID' => $file_data['file_id'], 'U_FILE_EDIT' => append_sid( "admin_pa_file.$phpEx?mode=edit&file_id={$file_data['file_id']}" ), 'U_FILE_DELETE' => append_sid( "admin_pa_file.$phpEx?mode=delete&file_id={$file_data['file_id']}" ), 'U_FILE_APPROVE' => append_sid( "admin_pa_file.$phpEx?mode=$approve_mode&file_id={$file_data['file_id']}" ), 'L_APPROVE' => ( $file_data['file_approved'] ) ? $lang['Unapprove'] : $lang['Approve'] )); } } } } elseif ( $mode == 'add' || $mode == 'edit' || $mirrors ) { if ( $mode == 'add' ) { $file_name = ''; $file_desc = ''; $file_long_desc = ''; $file_author = ''; $file_version = ''; $file_website = ''; $file_posticons = $pafiledb_functions->post_icons(); $file_cat_list = $pafiledb->generate_jumpbox( 0, 0, '', true ); $file_license = $pafiledb_functions->license_list(); $pin_checked_yes = ''; $pin_checked_no = ' checked'; $file_download = 0; $approved_checked_yes = ' checked'; $approved_checked_no = ''; $file_ssurl = ''; $ss_checked_yes = ''; $ss_checked_no = ' checked'; $file_url = ''; $custom_exist = $custom_field->display_edit(); } else { $sql = 'SELECT * FROM ' . PA_FILES_TABLE . " WHERE file_id = $file_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldn\'t get file info', '', __LINE__, __FILE__, $sql ); } $file_info = $db->sql_fetchrow( $result ); $file_name = $file_info['file_name']; $file_desc = $file_info['file_desc']; $file_long_desc = $file_info['file_longdesc']; $file_author = $file_info['file_creator']; $file_version = $file_info['file_version']; $file_website = $file_info['file_docsurl']; $file_posticons = $pafiledb_functions->post_icons( $file_info['file_posticon'] ); $file_cat_list = $pafiledb->generate_jumpbox( 0, 0, array( $file_info['file_catid'] => 1 ), true ); $file_license = $pafiledb_functions->license_list( $file_info['file_license'] ); $pin_checked_yes = ( $file_info['file_pin'] ) ? ' checked' : ''; $pin_checked_no = ( !$file_info['file_pin'] ) ? ' checked' : ''; $file_download = intval( $file_info['file_dls'] ); $approved_checked_yes = ( $file_info['file_approved'] ) ? ' checked' : ''; $approved_checked_no = ( !$file_info['file_approved'] ) ? ' checked' : ''; $file_ssurl = $file_info['file_ssurl']; $ss_checked_yes = ( $file_info['file_sshot_link'] ) ? ' checked' : ''; $ss_checked_no = ( !$file_info['file_sshot_link'] ) ? ' checked' : ''; $file_url = $file_info['file_dlurl']; $file_unique_name = $file_info['unique_name']; $file_dir = $file_info['file_dir']; $custom_exist = $custom_field->display_edit( $file_id ); } $pafiledb_template->assign_vars( array( 'U_MIRRORS_PAGE' => append_sid( "admin_pa_file.$phpEx?mode=mirrors&file_id=$file_id" ), 'ADD_MIRRORS' => $mirrors, 'MODE_EDIT' => ( $mode == 'edit' ) ? true : false, 'MODE' => $mode, 'FILESIZE' => intval( $pafiledb_config['max_file_size'] ), 'FILE_NAME' => $file_name, 'FILE_DESC' => $file_desc, 'FILE_LONG_DESC' => $file_long_desc, 'FILE_AUTHOR' => $file_author, 'FILE_VERSION' => $file_version, 'FILE_SSURL' => $file_ssurl, 'FILE_WEBSITE' => $file_website, 'FILE_DLURL' => $file_url, 'FILE_DOWNLOAD' => $file_download, 'CUSTOM_EXIST' => $custom_exist, 'APPROVED_CHECKED_YES' => $approved_checked_yes, 'APPROVED_CHECKED_NO' => $approved_checked_no, 'SS_CHECKED_YES' => $ss_checked_yes, 'SS_CHECKED_NO' => $ss_checked_no, 'PIN_CHECKED_YES' => $pin_checked_yes, 'PIN_CHECKED_NO' => $pin_checked_no, 'MIRROR_FILE' => $file_unique_name, // 'U_UPLOADED_MIRROR' => get_formated_url() . '/' . $file_dir . $file_unique_name, 'U_UPLOADED_MIRROR' => PORTAL_URL . 'modules/mx_pafiledb/' . $file_dir . $file_unique_name, 'L_FILE_APPROVED' => $lang['Approved'], 'L_FILE_APPROVED_INFO' => $lang['Approved_info'], 'L_ADDTIONAL_FIELD' => $lang['Addtional_field'], 'L_SCREENSHOT' => $lang['Scrsht'], 'L_FILES' => $lang['Files'], 'L_FILE_NAME' => $lang['Filename'], 'L_FILE_NAME_INFO' => $lang['Filenameinfo'], 'L_FILE_SHORT_DESC' => $lang['Filesd'], 'L_FILE_SHORT_DESC_INFO' => $lang['Filesdinfo'], 'L_FILE_LONG_DESC' => $lang['Fileld'], 'L_FILE_LONG_DESC_INFO' => $lang['Fileldinfo'], 'L_FILE_AUTHOR' => $lang['Filecreator'], 'L_FILE_AUTHOR_INFO' => $lang['Filecreatorinfo'], 'L_FILE_VERSION' => $lang['Fileversion'], 'L_FILE_VERSION_INFO' => $lang['Fileversioninfo'], 'L_FILESS' => $lang['Filess'], 'L_FILESSINFO' => $lang['Filessinfo'], 'L_FILESS_UPLOAD' => $lang['Filess_upload'], 'L_FILESSINFO_UPLOAD' => $lang['Filessinfo_upload'], 'L_FILE_SSLINK' => $lang['Filess_link'], 'L_FILE_SSLINK_INFO' => $lang['Filess_link_info'], 'L_FILESSUPLOAD' => $lang['Filessupload'], 'L_FILE_WEBSITE' => $lang['Filedocs'], 'L_FILE_WEBSITE_INFO' => $lang['Filedocsinfo'], 'L_FILE_URL' => $lang['Fileurl'], 'L_FILE_UPLOAD' => $lang['File_upload'], 'L_FILEINFO_UPLOAD' => $lang['Fileinfo_upload'], 'L_FILE_URL_INFO' => $lang['Fileurlinfo'], 'L_FILE_POSTICONS' => $lang['Filepi'], 'L_FILE_POSTICONS_INFO' => $lang['Filepiinfo'], 'L_FILE_CAT' => $lang['Filecat'], 'L_FILE_CAT_INFO' => $lang['Filecatinfo'], 'L_FILE_LICENSE' => $lang['Filelicense'], 'L_NONE' => $lang['None'], 'L_FILE_LICENSE_INFO' => $lang['Filelicenseinfo'], 'L_FILE_PINNED' => $lang['Filepin'], 'L_FILE_PINNED_INFO' => $lang['Filepininfo'], 'L_FILE_DOWNLOAD' => $lang['Filedls'], 'L_MIRRORS' => $lang['Mirrors'], 'L_MIRRORS_INFO' => $lang['Mirrors_explain'], 'L_CLICK_HERE_MIRRORS' => $lang['Click_here_mirrors'], 'L_UPLOADED_FILE' => $lang['Uploaded_file'], 'L_NO' => $lang['No'], 'L_YES' => $lang['Yes'], 'S_POSTICONS' => $file_posticons, 'S_LICENSE_LIST' => $file_license, 'S_CAT_LIST' => $file_cat_list ) ); } elseif ( $mode == 'mirrors' ) { if ( isset( $_POST['delete_mirrors'] ) ) { $mirror_ids = ( isset( $_POST['mirror_ids'] ) ) ? array_map( 'intval', $_POST['mirror_ids'] ) : array(); if ( !empty( $mirror_ids ) ) { $pafiledb->delete_mirror( $mirror_ids ); } } if ( isset( $_POST['add_new'] ) ) { $file_upload = ( empty( $_POST['new_download_url'] ) ) ? true : false; $file_remote_url = ( !empty( $_POST['new_download_url'] ) ) ? $_POST['new_download_url'] : ''; $file_local = ( $_FILES['new_userfile']['tmp_name'] !== 'none' ) ? $_FILES['new_userfile']['tmp_name'] : ''; $file_realname = ( $_FILES['new_userfile']['name'] !== 'none' ) ? $_FILES['new_userfile']['name'] : ''; $file_size = ( !empty( $_FILES['new_userfile']['size'] ) ) ? $_FILES['new_userfile']['size'] : ''; $file_type = ( !empty( $_FILES['new_userfile']['type'] ) ) ? $_FILES['new_userfile']['type'] : ''; $mirror_location = ( !empty( $_POST['new_location'] ) ) ? $_POST['new_location'] : ''; $pafiledb->mirror_add_update( $file_id, $file_upload, $file_remote_url, $file_local, $file_realname, $file_size, $file_type, $mirror_location ); } if ( isset( $_POST['modify'] ) ) { $file_urls = ( !empty( $_POST['download_url'] ) ) ? $_POST['download_url'] : array(); $userfiles = ( !empty( $_FILES['userfile'] ) ) ? $_FILES['userfile'] : array(); $locations = ( !empty( $_POST['location'] ) ) ? $_POST['location'] : array(); $data = array(); foreach( $file_urls as $mirror_id => $file_url ) { $data[$mirror_id]['download_url'] = $file_url; } foreach( array_keys( $userfiles ) as $key ) { foreach( $userfiles[$key] as $mirror_id => $userfile ) { $data[$mirror_id][$key] = $userfile; } } foreach( $locations as $mirror_id => $location ) { $data[$mirror_id]['location'] = $location; } unset( $file_urls ); unset( $userfiles ); unset( $locations ); foreach( $data as $mirror_id => $mirror_data ) { $file_upload = ( empty( $mirror_data['download_url'] ) ) ? true : false; $file_remote_url = ( !empty( $mirror_data['download_url'] ) ) ? $mirror_data['download_url'] : ''; $file_local = ( $mirror_data['tmp_name'] !== 'none' ) ? $mirror_data['tmp_name'] : ''; $file_realname = ( $mirror_data['name'] !== 'none' ) ? $mirror_data['name'] : ''; $file_size = ( !empty( $mirror_data['size'] ) ) ? $mirror_data['size'] : ''; $file_type = ( !empty( $mirror_data['type'] ) ) ? $mirror_data['type'] : ''; $mirror_location = ( !empty( $mirror_data['location'] ) ) ? $mirror_data['location'] : ''; $pafiledb->mirror_add_update( $file_id, $file_upload, $file_remote_url, $file_local, $file_realname, $file_size, $file_type, $mirror_location, $mirror_id ); } unset( $data ); } $sql = 'SELECT f.* FROM ' . PA_MIRRORS_TABLE . " AS f WHERE f.file_id = '" . $file_id . "' ORDER BY mirror_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, 'Couldnt select download', '', __LINE__, __FILE__, $sql ); } $mirrors_data = array(); while ( $row = $db->sql_fetchrow( $result ) ) { $mirrors_data[$row['mirror_id']] = $row; } $pafiledb_template->assign_vars( array( 'ROW_NOT_EMPTY' => ( empty( $mirrors_data ) ) ? false : true, 'FILESIZE' => intval( $pafiledb_config['max_file_size'] ), 'L_MIRROR_LOCATION' => $lang['Mirror_location'], 'L_FILE_UPLOAD' => $lang['File_upload'], 'L_FILE_DELETE' => $lang['Delete'], 'L_DELETE' => $lang['Delete_selected'], 'L_FILEINFO_UPLOAD' => $lang['Fileinfo_upload'], 'L_UPLOADED_FILE' => $lang['Uploaded_file'], 'L_FILE_URL' => $lang['Fileurl'], 'L_FILE_URL_INFO' => $lang['Fileurl'], 'L_MODIFY' => $lang['Efiletitle'], 'L_ADD_NEW' => $lang['Afiletitle'], 'L_ADD_NEW_MIRROR' => $lang['Add_new_mirror'] )); foreach( $mirrors_data as $mirror_id => $mirror_data ) { $pafiledb_template->assign_block_vars( 'row', array( 'LOCATION' => $mirror_data['mirror_location'], 'MIRROR_ID' => $mirror_id, 'MIRROR_URL' => $mirror_data['file_dlurl'], 'MIRROR_FILE' => $mirror_data['unique_name'], 'U_UPLOADED_MIRROR' => get_formated_url() . '/' . $mirror_data['file_dir'] . $mirror_data['unique_name'] )); } } $pafiledb_template->assign_vars( array( 'ERROR' => ( sizeof( $pafiledb->error ) ) ? implode( '<br />', $pafiledb->error ) : '' ) ); // // Output // include( $mx_root_path . 'admin/page_header_admin.' . $phpEx ); $pafiledb_template->display( 'admin' ); $pafiledb->_pafiledb(); $pafiledb_cache->unload(); include( $mx_root_path . 'admin/page_footer_admin.' . $phpEx ); } } ?> --- NEW FILE: admin_ug_auth_manage.php --- <?php /** * * @package mxBB Portal Module - mx_pafiledb * @version $Id: admin_ug_auth_manage.php,v 1.1 2006/07/08 10:23:35 jonohlsson Exp $ * @copyright (c) 2002-2006 [Mohd Basri, PHP Arena, pafileDB, Jon Ohlsson] mxBB Project Team * @license http://opensource.org/licenses/gpl-license.php GNU General Public License v2 * */ if ( !defined( 'IN_PORTAL' ) || !defined( 'IN_ADMIN' ) ) { die( "Hacking attempt" ); } class pafiledb_ug_auth_manage extends pafiledb_admin { function main( $action ) { global $db, $images, $template, $lang, $phpEx, $pafiledb_functions, $pafiledb_cache, $pafiledb_config, $phpbb_root_path, $module_root_path, $mx_root_path, $mx_request_vars; // // Includes // include_once( $phpbb_root_path . 'includes/functions_search.' . $phpEx ); $params = array( 'mode' => 'mode', 'user_id' => POST_USERS_URL, 'group_id' => POST_GROUPS_URL ); foreach( $params as $var => $param ) { $$var = ( isset( $_REQUEST[$param] ) ) ? $_REQUEST[$param] : ''; } $user_id = intval( $user_id ); $group_id = intval( $group_id ); $cat_auth_fields = array( 'auth_view', 'auth_read', 'auth_view_file', 'auth_edit_file', 'auth_delete_file', 'auth_upload', 'auth_download', 'auth_rate', 'auth_email', 'auth_view_comment', 'auth_post_comment', 'auth_edit_comment', 'auth_delete_comment' ); $global_auth_fields = array( 'auth_search', 'auth_stats', 'auth_toplist', 'auth_viewall' ); $global_fields_names = array( 'auth_search' => $lang['Auth_search'], 'auth_stats' => $lang['Auth_stats'], 'auth_toplist' => $lang['Auth_toplist'], 'auth_viewall' => $lang['Auth_viewall'] ); $field_names = array( 'auth_view' => $lang['View'], 'auth_read' => $lang['Read'], 'auth_view_file' => $lang['View_file'], 'auth_edit_file' => $lang['Edit_file'], 'auth_delete_file' => $lang['Delete_file'], 'auth_upload' => $lang['Upload'], 'auth_download' => $lang['Download_file'], 'auth_rate' => $lang['Rate'], 'auth_email' => $lang['Email'], 'auth_view_comment' => $lang['View_comment'], 'auth_post_comment' => $lang['Post_comment'], 'auth_edit_comment' => $lang['Edit_comment'], 'auth_delete_comment' => $lang['Delete_comment'] ); $permissions_menu = array( append_sid( "admin_pa_catauth.$phpEx" ) => $lang['Cat_Permissions'], append_sid( "admin_pa_ug_auth.$phpEx?mode=user" ) => $lang['User_Permissions'], append_sid( "admin_pa_ug_auth.$phpEx?mode=group" ) => $lang['Group_Permissions'], append_sid( "admin_pa_ug_auth.$phpEx?mode=global_user" ) => $lang['User_Global_Permissions'], append_sid( "admin_pa_ug_auth.$phpEx?mode=global_group" ) => $lang['Group_Global_Permissions'] ); foreach( $permissions_menu as $url => $l_name ) { $pafiledb_template->assign_block_vars( 'pertype', array( 'U_NAME' => $url, 'L_NAME' => $l_name )); } if ( isset( $_POST['submit'] ) && ( ( $mode == 'user' && $user_id ) || ( $mode == 'group' && $group_id ) ) ) { if ( $mode == 'user' ) { $sql = "SELECT g.group_id FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND g.group_single_user = '1'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group information", "", __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); $group_id = $row['group_id']; $db->sql_freeresult( $result ); } $change_mod_list = ( isset( $_POST['moderator'] ) ) ? $_POST['moderator'] : array(); $change_acl_list = array(); for( $j = 0; $j < count( $cat_auth_fields ); $j++ ) { $auth_field = $cat_auth_fields[$j]; while ( list( $cat_id, $value ) = @each( $_POST['private_' . $auth_field] ) ) { $change_acl_list[$cat_id][$auth_field] = $value; } } $sql = ( $mode == 'user' ) ? "SELECT aa.* FROM " . PA_AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND aa.group_id = ug.group_id AND g.group_single_user = " . true : "SELECT * FROM " . PA_AUTH_ACCESS_TABLE . " WHERE group_id = $group_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql ); } $auth_access = array(); while ( $row = $db->sql_fetchrow( $result ) ) { $auth_access[$row['cat_id']] = $row; } $db->sql_freeresult( $result ); $cat_auth_action = array(); $update_acl_status = array(); $update_mod_status = array(); foreach( $pafiledb->cat_rowset as $cat_id => $cat_data ) { if ( ( isset( $auth_access[$cat_id]['auth_mod'] ) && $change_mod_list[$cat_id]['auth_mod'] != $auth_access[$cat_id]['auth_mod'] ) || ( !isset( $auth_access[$cat_id]['auth_mod'] ) && !empty( $change_mod_list[$cat_id]['auth_mod'] ) ) ) { $update_mod_status[$cat_id] = $change_mod_list[$cat_id]['auth_mod']; if ( !$update_mod_status[$cat_id] ) { $cat_auth_action[$cat_id] = 'delete'; } else if ( !isset( $auth_access[$cat_id]['auth_mod'] ) ) { $cat_auth_action[$cat_id] = 'insert'; } else { $cat_auth_action[$cat_id] = 'update'; } } for( $j = 0; $j < count( $cat_auth_fields ); $j++ ) { $auth_field = $cat_auth_fields[$j]; if ( $cat_data[$auth_field] == AUTH_ACL && isset( $change_acl_list[$cat_id][$auth_field] ) ) { if ( ( empty( $auth_access[$cat_id]['auth_mod'] ) && ( isset( $auth_access[$cat_id][$auth_field] ) && $change_acl_list[$cat_id][$auth_field] != $auth_access[$cat_id][$auth_field] ) || ( !isset( $auth_access[$cat_id][$auth_field] ) && !empty( $change_acl_list[$cat_id][$auth_field] ) ) ) || !empty( $update_mod_status[$cat_id] ) ) { $update_acl_status[$cat_id][$auth_field] = ( !empty( $update_mod_status[$cat_id] ) ) ? 0 : $change_acl_list[$cat_id][$auth_field]; if ( isset( $auth_access[$cat_id][$auth_field] ) && empty( $update_acl_status[$cat_id][$auth_field] ) && $cat_auth_action[$cat_id] != 'insert' && $cat_auth_action[$cat_id] != 'update' ) { $cat_auth_action[$cat_id] = 'delete'; } else if ( !isset( $auth_access[$cat_id][$auth_field] ) && !( $cat_auth_action[$cat_id] == 'delete' && empty( $update_acl_status[$cat_id][$auth_field] ) ) ) { $cat_auth_action[$cat_id] = 'insert'; } else if ( isset( $auth_access[$cat_id][$auth_field] ) && !empty( $update_acl_status[$cat_id][$auth_field] ) ) { $cat_auth_action[$cat_id] = 'update'; } } else if ( ( empty( $auth_access[$cat_id]['auth_mod'] ) && ( isset( $auth_access[$cat_id][$auth_field] ) && $change_acl_list[$cat_id][$auth_field] == $auth_access[$cat_id][$auth_field] ) ) && $cat_auth_action[$cat_id] == 'delete' ) { $cat_auth_action[$cat_id] = 'update'; } } } } // Checks complete, make updates to DB $delete_sql = ''; while ( list( $cat_id, $action ) = @each( $cat_auth_action ) ) { if ( $action == 'delete' ) { $delete_sql .= ( ( $delete_sql != '' ) ? ', ' : '' ) . $cat_id; } else { if ( $action == 'insert' ) { $sql_field = ''; $sql_value = ''; while ( list( $auth_type, $value ) = @each( $update_acl_status[$cat_id] ) ) { $sql_field .= ( ( $sql_field != '' ) ? ', ' : '' ) . $auth_type; $sql_value .= ( ( $sql_value != '' ) ? ', ' : '' ) . $value; } $sql_field .= ( ( $sql_field != '' ) ? ', ' : '' ) . 'auth_mod'; $sql_value .= ( ( $sql_value != '' ) ? ', ' : '' ) . ( ( !isset( $update_mod_status[$cat_id] ) ) ? 0 : $update_mod_status[$cat_id] ); $sql = "INSERT INTO " . PA_AUTH_ACCESS_TABLE . " (cat_id, group_id, $sql_field) VALUES ($cat_id, $group_id, $sql_value)"; } else { $sql_values = ''; while ( list( $auth_type, $value ) = @each( $update_acl_status[$cat_id] ) ) { $sql_values .= ( ( $sql_values != '' ) ? ', ' : '' ) . $auth_type . ' = ' . $value; } $sql_values .= ( ( $sql_values != '' ) ? ', ' : '' ) . 'auth_mod = ' . ( ( !isset( $update_mod_status[$cat_id] ) ) ? 0 : $update_mod_status[$cat_id] ); $sql = "UPDATE " . PA_AUTH_ACCESS_TABLE . " SET $sql_values WHERE group_id = $group_id AND cat_id = $cat_id"; } if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't update private forum permissions", "", __LINE__, __FILE__, $sql ); } } } if ( $delete_sql != '' ) { $sql = "DELETE FROM " . PA_AUTH_ACCESS_TABLE . " WHERE group_id = $group_id AND cat_id IN ($delete_sql)"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't delete permission entries", "", __LINE__, __FILE__, $sql ); } } $l_auth_return = ( $mode == 'user' ) ? $lang['Click_return_userauth'] : $lang['Click_return_groupauth']; $message = $lang['Auth_updated'] . '<br /><br />' . sprintf( $l_auth_return, '<a href="' . append_sid( "admin_pa_ug_auth.$phpEx?mode=$mode" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_admin_index'], '<a href="' . append_sid( $mx_root_path . "admin/index.$phpEx?pane=right" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } elseif ( isset( $_POST['submit'] ) && ( ( $mode == 'global_user' && $user_id ) || ( $mode == 'global_group' && $group_id ) ) ) { if ( $mode == 'global_user' ) { $sql = "SELECT g.group_id FROM " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND g.group_single_user = '1'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group information", "", __LINE__, __FILE__, $sql ); } $row = $db->sql_fetchrow( $result ); $group_id = $row['group_id']; $db->sql_freeresult( $result ); } $change_acl_list = array(); for( $j = 0; $j < count( $global_auth_fields ); $j++ ) { $auth_field = $global_auth_fields[$j]; $change_acl_list[$auth_field] = $_POST['private_' . $auth_field]; } $sql = ( $mode == 'global_user' ) ? "SELECT aa.* FROM " . PA_AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND aa.group_id = ug.group_id AND g.group_single_user = " . true . " AND aa.cat_id = '0'" : "SELECT * FROM " . PA_AUTH_ACCESS_TABLE . " WHERE group_id = $group_id AND cat_id = '0'"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql ); } $auth_access = ''; if ( $row = $db->sql_fetchrow( $result ) ) { $auth_access = $row; } $db->sql_freeresult( $result ); $global_auth_action = array(); $update_acl_status = array(); for( $j = 0; $j < count( $global_auth_fields ); $j++ ) { $auth_field = $global_auth_fields[$j]; if ( $pafiledb_config[$auth_field] == AUTH_ACL && isset( $change_acl_list[$auth_field] ) ) { if ( ( !is_moderator( $group_id ) && ( isset( $auth_access[$auth_field] ) && $change_acl_list[$auth_field] != $auth_access[$auth_field] ) || ( !isset( $auth_access[$cat_id][$auth_field] ) && !empty( $change_acl_list[$auth_field] ) ) ) ) { $update_acl_status[$auth_field] = $change_acl_list[$auth_field]; if ( isset( $auth_access[$auth_field] ) && empty( $update_acl_status[$auth_field] ) && $global_auth_action != 'insert' && $global_auth_action != 'update' ) { $global_auth_action = 'delete'; } else if ( !isset( $auth_access[$auth_field] ) && !( $global_auth_action == 'delete' && empty( $update_acl_status[$auth_field] ) ) ) { $global_auth_action = 'insert'; } else if ( isset( $auth_access[$auth_field] ) && !empty( $update_acl_status[$auth_field] ) ) { $global_auth_action = 'update'; } } else if ( ( !is_moderator( $auth_access['group_id'] ) && ( isset( $auth_access[$auth_field] ) && $change_acl_list[$auth_field] == $auth_access[$auth_field] ) ) && $global_auth_action == 'delete' ) { $global_auth_action = 'update'; } } } // Checks complete, make updates to DB $delete_sql = 0; if ( $global_auth_action == 'delete' ) { $delete_sql = 1; } else { if ( $global_auth_action == 'insert' ) { $sql_field = ''; $sql_value = ''; while ( list( $auth_type, $value ) = @each( $update_acl_status ) ) { $sql_field .= ( ( $sql_field != '' ) ? ', ' : '' ) . $auth_type; $sql_value .= ( ( $sql_value != '' ) ? ', ' : '' ) . $value; } $sql = "INSERT INTO " . PA_AUTH_ACCESS_TABLE . " (cat_id, group_id, $sql_field) VALUES (0, $group_id, $sql_value)"; } else { $sql_values = ''; while ( list( $auth_type, $value ) = @each( $update_acl_status ) ) { $sql_values .= ( ( $sql_values != '' ) ? ', ' : '' ) . $auth_type . ' = ' . $value; } $sql = "UPDATE " . PA_AUTH_ACCESS_TABLE . " SET $sql_values WHERE group_id = $group_id AND cat_id = 0"; } if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't update private forum permissions", "", __LINE__, __FILE__, $sql ); } } if ( $delete_sql ) { $sql = "DELETE FROM " . PA_AUTH_ACCESS_TABLE . " WHERE group_id = $group_id AND cat_id = 0"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't delete permission entries", "", __LINE__, __FILE__, $sql ); } } $l_auth_return = ( $mode == 'global_user' ) ? $lang['Click_return_userauth'] : $lang['Click_return_groupauth']; $message = $lang['Auth_updated'] . '<br /><br />' . sprintf( $l_auth_return, '<a href="' . append_sid( "admin_pa_ug_auth.$phpEx?mode=$mode" ) . '">', '</a>' ) . '<br /><br />' . sprintf( $lang['Click_return_admin_index'], '<a href="' . append_sid( $mx_root_path . "admin/index.$phpEx?pane=right" ) . '">', '</a>' ); mx_message_die( GENERAL_MESSAGE, $message ); } elseif ( ( $mode == 'user' && ( isset( $_POST['username'] ) || $user_id ) ) || ( $mode == 'group' && $group_id ) ) { if ( isset( $_POST['username'] ) ) { $this_userdata = mx_get_userdata( $_POST['username'], true ); if ( !is_array( $this_userdata ) ) { mx_message_die( GENERAL_MESSAGE, $lang['No_such_user'] ); } $user_id = $this_userdata['user_id']; } // Front end $sql = "SELECT u.user_id, u.username, u.user_level, g.group_id, g.group_name, g.group_single_user FROM " . USERS_TABLE . " u, " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug WHERE "; $sql .= ( $mode == 'user' ) ? "u.user_id = $user_id AND ug.user_id = u.user_id AND g.group_id = ug.group_id" : "g.group_id = $group_id AND ug.group_id = g.group_id AND u.user_id = ug.user_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group information", "", __LINE__, __FILE__, $sql ); } $ug_info = array(); while ( $row = $db->sql_fetchrow( $result ) ) { $ug_info[] = $row; } $db->sql_freeresult( $result ); $sql = ( $mode == 'user' ) ? "SELECT aa.*, g.group_single_user FROM " . PA_AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g WHERE ug.user_id = $user_id AND g.group_id = ug.group_id AND aa.group_id = ug.group_id AND g.group_single_user = 1" : "SELECT * FROM " . PA_AUTH_ACCESS_TABLE . " WHERE group_id = $group_id"; if ( !( $result = $db->sql_query( $sql ) ) ) { mx_message_die( GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql ); } $auth_access = array(); $auth_access_count = array(); while ( $row = $db->sql_fetchrow( $result ) ) { $auth_access[$row['cat_id']][] = $row; $auth_access_count[$row['cat_id']]++; } $db->sql_freeresult( $result ); $is_admin = ( $mode == 'user' ) ? ( ( $ug_info[0]['user_level'] == ADMIN && $ug_info[0]['user_id'] != ANONYMOUS ) ? 1 : 0 ) : 0; foreach( $pafiledb->cat_rowset as $cat_id => $cat_data ) { for( $j = 0; $j < count( $cat_auth_fields ); $j++ ) { $key = $cat_auth_fields[$j]; $value = $cat_data[$key]; switch ( $value ) { case AUTH_ALL: case AUTH_REG: $auth_ug[$cat_id][$key] = 1; break; case AUTH_ACL: $auth_ug[$cat_id][$key] = ( !empty( $auth_access_count[$cat_id] ) ) ? $pafiledb->auth_check_user( AUTH_ACL, $key, $auth_access[$cat_id], $is_admin ) : 0; $auth_field_acl[$cat_id][$key] = $auth_ug[$cat_id][$key]; break; case AUTH_MOD: $auth_ug[$cat_id][$key] = ( !empty( $auth_access_count[$cat_id] ) ) ? $pafiledb->auth_check_user( AUTH_MOD, $key, $auth_access[$cat_id], $is_admin ) : 0; break; case AUTH_ADMIN: $auth_ug[$cat_id][$key] = $is_admin; break; default: $auth_ug[$cat_id][$key] = 0; break; } } // Is user a moderator? $auth_ug[$cat_id]['auth_mod'] = ( !empty( $auth_access_count[$cat_id] ) ) ? $pafiledb->auth_check_user( AUTH_MOD, 'auth_mod', $auth_access[$cat_id], 0 ) : 0; } $optionlist_acl_adv = array(); $optionlist_mod = array(); foreach( $auth_ug as $cat_id => $user_ary ) { for( $k = 0; $k < count( $cat_auth_fields ); $k++ ) { $field_name = $cat_auth_fields[$k]; if ( $pafiledb->cat_rowset[$cat_id][$field_name] == AUTH_ACL ) { $optionlist_acl_adv[$cat_id][$k] = '<select name="private_' . $field_name . '[' . $cat_id . ']">'; if ( isset( $auth_field_acl[$cat_id][$field_name] ) && !( $is_admin || $user_ary['auth_mod'] ) ) { if ( !$auth_field_acl[$cat_id][$field_name] ) { $optionlist_acl_adv[$cat_id][$k] .= '<option value="1">' . $lang['ON'] . '</option><option value="0" selected="selected">' . $lang['OFF'] . '</option>'; } else { $optionlist_acl_adv[$cat_id][$k] .= '<option value="1" selected="selected">' . $lang['ON'] . '</option><option value="0">' . $lang['OFF'] . '</option>'; } } else { if ( $is_admin || $user_ary['auth_mod'] ) { $optionlist_acl_adv[$cat_id][$k] .= '<option value="1">' . $lang['ON'] . '</option>'; } else { $optionlist_acl_adv[$cat_id][$k] .= '<option value="1">' . $lang['ON'] . '</option><option value="0" selected="selected">' . $lang['OFF'] . '</option>'; } } $optionlist_acl_adv[$cat_id][$k] .= '</select>'; } } $optionlist_mod[$cat_id] = '<select name="moderator[' . $cat_id . ']">'; $optionlist_mod[$cat... [truncated message content] |