[Easymod-cvs] easymod/install/em_files/admin admin_easymod.php,NONE,1.1 em_general.php,NONE,1.1 em_h
Status: Beta
Brought to you by:
wgeric
From: Eric F. <wg...@us...> - 2005-12-04 03:12:42
|
Update of /cvsroot/easymod/easymod/install/em_files/admin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29556/install/em_files/admin Added Files: admin_easymod.php em_general.php em_history.php em_logs.php em_manage.php index.htm Log Message: First commit to SourceForge. Enjoy! --- NEW FILE: em_logs.php --- <?php /** * * @package EasyMOD * @version $Id: em_logs.php,v 1.1 2005/12/04 03:12:30 wgeric Exp $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * */ // // Start System // define('IN_PHPBB', 1); $phpbb_root_path = './../'; $em_page = basename(__FILE__); require($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'includes/em/em_common.'.$phpEx); // // URL used to get information about IP Addresses // $u_ip_info = 'http://www.dnsstuff.com/tools/whois.ch?ip=%s'; // // Get processing arguments // $deletemark = ( isset($HTTP_POST_VARS['delmarked']) ? true : false ); $deleteall = ( isset($HTTP_POST_VARS['delall']) ? true : false ); $marked = ( isset($HTTP_POST_VARS['mark']) ? array_map('intval', $HTTP_POST_VARS['mark']) : 0 ); $start = request_var('start', 0); $sort_days = request_var('st', 0); $sort_key = request_var('sk', ''); $sort_dir = request_var('sd', ''); // // Delete entries if requested and able // if( $deleteall || ($deletemark && is_array($marked) && count($marked) > 0) ) { $sql = 'DELETE FROM ' . EM_LOGS_TABLE . ( ($deletemark) ? (' WHERE log_id IN (' . implode(', ', $marked) . ')') : '' ); if( !$db->sql_query($sql) ) { message_die(GENERAL_ERROR, 'Could not delete log events(s)', '', __LINE__, __FILE__, $sql); } add_log('EM_Log_event_cleared'); } // // Build sort selects // $sort_days_ary = array('EM_All_Events' => 0, '1_Day' => 1, '7_Days' => 7, '2_Weeks' => 14, '1_Month' => 30, '3_Months' => 90, '6_Months' => 180, '1_Year' => 365); $s_limit_days = '<select name="st">'; foreach( $sort_days_ary as $lang_key => $days ) { $selected = ( $sort_days == $days ) ? ' selected="selected"' : ''; $s_limit_days .= '<option value="' . $days . '"' . $selected . '>' . $lang[$lang_key] . '</option>'; } $s_limit_days .= '</select>'; $sort_keys_ary = array( 'u' => array('lang' => 'Username', 'sql' => 'u.username'), 't' => array('lang' => 'Date', 'sql' => 'l.log_time'), 'i' => array('lang' => 'IP_Address', 'sql' => 'l.log_ip') ); if( !in_array($sort_key, array_keys($sort_keys_ary)) ) { $sort_key = 't'; } $s_sort_key = '<select name="sk">'; foreach( $sort_keys_ary as $key => $data ) { $selected = ( $sort_key == $key ) ? ' selected="selected"' : ''; $s_sort_key .= '<option value="' . $key . '"' . $selected . '>' . $lang[$data['lang']] . '</option>'; } $s_sort_key .= '</select>'; if( $sort_dir != 'a' && $sort_dir != 'd' ) { $sort_dir = 'd'; } $s_sort_dir = '<select name="sd">'; $s_sort_dir .= '<option value="a"' . ( $sort_dir == 'a' ? ' selected="selected"' : '') . '>' . $lang['Sort_Ascending'] . '</option>'; $s_sort_dir .= '<option value="d"' . ( $sort_dir == 'd' ? ' selected="selected"' : '') . '>' . $lang['Sort_Descending'] . '</option>'; $s_sort_dir .= '</select>'; // Define where and sort sql for use in displaying logs $limit_days = ($sort_days) ? (time() - ($sort_days * 86400)) : 0; $sort_by = $sort_keys_ary[$sort_key]['sql'] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC'); // Define parameters for use in pagination URLs $u_sort_param = "st=$sort_days&sk=$sort_key&sd=$sort_dir"; $events_per_page = $board_config['topics_per_page']; // // Grab log events // $log_rows = array(); $total_events = 0; view_log($log_rows, $total_events, $start, $events_per_page, $limit_days, $sort_by); $log_count = count($log_rows); // // Let's report them... // $template->set_filenames(array( 'body' => 'admin/em_logs.tpl') ); if( $log_count <= 0 ) { $template->assign_block_vars('no_events', array()); } else { for( $i = 0; $i < $log_count; $i++ ) { $template->assign_block_vars('logrow', array( 'ROW_CLASS' => ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'], 'U_PROFILE' => append_sid($phpbb_root_path . "profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . '=' . $log_rows[$i]['user_id']), 'USERNAME' => $log_rows[$i]['username'], 'U_IP_INFO' => sprintf($u_ip_info, $log_rows[$i]['ip']), 'IP' => $log_rows[$i]['ip'], 'DATE' => $log_rows[$i]['time'], 'MESSAGE' => $log_rows[$i]['message'], 'ID' => $log_rows[$i]['id'] )); } $template->assign_vars(array( 'PAGINATION' => generate_pagination($phpbb_root_path . "admin/$em_page?$u_sort_param", $total_events, $events_per_page, $start), 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $events_per_page ) + 1 ), ceil( $total_events / $events_per_page )) )); } // // Setup template vars. // $template->assign_vars(array( 'L_LOGS' => $lang['EM_Logs'], 'L_LOGS_EXPLAIN' => $lang['EM_Logs_explain'], 'L_DISPLAY_LOG' => $lang['EM_Display_events'], 'S_LIMIT_DAYS' => $s_limit_days, 'L_SORT_BY' => $lang['Sort_by'], 'S_SORT_KEY' => $s_sort_key, 'S_SORT_DIR' => $s_sort_dir, 'L_GO' => $lang['Go'], 'L_USERNAME' => $lang['Username'], 'L_IP' => $lang['IP_Address'], 'L_TIME' => $lang['Time'], 'L_ACTION' => $lang['Action'], 'L_MARK' => $lang['Mark'], 'L_NO_EVENTS' => $lang['EM_No_log_events'], 'L_MARK_ALL' => $lang['Mark_all'], 'L_UNMARK_ALL' => $lang['Unmark_all'], 'L_DELETE_MARKED' => $lang['Delete_marked'], 'L_DELETE_ALL' => $lang['Delete_all'] )); // // Show Page // $template->pparse('body'); include('page_footer_admin.'.$phpEx); ?> --- NEW FILE: em_manage.php --- <?php /** * * @package EasyMOD * @version $Id: em_manage.php,v 1.1 2005/12/04 03:12:30 wgeric Exp $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * */ // // Start System // define('IN_PHPBB', 1); $phpbb_root_path = './../'; $em_page = basename(__FILE__); require($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'includes/em/em_common.'.$phpEx); include($phpbb_root_path . 'includes/em/em_actions.'.$phpEx); $mode = request_var('mode', ''); //---------------------------------------------------------------------------------// // Get Info //---------------------------------------------------------------------------------// // name // decription // version // authors // size (on disk) // format (text, xml, zipped etc..) // files edited (count open commands) // included files (count copy commands) // license // author notes // history // generator // number of edits (count after adds etc..) // x to file.php ... etc... // number of sql commands (click to show) //---------------------------------------------------------------------------------// if( $mode == 'info' ) { // Get the MOD identifier $mod_file = request_var('file', ''); $mod_id = request_var('id', 0); // Set template $template->set_filenames(array( 'body' => 'admin/em_mod_info.tpl') ); if( !empty($mod_file) ) { mod_info_rows('MOD_INFO_ROWS', $mod_file); } elseif( $mod_id > 0 ) { mod_info_rows('MOD_INFO_ROWS', $mod_id); } else { message_die(GENERAL_ERROR, 'Could not load MOD information'); } $template->assign_vars(array( 'L_MOD_INFO' => $lang['EM_Mod_info'], 'L_CLOSE_WINDOW' => $lang['Close_window'], )); } //---------------------------------------------------------------------------------// // Previewing //---------------------------------------------------------------------------------// elseif( $mode == 'preview' ) { // Set template $template->set_filenames(array( 'body' => 'admin/em_preview.tpl') ); } //---------------------------------------------------------------------------------// // Installing (check) //---------------------------------------------------------------------------------// elseif( $mode == 'install' ) { $step = request_var('step', 0); // Obtain the filename $mod_file = request_var('file', ''); $mod_dir = dirname($mod_file) . '/'; $processed_dir = $mod_dir . 'processed'; $backup_dir = $mod_dir . 'backup'; // Instatiate the workers $mod_parser = new_parser($mod_file); $mod_io = new_io(); $modder = new actions('mod_io'); // Check the MOD file and Parse the MOD if( !$mod_parser->verify() ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_open', $mod_file); } $mod_parser->parse_header(); $mod_parser->parse_actions(); switch($step) { // edit the files! case 2: // Set template $template->set_filenames(array( 'body' => 'admin/em_check_install.tpl') ); // create the processed directory $mod_io->make_dir($processed_dir); // Display general MOD information mod_info_rows('MOD_INFO_ROWS', $mod_file, $mod_parser->header); // Display MOD actions foreach( $mod_parser->actions as $action => $action_data ) { if( in_array($action, array('sql','copy','open', 'diy-instructions', 'save-close-files')) ) { switch( $action ) { case 'sql': if ( !empty($action_data) ) { display_mod_action('processed', $action, implode(";\n", $action_data) . ';'); } break; case 'copy': $copy_actions = array(); for( $i = 0; $i < count($action_data); $i++ ) { $copy_files = $modder->copy($action_data[$i]['from'], $action_data[$i]['to']); for( $k = 0, $copy_total = sizeof($copy_files); $k < $copy_total; $k++ ) { $copy_actions[] = 'copy ' . $copy_files[$k]['from'] . ' to ' . $copy_files[$k]['to']; } } display_mod_action('processed', $action, implode("\n", $copy_actions)); break; case 'open': foreach( $action_data as $target_file => $target_actions ) { // create directory for the file within the processed directory and move file there for edits $file_dir = dirname($target_file); $edit_file = $processed_dir . '/' . $file_dir . '/' . basename($target_file) . '.txt'; $mod_io->make_dir($processed_dir . '/' . $file_dir); $mod_io->copy_file($target_file, $edit_file); if ( !$modder->open($edit_file) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_open', $target_file); } display_mod_action('processed', $action, $target_file); for( $i = 0, $total = sizeof($target_actions['edit']); $i < $total; $i++ ) { $actions_data = $target_actions['edit'][$i]; // should be a find here if ( !$modder->find($actions_data['find']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_find', $actions_data['find'], $target_file); } display_mod_action('processed', 'find', $actions_data['find']); // loop through the avaliable actions for( $j = 0, $action_total = sizeof($actions_data['action']); $j < $action_total; $j++ ) { $action_data = $actions_data['action'][$j]; if ( in_array($action_data['type'], array('before-add', 'after-add', 'replace-with', 'increment')) ) { $action_func = str_replace('-', '_', $action_data['type']); if ( !call_user_func(array(&$modder, $action_func), $action_data['code']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_' . $action_func, $action_data['code']); } $block = 'processed'; } else { $block = 'unprocessed'; } display_mod_action($block, $action_data['type'], $action_data['code']); } // in-line actions for( $k = 0, $inline_total = sizeof($actions_data['in-line-edit']); $k < $inline_total; $k++ ) { $inlines_data = $actions_data['in-line-edit'][$k]; // should be a in-line find here if ( !$modder->in_line_find($inlines_data['in-line-find']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_inline_find', $actions_data['find'], $target_file); } display_mod_action('processed', 'in-line-find', $inlines_data['in-line-find']); // loop through the in-line actions for( $j = 0, $action_total = sizeof($inlines_data['in-line-action']); $j < $action_total; $j++ ) { $inline_data = $inlines_data['in-line-action'][$j]; if ( in_array($inline_data['type'], array('in-line-before-add', 'in-line-after-add', 'in-line-replace-with', 'increment')) ) { $action_func = str_replace('-', '_', $inline_data['type']); if ( !call_user_func(array(&$modder, $action_func), $inline_data['code']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_' . $action_func, $action_data['code']); } $block = 'processed'; } else { $block = 'unprocessed'; } display_mod_action($block, $inline_data['type'], $inline_data['code']); } } } $modder->close(); } break; case 'diy-instructions': for( $i = 0, $total = sizeof($action_data); $i < $total; $i++ ) { display_mod_action('unprocessed', $action, $action_data[$i]); } break; case 'save-close-files': display_mod_action('processed', $action, 'EoM'); break; } } else { for( $i = 0, $total = sizeof($action_data); $i < $total; $i++ ) { display_mod_action('unprocessed', $action, $action_data[$i]); } } } $hidden_ary = array( 'mode' => 'install', 'step' => 3, 'file' => $mod_file); $template->assign_vars(array( 'S_ACTION' => append_sid($phpbb_root_path . 'admin/em_manage.'.$phpEx), 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_ary), 'L_TITLE' => $lang['EM_Install_perform'] . ' - ' . sprintf($lang['EM_Mod_steps'], 2), 'L_DESCRIPTION' => $lang['EM_Install_perform_desc'], 'L_MOD_INFO' => $lang['EM_Mod_info'], 'L_COMMANDS_PROCESSED' => $lang['EM_Commands_processed'], 'L_COMMANDS_UNPROCESSED' => $lang['EM_Commands_unprocessed'], 'L_CONTINUE' => $lang['EM_Goto_3']) ); break; // check sql, let users select which queries to perform case 3: $template->set_filenames(array( 'body' => 'admin/em_check_sql.tpl') ); $sql_ary = array(); if ( is_object($sql_parser) ) { $sql = $mod_parser->actions['sql']; for( $i = 0, $total = sizeof($sql); $i < $total; $i++ ) { // Split stream into separate SQL formatted statements $result = $sql_parser->parse_stream($sql[$i], $table_prefix); // @TODO: Define how to deal with errors or warnings here if( $result & SQL_PARSER_ERROR ) { message_die(GENERAL_ERROR, '<b>Error:</b><br />' . $sql_parser->error_message['message'] . '<br /><br /><b>SQL:</b><br />' . $sql_parser->sql_input[$sql_parser->sql_count]); } if( $result & SQL_PARSER_WARNINGS ) { for( $i = 0, $total = sizeof($sql_parser->warnings); $i < $total; $i++ ) { em_handle_error(EM_ERR_WARNING, 'SQL Warning', $sql_parser->warnings[$i]); } } $sql_ary = array_merge($sql_ary, $sql_parser->sql_output); } } for( $i = 0, $total = sizeof($sql_ary); $i < $total; $i++ ) { $hidden_ary = array( "sql[$i]" => htmlspecialchars($sql_ary[$i])); $template->assign_block_vars('sql_row', array( 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_ary), 'STATUS' => '<input type="checkbox" name="perform[' . $i . ']" value="1" checked="checked" />', 'SQL' => htmlspecialchars($sql_ary[$i])) ); } $hidden_ary = array( 'mode' => 'install', 'step' => ( !empty($sql_ary) ) ? 4 : 5, 'file' => $mod_file); $template->assign_vars(array( 'S_ACTION' => append_sid($phpbb_root_path . 'admin/em_manage.'.$phpEx), 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_ary), 'L_TITLE' => $lang['EM_Install_sql_check'] . ' - ' . sprintf($lang['EM_Mod_steps'], 3), 'L_DESCRIPTION' => $lang['EM_Install_sql_check_desc'], 'L_SQL_QUERY' => $lang['EM_Sql_query'], 'L_SQL_STATUS' => $lang['EM_Sql_perform'], 'L_CONTINUE' => ( !empty($sql_ary) ) ? $lang['EM_Goto_4'] : $lang['EM_Goto_5']) ); break; // perform sql case 4: $template->set_filenames(array( 'body' => 'admin/em_check_sql.tpl') ); $sql = ( isset($HTTP_POST_VARS['sql']) ) ? $HTTP_POST_VARS['sql'] : array(); $perform = ( isset($HTTP_POST_VARS['perform']) ) ? $HTTP_POST_VARS['perform'] : array(); for( $i = 0, $total = sizeof($sql); $i < $total; $i++ ) { $sql[$i] = htmlspecialchars(stripslashes($sql[$i])); if ( isset($perform[$i]) && $perform[$i] == true ) { $skip = false; if ( $db->sql_query($sql[$i]) ) { $status = true; } else { $status = false; vd(array($sql[$i], $db->sql_error())); } } else { $skip = true; } $template->assign_block_vars('sql_row', array( 'STATUS' => ( $skip === true ) ? $lang['EM_Skipped'] : (( $status === true ) ? $lang['EM_Passed'] : $lang['EM_Failed']), 'SQL' => $sql[$i]) ); } $hidden_ary = array( 'mode' => 'install', 'step' => 5, 'file' => $mod_file); $template->assign_vars(array( 'S_ACTION' => append_sid($phpbb_root_path . 'admin/em_manage.'.$phpEx), 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_ary), 'L_TITLE' => $lang['EM_Install_sql_perform'] . ' - ' . sprintf($lang['EM_Mod_steps'], 4), 'L_DESCRIPTION' => $lang['EM_Install_sql_perform_desc'], 'L_SQL_QUERY' => $lang['EM_Sql_query'], 'L_SQL_STATUS' => $lang['EM_Status'], 'L_CONTINUE' => $lang['EM_Goto_5']) ); break; // post process, move files, finish everything up, etc case 5: // Set template $template->set_filenames(array( 'body' => 'admin/em_post_process.tpl') ); // create the backup directory $mod_io->make_dir($backup_dir); // Display general MOD information mod_info_rows('MOD_INFO_ROWS', $mod_file, $mod_parser->header); $backup_files = array(); $copy_files = array(); $diy_instructions = array(); // Display MOD actions foreach( $mod_parser->actions as $action => $action_data ) { if( in_array($action, array('copy','open', 'diy-instructions')) ) { switch( $action ) { case 'copy': for( $i = 0; $i < count($action_data); $i++ ) { $copy_files_tmp = $modder->copy($action_data[$i]['from'], $action_data[$i]['to']); for( $k = 0; $k < count($copy_files_tmp); $k++ ) { $copy_files[] = array( 'from' => $mod_dir . $copy_files_tmp[$k]['from'], 'to' => str_replace('../', '', str_replace('./', '', $copy_files_tmp[$k]['to']))); // easy to by pass but mods shouldn't be doing that } } break; case 'open': foreach( $action_data as $target_file => $target_actions ) { // make directory for the file if ( !$mod_io->make_dir($backup_dir . '/' . dirname($target_file)) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_mkdir_backup', $backup_dir . '/' . dirname($target_file)); } // move backup into place if ( !$mod_io->copy_file($target_file, $backup_dir . '/' . $target_file . '.txt') ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_move_backup', $target_file); } $template->assign_block_vars('backup_row', array( 'FROM' => $target_file, 'TO' => $backup_dir . '/' . $target_file . '.txt') ); $copy_files[] = array( 'from' => $processed_dir . '/' . $target_file . '.txt', 'to' => $target_file); } break; case 'diy-instructions': $diy_instructions = $action_data; break; } } } if ( !empty($diy_instructions) ) { $template->assign_block_vars('switch_diy', array( 'DIY_INSTRUCTIONS' => str_replace("\n", '<br />', implode('<br /><br />', $diy_instructions))) ); } for( $i = 0, $total = count($copy_files); $i < $total; $i++ ) { // make directory for the file if ( !$mod_io->make_dir(dirname($copy_files[$i]['to'])) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_mkdir_file', dirname($copy_files[$i]['to'])); } if ( !$mod_io->copy_file($copy_files[$i]['from'], $copy_files[$i]['to']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_move_file', $copy_files[$i]['from']); } $template->assign_block_vars('copy_row', array( 'FROM' => $copy_files[$i]['from'], 'TO' => $copy_files[$i]['to']) ); } $mod_file = str_replace("'", "''", htmlspecialchars(stripslashes($mod_file))); $mod_name = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['name']))); $mod_version = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['version']))); $author_username = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['author'][0]['username']))); $author_email = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['author'][0]['email']))); $author_realname = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['author'][0]['realname']))); $author_website = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['author'][0]['website']))); $mod_desc = str_replace("'", "''", htmlspecialchars(stripslashes($mod_parser->header['desc']))); add_log('EM_Log_install', $mod_name, $mod_version); $sql = 'INSERT INTO ' . EM_MODS_TABLE . "( mod_file, mod_name, mod_version, mod_author_username, mod_author_email, mod_author_realname, mod_author_website, mod_desc ) VALUES ('$mod_file', '$mod_name', '$mod_version', '$author_username', '$author_email', '$author_realname', '$author_realname', '$mod_desc' )"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not insert MOD information', '', __LINE__, __FILE__, $sql); } $template->assign_vars(array( 'L_TITLE' => $lang['EM_Install_post'] . ' - ' . sprintf($lang['EM_Mod_steps'], 5), 'L_DESCRIPTION' => $lang['EM_Install_post_desc'], 'L_MOD_INFO' => $lang['EM_Mod_info'], 'L_COPY_FILES' => $lang['EM_Copy_files'], 'L_BACKUP_FILES' => $lang['EM_Backup_files'], 'L_DIY_INSTRUCTIONS' => $lang['EM_DIY_instructions'], 'L_DIY_INSTRUCTIONS_DESC' => $lang['EM_DIY_instructions_desc'], 'L_INSTALL_SUCCESSFUL' => $lang['EM_Mod_install_success'], 'L_FROM' => $lang['EM_From'], 'L_TO' => $lang['EM_To']) ); break; // check install default: // Set template $template->set_filenames(array( 'body' => 'admin/em_check_install.tpl') ); // Display general MOD information mod_info_rows('MOD_INFO_ROWS', $mod_file, $mod_parser->header); // Display MOD actions foreach( $mod_parser->actions as $action => $action_data ) { if( in_array($action, array('sql','copy','open', 'diy-instructions', 'save-close-files')) ) { switch( $action ) { case 'sql': if ( !empty($action_data) ) { display_mod_action('processed', $action, implode(";\n", $action_data) . ';'); } break; case 'copy': $copy_actions = array(); for( $i = 0; $i < count($action_data); $i++ ) { $copy_files = $modder->copy($action_data[$i]['from'], $action_data[$i]['to']); for( $k = 0, $copy_total = sizeof($copy_files); $k < $copy_total; $k++ ) { $copy_actions[] = 'copy ' . $copy_files[$k]['from'] . ' to ' . $copy_files[$k]['to']; } } display_mod_action('processed', $action, implode("\n", $copy_actions)); break; case 'open': foreach( $action_data as $target_file => $target_actions ) { // performing open to see if the file exists if ( !$modder->open($phpbb_root_path . $target_file) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_open', $target_file); } display_mod_action('processed', $action, $target_file); for( $i = 0, $total = sizeof($target_actions['edit']); $i < $total; $i++ ) { $actions_data = $target_actions['edit'][$i]; // should be a find here // performing the find to see if it works if ( !$modder->find($actions_data['find']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_find', $actions_data['find'], $target_file); } display_mod_action('processed', 'find', $actions_data['find']); // loop through the avaliable actions for( $j = 0, $action_total = sizeof($actions_data['action']); $j < $action_total; $j++ ) { $action_data = $actions_data['action'][$j]; if ( in_array($action_data['type'], array('before-add', 'after-add', 'replace-with', 'increment')) ) { $block = 'processed'; } else { $block = 'unprocessed'; } display_mod_action($block, $action_data['type'], $action_data['code']); } // in-line actions for( $k = 0, $inline_total = sizeof($actions_data['in-line-edit']); $k < $inline_total; $k++ ) { $inlines_data = $actions_data['in-line-edit'][$k]; // should be a in-line find here if ( !$modder->in_line_find($inlines_data['in-line-find']) ) { em_handle_error(EM_ERR_CRITICAL, 'EM_Err_inline_find', $actions_data['find'], $target_file); } display_mod_action('processed', 'in-line-find', $inlines_data['in-line-find']); // loop through the in-line actions for( $j = 0, $action_total = sizeof($inlines_data['in-line-action']); $j < $action_total; $j++ ) { $inline_data = $inlines_data['in-line-action'][$j]; if ( in_array($inline_data['type'], array('in-line-before-add', 'in-line-after-add', 'in-line-replace-with', 'increment')) ) { $block = 'processed'; } else { $block = 'unprocessed'; } display_mod_action($block, $inline_data['type'], $inline_data['code']); } } } } break; case 'diy-instructions': for( $i = 0, $total = sizeof($action_data); $i < $total; $i++ ) { display_mod_action('processed', $action, $action_data[$i]); } break; case 'save-close-files': display_mod_action('processed', $action, 'EoM'); break; } } else { for( $i = 0, $total = sizeof($action_data); $i < $total; $i++ ) { display_mod_action('unprocessed', $action, $action_data[$i]); } } } // temp display_mod_action('processed', 'mod-parser-class', var_export($mod_parser, true)); $hidden_ary = array( 'mode' => 'install', 'step' => 2, 'file' => $mod_file); $template->assign_vars(array( 'S_ACTION' => append_sid($phpbb_root_path . 'admin/em_manage.'.$phpEx), 'S_HIDDEN_FIELDS' => build_hidden_fields($hidden_ary), 'L_TITLE' => $lang['EM_Install_check'] . ' - ' . sprintf($lang['EM_Mod_steps'], 1), 'L_DESCRIPTION' => $lang['EM_Install_check_desc'], 'L_MOD_INFO' => $lang['EM_Mod_info'], 'L_COMMANDS_PROCESSED' => $lang['EM_Commands_processed'], 'L_COMMANDS_UNPROCESSED' => $lang['EM_Commands_unprocessed'], 'L_CONTINUE' => $lang['EM_Goto_2']) ); break; } } //---------------------------------------------------------------------------------// // Uninstalling //---------------------------------------------------------------------------------// elseif( $mode == 'uninstall' ) { $step = request_var('step', 0); switch($step) { default: // Set template $template->set_filenames(array( 'body' => 'admin/em_check_uninstall.tpl') ); break; } } //---------------------------------------------------------------------------------// // Updating (check) //---------------------------------------------------------------------------------// elseif( $mode == 'update' ) { $step = request_var('step', 0); switch($step) { default: // Set template $template->set_filenames(array( 'body' => 'admin/em_check_update.tpl') ); $mod_id = request_var('id', 0); // Get MOD info $sql = 'SELECT mod_id, mod_file, mod_name, mod_version, mod_desc, mod_styles FROM ' . EM_MODS_TABLE . ' WHERE mod_id = ' . $mod_id; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not select MOD information', '', __LINE__, __FILE__, $sql); } $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); // Need Style Update? if( styles_outdated($row['mod_styles']) ) { // Add style block, with more info //$mod_status_img = $images['em_status_style']; //$mod_status_lang = $lang['EM_Status_style']; } else { // Add up to date styles block. } // Need Lang Update? (manual, but notify) break; } } //---------------------------------------------------------------------------------// // Available MODs Report //---------------------------------------------------------------------------------// else { // Set template $template->set_filenames(array( 'body' => 'admin/em_manage_install.tpl') ); // Get installed MODs from DB $installed_mods = array(); $sql = 'SELECT mod_file FROM ' . EM_MODS_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not select MOD information', '', __LINE__, __FILE__, $sql); } while( $row = $db->sql_fetchrow($result) ) { $installed_mods[] = $phpbb_root_path . $board_config['em_mod_dir'] . $row['mod_file']; } $db->sql_freeresult($result); // Get uninstalled, or new mods $new_mods = mod_scan($phpbb_root_path . $board_config['em_mod_dir'], $installed_mods); $new_mods_count = count($new_mods); if( $new_mods_count <= 0 ) { // No MODs available $template->assign_block_vars('no_available_mods', array( 'L_NO_AVAILABLE_MODS' => $lang['EM_No_available_mods'], )); } else { // oowwww, new goodies ... for( $i = 0; $i < $new_mods_count; $i++ ) { $row_class = (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2']; $mod = $new_mods[$i]; $template->assign_block_vars('available_mods', array( 'S_MORE_INFO' => append_sid(basename(__FILE__) . '?mode=info&file=' . urlencode($mod['file'])), 'S_PREVIEW' => append_sid(basename(__FILE__) . '?mode=preview&file=' . urlencode($mod['file'])), 'S_INSTALL' => append_sid(basename(__FILE__) . '?mode=install&file=' . urlencode($mod['file'])), 'ROW_CLASS' => $row_class, 'MOD_NAME' => $mod['name'], 'MOD_DESC' => str_cut($mod['desc'], 80), 'MOD_VERSION' => $mod['version'], 'MOD_AUTHOR' => $mod['author'][0]['username'], )); } } // Misc. template vars $template->assign_vars(array( 'L_MANAGE' => $lang['EM_Install_MODs'], 'L_MANAGE_EXPLAIN' => $lang['EM_Install_MODs_explain'], 'L_AVAILABLE_MODS' => $lang['EM_Available_mods'], 'L_MOD_NAME' => $lang['EM_Mod_name'], 'L_MOD_DESCRIPTION' => $lang['EM_Mod_description'], 'L_MOD_VERSION' => $lang['EM_Mod_version'], 'L_MOD_AUTHOR' => $lang['EM_Mod_author'], 'L_MORE_INFO' => $lang['EM_More_info'], 'L_PREVIEW' => $lang['EM_Preview'], 'L_INSTALL' => $lang['EM_Install'], )); } //---------------------------------------------------------------------------------// // // Show Page // $template->pparse('body'); include('page_footer_admin.'.$phpEx); //---------------------------------------------------------------------------------// // FUNCTIONS //---------------------------------------------------------------------------------// function mod_info_rows($template_variable, $mod_id, $mod_header = '') { global $template, $theme, $lang, $db; if( is_numeric($mod_id) ) { // Draw data from DB $sql = 'SELECT * FROM ' . EM_MODS_TABLE . ' WHERE mod_id = ' . $mod_id; if( !($result = $db->sql_query($sql)) || !($mod_row = $db->sql_fetchrow($result)) ) { message_die(GENERAL_ERROR, 'Could not select MOD information', '', __LINE__, __FILE__, $sql); } $db->sql_freeresult($result); $mod_info = array( 'mod_name' => htmlspecialchars($mod_row['mod_name']), 'mod_author' => array( 'username' => $mod_row['mod_author_username'], 'email' => $mod_row['mod_author_email'], 'realname' => $mod_row['mod_author_realname'], 'website' => $mod_row['mod_author_website']), 'mod_description' => htmlspecialchars($mod_row['mod_desc']), 'mod_version' => $mod_row['mod_version'], 'mod_file' => $mod_row['mod_file'], ); // If MOD file still around, get more information $mod_parser = new_parser($mod_row['mod_file']); if( $mod_parser->verify() ) { $mod_header = $mod_parser->parse_header(); $mod_info['author_notes'] = str_replace("\n", '<br />', htmlspecialchars($mod_header['author-notes'])); } } else { $mod_file = $mod_id; } if( !empty($mod_file) && empty($mod_header) ) { // Setup Parser $mod_parser = new_parser($mod_file); if( !$mod_parser->verify() ) { message_die(GENERAL_ERROR, sprintf('Could not open file "%s"', $mod_file)); } // Get all the info $mod_header = $mod_parser->parse_header(); } if ( empty($mod_info) ) { $mod_info = array( 'mod_name' => htmlspecialchars($mod_header['name']), 'mod_author' => array( 'username' => $mod_header['author'][0]['username'], 'email' => $mod_header['author'][0]['email'], 'realname' => $mod_header['author'][0]['realname'], 'website' => $mod_header['author'][0]['website']), 'mod_description' => htmlspecialchars($mod_header['desc']), 'mod_version' => $mod_header['version'], 'mod_file' => basename($mod_file), 'author_notes' => str_replace("\n", '<br />', htmlspecialchars($mod_header['author-notes'])), ); } // Set template $template->set_filenames(array( 'mod_info_rows' => 'admin/em_mod_info_rows.tpl') ); // Send data to templates // did this automatically, to start, might want to do it all manually, for the proper effect $info_names = array_keys($mod_info); for( $i = 0; $i < count($mod_info); $i++ ) { if ( $info_names[$i] == 'mod_author' ) { // splitting these up into multiple lines so we don't have one long mess even though it still is a mess $username = ( !empty($mod_info['mod_author']['username']) && strtolower($mod_info['author']['username']) != 'n/a' ) ? $mod_info['mod_author']['username'] : $lang['EM_NA']; $email = ( !empty($mod_info['mod_author']['email']) && strtolower($mod_info['mod_author']['email']) != 'n/a' ) ? '<a href="mailto:' . $mod_info['mod_author']['email'] . '">' . $mod_info['mod_author']['email'] . '</a>' : $lang['EM_NA']; $website = ( !empty($mod_info['mod_author']['website']) && strtolower($mod_info['mod_author']['website']) != 'n/a' ) ? '<a href="' . $mod_info['mod_author']['website'] . '">' . $mod_info['mod_author']['website'] . '</a>' : $lang['EM_NA']; $realname = ( !empty($mod_info['mod_author']['realname']) && strtolower($mod_info['author']['realname']) != 'n/a' ) ? $mod_info['mod_author']['realname'] : $lang['EM_NA']; $mod_info['mod_author'] = $username . ' < ' . $email . ' > (' . $realname . ') ' . $website; } $template->assign_block_vars('mod_info', array( 'ROW_CLASS' => (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'], 'INFO_NAME' => str_replace(' ', ' ', $lang['EM_' . ucfirst($info_names[$i])]), 'INFO_DATA' => $mod_info[$info_names[$i]] )); } $template->assign_var_from_handle($template_variable, 'mod_info_rows'); } function display_mod_action($block, $action, $body) { global $template, $theme; $template->assign_block_vars($block, array( 'ROW_CLASS' => $theme['td_class2'], 'LINE' => '<b>' . strtoupper($action) . '</b>' )); $template->assign_block_vars($block, array( 'ROW_CLASS' => $theme['td_class1'], 'LINE' => '<pre>' . htmlspecialchars($body) . '</pre>' )); } //---------------------------------------------------------------------------------// ?> --- NEW FILE: em_general.php --- <?php /** * * @package EasyMOD * @version $Id: em_general.php,v 1.1 2005/12/04 03:12:30 wgeric Exp $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * */ // // Start System // define('IN_PHPBB', 1); $phpbb_root_path = './../'; $em_page = basename(__FILE__); require($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'includes/em/em_common.'.$phpEx); // // EasyMOD General ... // $template->set_filenames(array( 'body' => 'admin/em_general.tpl') ); $update = request_var('update', ''); // Updating Settings if( $update == 'settings' ) { foreach($board_config as $config_name => $void) { $new_config = request_var($config_name, $void); if(!empty($new_config)) { if ($config_name == 'em_ftp_password') { $key = ''; for($i = 1, $total = strlen($board_config['em_pass']); $i < $total; $i = round(($i+1)*2)) { $key .= md5($board_config['em_pass']{$i}); } $new_config = $crypt->encrypt($new_config, $key); } $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . str_replace("\'", "''", $new_config) . "' WHERE config_name = '$config_name'"; if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Failed to update general EM configuration for $config_name", "", __LINE__, __FILE__, $sql); } } } $message = $lang['EM_Settings_updated'] . "<br /><br />" . sprintf($lang['EM_Click_return_general'], "<a href=\"" . append_sid(basename(__FILE__)) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } // Updating password // Ask for old pass? elseif( $update == 'pass' ) { $pass = request_var('pass', ''); $pass_confirm = request_var('pass_confirm', ''); if($pass != $pass_confirm) { $message = $lang['EM_Passwords_no_match'] . "<br /><br />" . sprintf($lang['EM_Click_return_general'], "<a href=\"" . append_sid(basename(__FILE__)) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } $sql = "UPDATE " . CONFIG_TABLE . " SET config_value = '" . md5($pass) . "' WHERE config_name = 'em_pass'"; if(!$db->sql_query($sql)) { message_die(GENERAL_ERROR, "Failed to update EM password", "", __LINE__, __FILE__, $sql); } $message = $lang['EM_Password_updated'] . "<br /><br />" . sprintf($lang['EM_Click_return_general'], "<a href=\"" . append_sid(basename(__FILE__)) . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>"); message_die(GENERAL_MESSAGE, $message); } $allowed_methods = '<select name="em_method">'; $methods = load_methods(); $method_files = array(); for($i = 0, $total = sizeof($methods); $i < $total; $i++) { include($phpbb_root_path . $em_dir . 'includes/em/em_methods_' . $methods[$i]['file'] . '.'. $phpEx); $mod_io->test($debug, $methods[$i]['name']); $method_files[$methods[$i]['name']] = $methods[$i]['file']; } foreach ($method_files as $name => $file) { $selected = ( $board_config['em_method'] == $file ) ? ' selected="selected"' : ''; $method_lang = ( isset($lang['EM_' . $name]) ) ? $lang['EM_' . $name] : str_replace('_', ' ', $name); $allowed_methods .= '<option value="' . $file . '"' . $selected . '>' . $method_lang . '</option>'; } $allowed_methods .= '</select>'; // Template Vars $template->assign_vars(array( 'S_PASSWORD_ACTION' => append_sid(basename(__FILE__) . '?update=pass'), 'S_SETTINGS_ACTION' => append_sid(basename(__FILE__) . '?update=settings'), 'L_GENERAL' => $lang['EM_General'], 'L_GENERAL_EXPLAIN' => $lang['EM_General_explain'], 'L_GENERAL_SETTINGS' => $lang['EM_General_settings'], 'L_PASSWORD_SETTINGS' => $lang['EM_Password_settings'], 'L_PASSWORD' => $lang['EM_Password'], 'L_PASSWORD_CONFIRM' => $lang['EM_Password_confirm'], 'L_METHOD' => $lang['EM_method'], 'L_TEMP_PATH' => $lang['EM_temp_path'], 'L_FILE_PERM' => $lang['EM_file_perm'], 'L_DIR_PERM' => $lang['EM_dir_perm'], 'L_FTP_SETTINGS' => $lang['EM_ftp_conn'], 'L_FTP_USER' => $lang['EM_ftp_user'], 'L_FTP_PASS' => $lang['EM_ftp_pass'], 'L_FTP_HOST' => $lang['EM_ftp_host'], 'L_FTP_PATH' => $lang['EM_ftp_path'], 'L_FTP_PORT' => $lang['EM_ftp_port'], 'L_FTP_TIME' => $lang['EM_ftp_time'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_MOD_DIR' => $lang['EM_Mod_dir'], 'L_MOD_DIR_EXPLAIN' => $lang['EM_Mod_dir_explain'], 'EM_METHODS' => $allowed_methods, 'EM_TEMP_PATH' => $board_config['em_tmp_path'], 'EM_FILE_PERM' => $board_config['em_file_perms'], 'EM_DIR_PERM' => $board_config['em_dir_perms'], 'EM_MOD_DIR' => $board_config['em_mod_dir'], 'EM_FTP_USER' => $board_config['em_ftp_user'], 'EM_FTP_HOST' => $board_config['em_ftp_host'], 'EM_FTP_PATH' => $board_config['em_ftp_root_path'], 'EM_FTP_PORT' => $board_config['em_ftp_port'], 'EM_FTP_TIME' => $board_config['em_ftp_timeout'] )); // // Show Page // $template->pparse('body'); include('page_footer_admin.'.$phpEx); ?> --- NEW FILE: admin_easymod.php --- <?php /** * * @package EasyMOD * @version $Id: admin_easymod.php,v 1.1 2005/12/04 03:12:30 wgeric Exp $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * */ // // Set Menu // if( !empty($setmodules) ) { include_once($phpbb_root_path . 'includes/em/em_acp_menu.'.$phpEx); return; } redirect($phpbb_root_path . 'admin/index.'.$phpEx); ?> --- NEW FILE: index.htm --- <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> --- NEW FILE: em_history.php --- <?php /** * * @package EasyMOD * @version $Id: em_history.php,v 1.1 2005/12/04 03:12:30 wgeric Exp $ * @copyright (c) 2005 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU General Public License * */ // // Start System // define('IN_PHPBB', 1); $phpbb_root_path = './../'; $em_page = basename(__FILE__); require($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'includes/em/em_common.'.$phpEx); include($phpbb_root_path . 'includes/em/em_actions.'.$phpEx); $mode = request_var('mode', ''); //---------------------------------------------------------------------------------// // MODs History Report //---------------------------------------------------------------------------------// // Set template $template->set_filenames(array( 'body' => 'admin/em_manage_history.tpl') ); // Get installed MODs from DB $installed_mods = array(); $mods_count = 0; $sql = 'SELECT mod_id, mod_file, mod_name, mod_version, mod_desc, mod_styles FROM ' . EM_MODS_TABLE; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not select MOD information', '', __LINE__, __FILE__, $sql); } while( $row = $db->sql_fetchrow($result) ) { // Default Status $mod_status_img = $images['em_status_ready']; $mod_status_lang = $lang['EM_Status_ready']; // Track MOD as installed $installed_mods[] = $phpbb_root_path . $board_config['em_mod_dir'] . $row['mod_file']; // Check Styles if( styles_outdated($row['mod_styles']) ) { $mod_status_img = $images['em_status_style']; $mod_status_lang = $lang['EM_Status_style']; } // Show to page $template->assign_block_vars('installed_mods', array( 'S_MORE_INFO' => append_sid(basename(__FILE__) . '?mode=info&id=' . $row['mod_id']), 'S_UPDATE' => append_sid(basename(__FILE__) . '?mode=check_update&id=' . $row['mod_id']), 'S_UNINSTALL' => append_sid(basename(__FILE__) . '?mode=check_uninstall&id=' . $row['mod_id']), 'ROW_CLASS' => (!($mods_count % 2)) ? $theme['td_class1'] : $theme['td_class2'], 'MOD_STATUS_IMG' => $mod_status_img, 'MOD_STATUS_LANG' => $mod_status_lang, 'MOD_NAME' => $row['mod_name'], 'MOD_DESC' => str_cut($row['mod_desc'], 80), 'MOD_VERSION' => $row['mod_version'], 'MOD_STYLES' => '', )); $mods_count++; } $db->sql_freeresult($result); if( $mods_count <= 0 ) { $template->assign_block_vars('no_installed_mods', array( 'L_NO_INSTALLED_MODS' => $lang['EM_No_installed_mods'], )); } // Misc. template vars $template->assign_vars(array( 'L_MANAGE' => $lang['EM_History'], 'L_MANAGE_EXPLAIN' => $lang['EM_History_explain'], 'L_INSTALLED_MODS' => $lang['EM_Installed_mods'], 'L_MOD_STATUS' => $lang['EM_Mod_status'], 'L_MOD_NAME' => $lang['EM_Mod_name'], 'L_MOD_DESCRIPTION' => $lang['EM_Mod_description'], 'L_MOD_VERSION' => $lang['EM_Mod_version'], 'L_MORE_INFO' => $lang['EM_More_info'], 'L_UPDATE' => $lang['EM_Update'], 'L_UNINSTALL' => $lang['EM_Uninstall'], )); // // Show Page // $template->pparse('body'); include('page_footer_admin.'.$phpEx); ?> |