Easymod

Hulp nodig bij een modificaties of op zoek naar een MOD? Bekijk ons archief. Support wordt helaas niet meer verleend.
Forumregels

Sinds 1 januari 2009 wordt phpBB2 niet meer ondersteund.
Onderstaande informatie is verouderd en dient uitsluitend als archief.
phpBB2.0.x
Gesloten
koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Easymod

Bericht door koudekerk » 17 apr 2004, 17:24

Er staat in het txt filtje van easey mod dit maar wat moet je doen dan?

Code: Selecteer alles

<?php
/***************************************************************************
 *                              admin_easymod.php
 *                            -------------------
 *   begin                : Sunday, Mar 31, 2002
 *   copyright            : (C) 2003 Nuttzy
 *   email                : nuttzy@blizzhackers.com
 *
 *   $Id: admin_easymod.php,v 0.0.10a 2003/08/03 00:00:00 nuttzy Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', 1);

// entries to be displayed in the ACP index
if (!empty($setmodules))
{
	$file = basename(__FILE__);
	$module['Modifications']['MOD_ainstall'] = "$file?mode=install";
	$module['Modifications']['MOD_settings'] = "$file?mode=settings";
	$module['Modifications']['MOD_history'] = "$file?mode=history";
	return;
}


//
// Let's set the root dir for phpBB
//
$script_path = 'admin' ;
$phpbb_root_path = './../';
require($phpbb_root_path . 'extension.inc');

// if we are downloading the file (or backup), then we don't want to call pagestart.php
$mode = (isset($HTTP_POST_VARS['mode'])) ? htmlspecialchars($HTTP_POST_VARS['mode']) : '';
if (($mode == 'download_file') || ($mode == 'download_backup'))
{
	include($phpbb_root_path . 'config.'.$phpEx);
	include($phpbb_root_path . 'includes/constants.'.$phpEx);
	include($phpbb_root_path . 'includes/functions.'.$phpEx);
	include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
	include($phpbb_root_path . 'includes/db.'.$phpEx);
}
else
{
	require('pagestart.' . $phpEx);
}
$mode = '' ;

// load the EM functions; make sure we are using the proper lang; if this is a download or display, then we won't
//   know the lang, so default to english; there is probably a better way to do this though
if ($board_config['default_lang'] == '')
{
	include($phpbb_root_path . 'language/lang_english/lang_easymod.' . $phpEx);
}
else
{
	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_easymod.' . $phpEx);
}
include($phpbb_root_path . '/admin/admin_easymod_functions.php') ;



///
///
define('EASYMOD_VER', 'alpha3 (0.0.10a)') ;
define('NUTTZY_LINK', '<a href="http://www.blizzhackers.com">Nuttzy</a>') ;
///
///


// write command info to the screen (add to template)
function display_line( $command, $body)
{
	global $template, $theme ;

	// print the command
	$template->assign_block_vars('processed', array(
		'ROW_CLASS' => $theme['td_class2'],
		'LINE' => '<b>' . htmlspecialchars($command['command']) . '</b> &nbsp;&nbsp;&nbsp;line #' . $command['line'] . "\n")
	);


	// print the command body
	$line = '' ;
	for ($i=0; $i<count($body); $i++)
	{
//		$line .= htmlspecialchars($body[$i]) . "<br>\n" ;
		$line .= htmlspecialchars($body[$i]) ;
	}

	// make sure there is a body to print!
	if (count($body) > 0)
	{
		$template->assign_block_vars('processed', array(
			'ROW_CLASS' => $theme['td_class1'],
//			'LINE' => $line)
			'LINE' => "\n<pre>$line</pre>\n")
		);
	}
}


// write command info to the screen (add to template)
function display_unprocessed_line( $command, $body)
{
	global $template, $theme ;

	// print the command
	$template->assign_block_vars('unprocessed', array(
		'ROW_CLASS' => $theme['td_class2'],
		'LINE' => '<b>' . htmlspecialchars($command['command']) . '</b> &nbsp;&nbsp;&nbsp;line #' . $command['line'] . "\n")
	);

	// print the command body
	$line = '' ;	
	for ($i=0; $i<count($body); $i++)
	{
//		$line .= htmlspecialchars($body[$i]) . "<br>\n" ;
		$line .= htmlspecialchars($body[$i]) ;
	}
	$template->assign_block_vars('unprocessed', array(
		'ROW_CLASS' => $theme['td_class1'],
//		'LINE' => $line)
		'LINE' => "\n<pre>$line</pre>\n")
	);
}


// display error message info; it will look like a message_die box
function display_error( $message)
{
	global $template, $mode ;

	// template is not defined if we are displaying/downloading the file so get us out of here
	if (($mode == 'display_file') || ($mode == 'download_file'))
	{
		return ;
	}

	$template->assign_block_vars('error', array(
		'L_TITLE' => $lang['EM_error_detail'],
		'ERROR_MESSAGE' => $message)
	) ;
}


// look in the DB to see if we already processed this MOD
function is_unprocessed( $db, $mod_title, $mod_version, $phpbb_version)
{
	$sql = "SELECT *
		FROM " . EASYMOD_TABLE . " 
		WHERE mod_title = '$mod_title' 
			AND mod_version = '$mod_version' 
		ORDER BY mod_id DESC" ;
	if ( !($result = $db->sql_query($sql)) )
	{
		return true ;
	}

	$row = $db->sql_fetchrow($result) ;
	if ( $row['mod_phpBB_version'] == $phpbb_version)
	{
		return false ;
	}
	else
	{
		return true ;
	}
}


// parse the MOD file and get properties about it (make sure it really is a MOD too)
function get_mod_properties( $file, &$mod_title, &$mod_author_handle, &$mod_author_email, &$mod_author_name, &$mod_author_url, &$mod_description, &$mod_version, &$compliant)
{
	// used to add a little tolerance on the Author line
	$faux_author = false ;
	$legit_author = false ;

	// open the file and grab the first line
	$f_mod_script = fopen ( $file, 'r');
	if (!$f_mod_script)
	{
		return false ;
	}
	$buffer = fgets($f_mod_script, 1024);


	// see if it is EMC right away; first line starts with ## on it and contains "easymod"
	$compliant = false ;
	if ((stristr( $buffer, 'easymod')) && (substr($buffer,0,2) == '##'))
	{
		$compliant = true ;
	}

	// loop through file and try to get MOD info; only look at lines starting with ##
	$getting_desc = 0 ;
	$first_line = true ;
	while ( (!feof($f_mod_script)) && ( substr($buffer,0,2) == '##'))
	{
		// we've already gotten the first line but still need to process it
		$buffer = ($first_line) ? $buffer : fgets($f_mod_script, 1024);
		$first_line = false ;

		// check for mod title; allow just "title" if we don't have a title yet
		if ((stristr( $buffer, 'MOD Title:')) || (($mod_title == '') && (stristr( $buffer, 'Title:'))))
		{
			$mod_title = trim(substr( $buffer, strpos( $buffer, ":")+1)) ;
			$getting_desc = 0 ;
		}

		// check for author info
		else if ( (stristr( $buffer, 'MOD Author:')) || (stristr( $buffer, 'Author:') ))
		{
			// if we've already gotten a legit MOD Author, then don't go looking for another
			if ($legit_author)
			{
				continue ;
			}

			// they are using just Author instead of MOD author and we've already gotten a "faux" one; get outta here
			else if ((!stristr( $buffer, 'MOD Author:')) && ($faux_author))
			{
				continue ;
			}

			// again using some variant of "Author" but allow it; we'll only accept the first non-MOD Author entry
			else if ((!stristr( $buffer, 'MOD Author:')) && (!$faux_author))
			{
				$faux_author = true ;
			}

			// they are using the proper "MOD Author" label
			else
			{
				$legit_author = true ;
			}

			// init our vars
			$mod_author_handle = '' ;
			$mod_author_email = '' ;
			$mod_author_name = '' ;
			$mod_author_url = '' ;

			// trim off the label
			$orig = trim(substr( $buffer, strpos( $buffer, ":")+1)) ;

			// get real name + email address
			if (strstr($orig, '<'))
			{
				$left = strpos( $orig, "<")+1 ;
				$len = strpos( $orig, ">") - $left ;
				$mod_author_email = trim(substr( $orig, $left, $len)) ;
				$mod_author_handle = trim(substr( $orig, 0, $left-1)) ;
				$mod_author_url = trim(substr( $orig, $left + $len +1)) ;
			}

			// get handle + web site
			if (strstr($orig, '('))
			{
				$left = strpos( $orig, "(")+1 ;
				$len = strpos( $orig, ")") - $left ;
				$mod_author_name = trim(substr( $orig, $left, $len)) ;
				$mod_author_url = trim(substr( $orig, $left + $len +1)) ;
				if ( $mod_author_handle == '')
				{
					$mod_author_handle = trim(substr( $orig, 0, $left-1)) ;
				}
			}

			// could't get proper format so make it all the handle field
			else if ($mod_author_handle == '')
			{
				$mod_author_handle = $orig ;
			}

			// see if we can debork a borked url; if there is "http:" but also spaces, take the chunck without spaces
			if ((strstr($mod_author_url, ' ')) && (strstr($mod_author_url, 'http:')))
			{
				$url_array = explode(' ', $mod_author_url) ;
				$pos_name = '' ;

				// looking for the element that has no http without any spaces; that will be our URL
				for ($url=0; $url<count($url_array); $url++)
				{
					// found our proper url
					if (strstr($url_array[$url], 'http:'))
					{
						$mod_author_url = $url_array[$url] ;

						// if we didn't get a proper real name, then use whatever was in front of the url
						if ($mod_author_name == '')
						{
							$mod_author_name = $pos_name ;
						}
						break ;
					}

					// didn't find a url so build a potentially new value for real name
					else
					{
						$pos_name .= ($pos_name != '') ? ' ' . $url_array[$url] : $url_array[$url] ;
					}
				}
			}

			// if we don't have an author handle, then see what we can do
			if (($mod_author_handle == '') && ($mod_author_name != ''))
			{
				$mod_author_handle = $mod_author_name ;
			}
			else if (($mod_author_handle == '') && ($mod_author_email != ''))
			{
				$mod_author_handle = $mod_author_email ;
			}


			$getting_desc = 0 ;
		}

		// get the description (up to 3 lines); allow just "description" if we don't have a description yet
		else if ((stristr( $buffer, 'MOD Description:')) || (($mod_description == '') && (stristr( $buffer, 'Description:'))))
		{
			$mod_description = trim(substr( $buffer, strpos( $buffer, ":")+1)) ;
			$getting_desc = 1 ;
		}

		// get the version; allow just "version" if we don't have a version yet
		else if ((stristr( $buffer, 'MOD Version:')) || (($mod_description == '') && (stristr( $buffer, 'Version:'))))
		{
			$mod_version = trim(substr( $buffer, strpos( $buffer, ":")+1)) ;
			$getting_desc = 0 ;
		}

		// if we are getting the description, chop carriage returns and make one long line; only allow 3 lines
		else if ($getting_desc > 0)
		{
			$new_line = ' ' . trim( substr( $buffer, 2)) ;
			$mod_description .= $new_line ;
			$getting_desc = ($getting_desc >= 3) ? 0 : $getting_desc + 1 ;
		}
	}
	fclose( $f_mod_script) ;

	// if we have a title and a handle, then that is good enough to call this a MOD (fixed in 0.0.10; used to be name)
	if (($mod_title != '') && ($mod_author_handle != ''))
	{
		return true ;
	}
	else
	{
		return false ;
	}
}


// strip the body array of a command down to the minimum
function strip_whitespace( $body, $single_line=true)
{
	$new_array = array() ;
	$have_line = false ;

	// rebuild the array and drop the whitespace lines
	for ($i=0; $i<count($body); $i++)
	{
		// if we already have line and are only looking for one, then skip this line
		if (($have_line) && ($single_line))
		{
			// do nothing
		}

		// if the line has something on it, then we'll want to store it
		else if (strlen(trim($body[$i])) > 0)
		{
			$new_array[] = $body[$i] ;
			$have_line = true ;
		}

		// empty line so get this out of our body array
		else
		{
			// do nothing
		}
	}

	// the white space is now gone, return the result
	return $new_array ;
}


// if we encounter an error will modifiying a file then print errors, clean up, and terminate processing if need be
function handle_error( $result, &$file_list, $line, $close_files=false, $find_array=array())
{
	global $lang ;

	// if we are halting the processing then finish writing all files, just to be neat i guess
	if (($close_files) && ($result == FIND_FAIL_CRITICAL))
	{
		// if we failed on an IN-LINE command be sure to write the find_array
		if (count($find_array) > 0)
		{
			write_find_array( $find_array, $file_list) ;
		}

		// don't worry if file repro fails since we are halting anyway
		complete_file_reproduction( $file_list) ;
	}


	// handle warnings and critical errors
	$failed_close = false ;
	if ( $result != OPEN_OK)
	{
		// loop through all files; print errors; and remove file from our file array
		$new_list = array() ;
		for ($err=0; $err<count($file_list); $err++)
		{
			// if there was an error associated with this file, then get down to biz
			if ($file_list[$err]->err_msg != '')
			{
				// if this file through a warning and we aren't halting then close just this file
				if (($close_files) && ($result != FIND_FAIL_CRITICAL))
				{
					$temp_array = array() ;
					$temp_array[] = $file_list[$err] ;

					// if we failed on an IN-LINE command be sure to write the find_array
					if (count($find_array) > 0)
					{
						write_find_array( $find_array, $temp_array) ;
					}

					// clean up this file
					if (!complete_file_reproduction( $temp_array))
					{
						// repro failed meaning close failed meaning we now have a show stopping error!
						$failed_close = true ;
					}
				}

				// show the error(s); do this last in case file repro throw another error
				display_error( $file_list[$err]->err_msg . "<br>\n" . $lang['EM_line_num'] . $line) ;
			}

			// no error so this file can stay in our file list; ones with errors are removed
			else
			{
				$new_list[] = $file_list[$err] ;
			}
		}
		$file_list = $new_list ;

		// if we have a critical error, then we have to halt the processing NOW!
		if ( ($result == OPEN_FAIL_CRITICAL) || ($failed_closed))
		{
			return true ;
		}
	}

	// no show stopping errors
	return false ;
}


// look in the config table to get the EM settings
function get_em_settings( $filename, $path)
{
	global $db ;

	//
	// grab the EM settings
	//
	$sql = "SELECT *
		FROM " . CONFIG_TABLE ;
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, $lang['EM_err_config_info'], '', __LINE__, __FILE__, $sql);
	}

	// loop through all the settings and assign the EM ones as appropriate
	while ( $row = $db->sql_fetchrow($result))
	{
		if ( $row['config_name'] == 'EM_read')
		{
			$read = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_write')
		{
			$write = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_write')
		{
			$write = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_move')
		{
			$move = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_ftp_dir')
		{
			$ftp_dir = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_ftp_user')
		{
			$ftp_user = $row['config_value'] ;
		}
		else if ( $row['config_name'] == 'EM_ftp_pass')
		{
			$ftp_pass = $row['config_value'] ;
		}
	}

	// easiest thing to do is return a mod_io object
	return new mod_io( $filename, $path, $read, $write, $move, $ftp_user, $ftp_pass, $ftp_dir) ;
}








// handle the mode; this is the key to securing EM
$mode = '' ;
$get_password = false ;

// if mode is passed in a GET, be very suspicious!  we don't like it when the user sends us GET vars so make sure they
//   are supposed to be
if (isset($HTTP_GET_VARS['mode']))
{
	// be very selective about what we allow from GET;  the allowed types will also require password auth
	$mode = (isset($HTTP_GET_VARS['mode'])) ? htmlspecialchars($HTTP_GET_VARS['mode']) : '';
	if (($mode == 'install') || ($mode == 'settings') || ($mode == 'history'))
	{
		$get_password = true ;
	}

	// if we are displaying the file to screen, then get the pw to confirm against
	else if (($mode == 'display_file') || ($mode == 'display_backup'))
	{
		$password = (isset($HTTP_GET_VARS['password'])) ? htmlspecialchars($HTTP_GET_VARS['password']) : '' ;
		$install_file = ( !empty($HTTP_GET_VARS['install_file']) ) ? htmlspecialchars(trim($HTTP_GET_VARS['install_file'])) : '';
		$install_path = ( !empty($HTTP_GET_VARS['install_path']) ) ? htmlspecialchars(trim($HTTP_GET_VARS['install_path'])) : '';

		// important! we are writing the file output to screen so the PRE tag will format it nicely for us
		echo "<PRE>\n" ;
	}

	// unexpected mode, someone is trying to circumvent the password!  we'll fix 'em ;-)
	else
	{
		// they'll now end up at the password screen instead of whatever they were trying
		$mode = 'install' ;
		$get_password = true ;
	}
}

// get post variables; we trust post variables ;-)
else
{
	$mode = ( !empty($HTTP_POST_VARS['mode']) ) ? htmlspecialchars(trim($HTTP_POST_VARS['mode'])) : '';

	$password = ( !empty($HTTP_POST_VARS['password']) ) ? htmlspecialchars($HTTP_POST_VARS['password']) : '' ; 
	$install_file = ( !empty($HTTP_POST_VARS['install_file']) ) ? trim($HTTP_POST_VARS['install_file']) : '';
	$install_path = ( !empty($HTTP_POST_VARS['install_path']) ) ? trim($HTTP_POST_VARS['install_path']) : '';
	$SQL_lines = ( isset($HTTP_POST_VARS['SQL_lines']) ) ? intval($HTTP_POST_VARS['SQL_lines']) : 0;
}


// make sure mode is valid; if not then set to default mode and get pw
if (($mode != 'history') && ($mode != 'settings') && ($mode != 'install') &&
	($mode != 'display_file') && ($mode != 'download_file') &&
	($mode != 'display_backup') && ($mode != 'download_backup') &&
	($mode != 'SQL_view') && ($mode != 'SQL_execute') &&
	($mode != 'update') && ($mode != 'process') && ($mode != 'post_process'))
{
	$mode = 'install' ;
	$get_password = true ;
}



//
// if they are trying to get to the first page, check the pw; after that assume they are validated
//
$pass_message = '' ;
if ((($mode == 'install') || ($mode == 'settings') || ($mode == 'history') ||
	($mode == 'display_file') || ($mode == 'display_backup')) && (!$get_password))
{
	// compare passwords and send them back to the password screen if they fail
	if ( $password != get_em_pw())
	{
		$get_password = true ;
		$pass_message = '<b>' . $lang['EM_err_pw_fail'] . '</b><br>' ;
	}
}



//
// if they are downloading or displaying a file or backup then we need to get setup
//

// downloading a file or a backup from the completed processing screen
if (($mode == 'download_file') || ($mode == 'download_backup'))
{
	// they clicked a form button; we need to figure out which one so we know what file they are looking for
	$num_files = ( isset($HTTP_POST_VARS['mod_count'])) ? intval($HTTP_POST_VARS['mod_count']) : 0 ;

	// loop through all the submit buttons to see which one was pressed
///////////////////////////////////
///////////////////////////////////
/////////////////////////////////// possible error.... should start at 0? was a 1 before
///////////////////////////////////
///////////////////////////////////
	for ( $i=0; $i<=$num_files; $i++)
	{
		$var_name = 'submitfile' . $i ;

		// if this is the button that was pressed then we are all set!  get the file name
		if ( isset($HTTP_POST_VARS[$var_name]))
		{
			$file = ( isset($HTTP_POST_VARS['file'.$i])) ? htmlspecialchars($HTTP_POST_VARS['file'.$i]) : '' ;
			break ;
		}
	}

	// we'll need to look at the path and filename so split things up
	$split = explode('/', $file) ;

	// if a file, then make sure we have the filename correct
	if ($mode == 'download_file')
	{
		// by default the filename sent will match the one in the MOD script
		$process_file = (substr($file, 0, 9) == '../../../') ? substr($file, 9) : '' ;
		$orig_file = $process_file ;

		// handle the special cases of a template file to download; only subSilver will appear in the MOD script
		if (($split[3] == 'templates') && ($split[4] != 'subSilver'))
		{
			$process_file = str_replace( $split[4], 'subSilver', $process_file) ;
		}

		// handle the special cases of a language file to download; only english will appear in the MOD script
		else if (($split[3] == 'language') && ($split[4] != 'lang_english'))
		{
			$process_file = str_replace( $split[4], 'lang_english', $process_file) ;
		}
	}

	// if a backup then we can assume the filename is valid
	else
	{
		$orig_file = $file ;
		$process_file = (substr($file, 0, 9) == '../../../') ? substr($file, 9) : '' ;
		$process_file = $phpbb_root_path . $process_file ;
	}


	// if there is no file to process then we are in trouble!
	if ( $process_file == '')
	{
		message_die(GENERAL_ERROR, $lang['EM_err_no_process_file'], '', __LINE__, __FILE__, $sql);
	}


	// set up the redirects so we will download a file, the contents of which we will echo out
	header('Content-Type: text/x-delimtext; name="' . $split[count($split)-1] . '"');
	header('Content-disposition: attachment; filename="' . $split[count($split)-1] . '"');
}

// writing to screen, get set up
else if (($mode == 'display_file') || ($mode == 'display_backup'))
{
	// get the file name
	$file = (isset($HTTP_GET_VARS['file'])) ? htmlspecialchars($HTTP_GET_VARS['file']) : '' ;
	$split = explode('/', $file) ;

	// if a file, then make sure we have the filename correct
	if ($mode == 'display_file')
	{
		// by default the filename sent will match the one in the MOD script
		$process_file = (substr($file, 0, 9) == '../../../') ? substr($file, 9) : '' ;
		$orig_file = $process_file ;

		// handle the special cases of a template file to display; only subSilver will appear in the MOD script
		if (($split[3] == 'templates') && ($split[4] != 'subSilver'))
		{
			$process_file = str_replace( $split[4], 'subSilver', $process_file) ;
		}

		// handle the special cases of a language file to display; only english will appear in the MOD script
		else if (($split[3] == 'language') && ($split[4] != 'lang_english'))
		{
			$process_file = str_replace( $split[4], 'lang_english', $process_file) ;
		}
	}

	// if a backup then we can assume the filename is valid
	else
	{
		$orig_file = $file ;
		$process_file = (substr($file, 0, 9) == '../../../') ? substr($file, 9) : '' ;
		$process_file = $phpbb_root_path . $process_file ;
	}

	// if there is no file to process then we are in trouble!
	if ( $process_file == '')
	{
		message_die(GENERAL_ERROR, $lang['EM_err_no_process_file'], '', __LINE__, __FILE__, $sql);
	}
}



//
// Show the page header (if we aren't doing the display modes)
//
if (($mode != 'display_file') && ($mode != 'download_file') && ($mode != 'display_backup') && ($mode != 'download_backup'))
{
	$template->set_filenames(array(
		'mod_header' => 'admin/mod_header.tpl')
	);

	$template->assign_vars(array(
		'L_TITLE' => $lang['EM_Title'],
		'L_EM_VERSION' => EASYMOD_VER,
		'NUTTZY' => NUTTZY_LINK)
	);

	$template->pparse('mod_header');
}





//
// password authentication page
//
if ($get_password)
{
	// load the password page template
	$template->set_filenames(array(
		"body" => "admin/mod_login.tpl")
	);


	$template->assign_vars(array(
		'S_ACTION' => append_sid('admin_easymod.' . $phpEx),
		'L_ACCESS_WARNING' => $lang['EM_access_warning'],
		'L_MESSAGE' => $pass_message,
		'L_PASSWORD_TITLE' => $lang['EM_password_title'],
		'L_PASSWORD' => $lang['EM_password'],
		'L_ACCESS_EM' => $lang['EM_access_EM'],

		'MODE' => $mode)
	);
}


//
// display the settings page
//
else if ($mode == 'settings')
{
	// load the settings page template
	$template->set_filenames(array(
		"body" => "admin/mod_settings.tpl")
	);

	$command_file = get_em_settings( '6E7574747A79.72756C657321', '') ;

	$select_read =  '<option value="server"' . (($command_file->read_method == 'server') ? ' selected=selected' : ''). '>' . $lang['EM_read_server'] . '</option>' ;

	$select_write =  '<option value="server"' . (($command_file->write_method == 'server') ? ' selected=selected' : ''). '>' . $lang['EM_write_server'] . '</option>' . "\n" ;
	$select_write .= '<option value="ftpb"' . (($command_file->write_method == 'ftpb') ? ' selected=selected' : ''). '>' . $lang['EM_write_ftp'] . '</option>' . "\n" ;
	$select_write .= '<option value="local"' . (($command_file->write_method == 'local') ? ' selected=selected' : ''). '>' . $lang['EM_write_download'] . '</option>' . "\n" ;
	$select_write .= '<option value="screen">' . (($command_file->write_method == 'screen') ? ' selected=selected' : ''). '' . $lang['EM_write_screen'] . '</option>' . "\n" ;

	$select_move =  '<option value="copy"' . (($command_file->move_method == 'copy') ? ' selected=selected' : ''). '>' . $lang['EM_move_copy'] . '</option>' . "\n" ;
	$select_move .= '<option value="ftpa"' . (($command_file->move_method == 'ftpa') ? ' selected=selected' : ''). '>' . $lang['EM_move_ftp'] . '</option>' . "\n" ;
	$select_move .= '<option value="exec"' . (($command_file->move_method == 'exec') ? ' selected=selected' : ''). '>' . $lang['EM_move_exec'] . '</option>' . "\n" ;
	$select_move .= '<option value="ftpm"' . (($command_file->move_method == 'ftpm') ? ' selected=selected' : ''). '>' . $lang['EM_move_manual'] . '</option>' . "\n" ;

	$template->assign_vars(array(
		'S_ACTION' => append_sid('admin_easymod.' . $phpEx),
		'L_SETTINGS' => $lang['EM_settings'],
		'L_DESC' => $lang['EM_settings_desc'],

		'L_PW_TITLE' => $lang['EM_password_title'],
//		'L_PW_DESC' => $lang['EM_password_desc'],
		'L_PW_DESC' => $lang['EM_settings_pw'],
		'L_PW_SET' => $lang['EM_password_set'],
		'L_PW_CONFIRM' => $lang['EM_password_confirm'],

		'L_FILE_TITLE' => $lang['EM_file_title'],
		'L_FILE_DESC' => $lang['EM_file_desc'],
		'L_FILE_READ' => $lang['EM_file_reading'],
		'L_FILE_WRITE' => $lang['EM_file_writing'],
		'L_FILE_MOVE' => $lang['EM_file_moving'],

		'L_FTP_TITLE' => $lang['EM_ftp_title'],
		'L_FTP_DESC' => $lang['EM_ftp_desc'],
		'L_FTP_DIR' => $lang['EM_ftp_dir'],
		'L_FTP_USER' => $lang['EM_ftp_user'],
		'L_FTP_PASS' => $lang['EM_ftp_pass'],
		'L_SUBMIT' => $lang['EM_settings_update'],

		'EM_PASS' => get_em_pw(),

		'SELECT_READ' => $select_read,
		'SELECT_WRITE' => $select_write,
		'SELECT_MOVE' => $select_move,

		'FTP_USER' => $command_file->ftp_user,
		'FTP_PASS' => $command_file->ftp_pass,
		'FTP_PATH' => $command_file->ftp_path,

		'MODE' => 'update')
	);
}


//
// update the EM settings; they already filled out the settings page and hit submit
//
else if ($mode == 'update')
{
	// password settings
	$em_pass = (isset($HTTP_POST_VARS['em_pass'])) ? htmlspecialchars( $HTTP_POST_VARS['em_pass']) : '' ;
	$em_pass_confirm = (isset($HTTP_POST_VARS['em_pass_confirm'])) ? htmlspecialchars( $HTTP_POST_VARS['em_pass_confirm']) : '' ;

	// file access settings
	$read = (isset($HTTP_POST_VARS['sel_read'])) ? htmlspecialchars( $HTTP_POST_VARS['sel_read']) : '' ;
	$write = (isset($HTTP_POST_VARS['sel_write'])) ? htmlspecialchars( $HTTP_POST_VARS['sel_write']) : '' ;
	$move = (isset($HTTP_POST_VARS['sel_move'])) ? htmlspecialchars( $HTTP_POST_VARS['sel_move']) : '' ;

	// ftp settings
	$ftp_dir = (isset($HTTP_POST_VARS['ftp_dir'])) ? htmlspecialchars( $HTTP_POST_VARS['ftp_dir']) : '' ;
	$ftp_user = (isset($HTTP_POST_VARS['ftp_user'])) ? htmlspecialchars( $HTTP_POST_VARS['ftp_user']) : '' ;
	$ftp_pass = (isset($HTTP_POST_VARS['ftp_pass'])) ? htmlspecialchars( $HTTP_POST_VARS['ftp_pass']) : '' ;


	// confirm passwords match and update pw if needed
	if ( $em_pass == $em_pass_confirm)
	{
		// update the password
		em_db_update( 'EM_password', $em_pass) ;
		$pass_msg = ($em_pass == '') ? $lang['EM_pass_disabled'] : $lang['EM_pass_updated'] ;
	}
	// the confirm is empty so they are not trying to update the pw, so don't
	else if ( $em_pass_confirm == '')
	{
		$pass_msg = $lang['EM_pass_not_updated'] ;
	}
	// passwords do not match so throw an error
	else if ( $em_pass != $em_pass_confirm)
	{
		message_die( GENERAL_ERROR, $lang['EM_err_set_pw']) ;
	}

	// update the settings
	em_db_update( 'EM_read', $read) ;
	em_db_update( 'EM_write', $write) ;
	em_db_update( 'EM_move', $move) ;
	em_db_update( 'EM_ftp_dir', $ftp_dir) ;
	em_db_update( 'EM_ftp_user', $ftp_user) ;
	em_db_update( 'EM_ftp_pass', $ftp_pass) ;

	message_die( GENERAL_MESSAGE, '<br>' . $lang['EM_settings_success'] . " $pass_msg<br><br>") ;
}


//
// history
//
else if ($mode == 'history')
{
	// load the history page template
	$template->set_filenames(array(
		"body" => "admin/mod_history.tpl")
	);


	$template->assign_vars(array(
		'L_INSTALLED' => $lang['EM_Installed'],
		'L_INSTALLED_DESC' => $lang['EM_installed_desc'],
		'L_INSTALL_DATE' => $lang['EM_install_date'],
		'L_MOD_NAME' => $lang['EM_Mod'],
		'L_FILE' => $lang['EM_File'],
		'L_VERSION' => $lang['EM_Version'],
		'L_AUTHOR' => $lang['EM_Author'],
		'L_DESCRIPTION' => $lang['EM_Description'],
		'L_DATE' => $lang['EM_Process_Date'],
		'L_PHPBB_VER' => $lang['EM_phpBB_Version'],
		'L_THEMES' => $lang['EM_Themes'],
		'L_LANGUAGES' => $lang['EM_Languages'],
		'L_NONE_INSTALLED' => $lang['EM_none_installed'])
	);



	$sql = "SELECT *
		FROM " . EASYMOD_TABLE . " 
		ORDER BY mod_id DESC" ;
	if( !$result = $db->sql_query($sql) )
	{
	   message_die(GENERAL_ERROR, $lang['EM_err_em_info'], '', __LINE__, __FILE__, $sql);
	}

	$i = 0 ;
	while( $row = $db->sql_fetchrow($result) )
	{
		$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
		$template->assign_block_vars('install', array(
			'ROW_CLASS' => $row_class,
			'INSTALL_DATE' => create_date($board_config['default_dateformat'], $row['mod_process_date'], $board_config['board_timezone']),
			'TITLE' => $row['mod_title'],
			'VERSION' => $row['mod_version'],
			'AUTHOR' => $row['mod_author_handle'],
			'URL' => $row['mod_author_url'],
			'PHPBB_VER' => $row['mod_phpBB_version'],
/////////////////
///////////////// blah, what about schema name?
/////////////////
			'THEMES' => $row['mod_processed_themes'],
			'LANGS' => $row['mod_processed_langs'])
		);
		$i++ ;
	}
	if ( $i == 0 )
	{
		$template->assign_block_vars('no_install', array()) ;
	}
}


//
// display install MOD page
//
else if ( $mode == 'install')
{
	// load the install page template
	$template->set_filenames(array(
		'body' => 'admin/mod_install.tpl')
	);

	$template->assign_vars(array(
		'L_EM_INTRO' => $lang['EM_Intro'],

		'L_UNPROCESSED' => $lang['EM_Unprocessed'],
		'L_UNPROCESSED_DESC' => $lang['EM_unprocessed_mods'],

		'L_MOD' => $lang['EM_Mod'],
		'L_AUTHOR' => $lang['EM_Author'],
		'L_SUPPORT' => $lang['EM_support_thread'],
		'L_DESCRIPTION' => $lang['EM_Description'],
		'L_EMC' => $lang['EM_EMC'],
		'L_PROCESS' => $lang['EM_process'],
		'L_ALL_PROCESSED' => $lang['EM_All_Processed'])
	);



	$phpbb_version = get_phpbb_version() ;
	if ($phpbb_version == '')
	{
		message_die( GENERAL_ERROR, $lang['EM_err_phpbb_ver']);
	}

	// parse the "mods" directory, looking for newly extracted mods, or mod updates
	$top_handle = opendir('./mods');
	$i = 0 ;
	while (false !== ($dir = readdir($top_handle)))
	{
		// only want the subdirectories (but not . and ..)
		if ( (is_dir('./mods/' . $dir) ) && ($dir != '.') && ($dir != '..'))
		{
			$path = './mods/' . $dir ;
			$dir_handle = opendir( $path);
			// loop through the subdirs, looking for mod files
			while (false !== ($file = readdir($dir_handle)))
			{
				$file_path =  $path . '/' . $file ;
				// make sure it is not a dir, and that it ends with .txt or .mod
				if ( !is_dir( $file_path) && ( (eregi(".txt$", $file_path)) || (eregi(".mod$", $file_path))))
				{
					$mod_title = '' ;
					$mod_author_handle = '' ;
					$mod_author_email = '' ;
					$mod_author_name = '' ;
					$mod_author_url = '' ;
					$mod_description = '' ;
					$mod_version = '' ;
					$compliant = false ;

					$is_mod = get_mod_properties( $file_path, $mod_title, $mod_author_handle, $mod_author_email, $mod_author_name, $mod_author_url, $mod_description, $mod_version, $compliant) ;

					// if it is a MOD and has not been processed yet then add it to the list
					if (($is_mod) && ( is_unprocessed( $db, $mod_title, $mod_version, $phpbb_version)))
					{
						$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
						$template->assign_block_vars('unprocessed', array(
							'ROW_CLASS' => $row_class,
							'MOD_TITLE' => $mod_title,
							'MOD_AUTHOR' => $mod_author_handle,
							'MOD_URL' => $mod_author_url,
							'MOD_VERSION' => $mod_version,
							'MOD_DESC' => $mod_description,
							'MOD_EMC' => ($compliant) ? '<img src="../templates/subSilver/images/emc.gif">' : $lang['No'],
							'MOD_PATH' => $path . '/',
							'MOD_FILE' => $file,
							'MOD_FILE_URL' => $path . '/' . $file)
						);
						$i++ ;
					}
				}
			}
		}
	}

	// didn't find any MODs we can process
	if ( $i == 0 )
	{
		$template->assign_block_vars('no_unprocessed', array()) ;
	}
}


//
// download or display a backup of the core phpBB file
//
else if (($mode == 'display_backup') || ($mode == 'download_backup'))
{
	// open the core file
	if (!$read_file = fopen ( $process_file, 'r'))
	{
		// gotta echo out the message since message_die is not an option
		echo sprintf( $lang['EM_err_backup_open'], $process_file) . "\n" ;
		exit ;
	}

	// write out the lines
	while (!feof($read_file))
	{
		$newline = fgets( $read_file, 4096);
		if ($mode == 'download_backup')
		{
			echo $newline ;
		}
		else
		{
			echo htmlspecialchars($newline) ;
		}
	}
	fclose( $read_file) ;

	// finish the PRE formatting tag
	if ($mode == 'display_backup')
	{
		echo "</PRE>\n" ;
	}

	// done! done! done!
	exit ;
}


//
// process the MOD script and modify the files
//
else if (($mode == 'process' ) || ($mode == 'display_file') || ($mode == 'download_file'))
{
	$current_command = '' ;
	$commands = array() ;
	$body = array() ;

	$in_header = false ;		// in the header of the command (the ## section)
	$line_num = 0 ;			// line number in the MOD script we are parsing

	$found_file = false ;		// only for the special cases


	//
	// open the mod script and load an array with commands to execute
	//

	$f_mod_script = fopen ( $install_path . '/' . $install_file, 'r');
	while (!feof ($f_mod_script))
	{
		$buffer = fgets($f_mod_script, 4096);
		$line_num++ ;

		// if the line starts with #, this is either a comment or an action command; will also tell us when
		//    we've hit the last search line of the target content for this command (meaning we've reached the
		//    next command)

		// after obtaining the command, skip any comments until we reach the command body
		if (($buffer[0] == '#') && ($in_header))
		{
			// do nothing until we are out of the command header!!
		}

		// not in a header so this comment is either a random comment or start of a command header
		else if ($buffer[0] == '#')
		{
			// done with last command now that we've hit a comment (regardless if a new command or just a comment)
			if ( $current_command != '')
			{
				$current_command = '' ;
			}

			// if we find [ and ] on this line, then we can be reasonably sure it is an action command
			if ((strstr($buffer, '[')) && (strstr($buffer, ']')))
			{

				//
				// we know it's an action, take appropriate steps for the action; see if the current command
				//   is found on our list;  NOTE: since we are using strstr, it is important to keep the
				//   IN-LINE commands listed before thier similarly named cousins
				//

				if (strstr($buffer, 'OPEN'))
				{
					$current_command = 'OPEN' ;
				}
				else if (strstr($buffer, 'IN-LINE FIND'))
				{
					$current_command = 'IN-LINE FIND' ;
				}
				else if (strstr($buffer, 'FIND'))
				{
					$current_command = 'FIND' ;
				}
				else if (strstr($buffer, 'IN-LINE AFTER, ADD'))
				{
					$current_command = 'IN-LINE AFTERADD' ;
				}
				else if (strstr($buffer, 'AFTER, ADD'))
				{
					$current_command = 'AFTERADD' ;
				}
				else if (strstr($buffer, 'IN-LINE BEFORE, ADD'))
				{
					$current_command = 'IN-LINE BEFOREADD' ;
				}
				else if (strstr($buffer, 'BEFORE, ADD'))
				{
					$current_command = 'BEFOREADD' ;
				}
				else if (strstr($buffer, 'IN-LINE REPLACE'))
				{
					$current_command = 'IN-LINE REPLACE' ;
				}
				else if (strstr($buffer, 'REPLACE'))
				{
					$current_command = 'REPLACE' ;
				}
				else if (strstr($buffer, 'COPY'))
				{
					$current_command = 'COPY' ;
				}
				else if (strstr($buffer, 'SAVE/CLOSE'))
				{
					$current_command = 'CLOSE' ;
				}

				// not a known command, let see if it is unrecognized command or just a comment
				else
				{
					$left_bracket = strpos( $buffer, '[') ;
					$right_bracket = strpos( $buffer, ']') ;
					$left_of_bracket = substr($buffer, 0, $left_bracket) ;
					$right_of_bracket = substr($buffer, $right_bracket) ;

					// if there is no "--" both before and after the brackets, this must be a comment
					if (( $left_bracket < $right_bracket) && (strstr( $left_of_bracket, '--')) && (strstr( $right_of_bracket, '--')))
					{
						$current_command = trim( substr($buffer, $left_bracket+1, (($right_bracket-1)-($left_bracket+1)))) ;
					}
				}

				// handle special cases when we display or download the file; we are looking for the commands
				//   for one file ONLY, so skip commands until we find the corresponding OPEN
				if (($mode == 'display_file') || ($mode == 'download_file'))
				{
					if ( $current_command != '')
					{
						// not found found file yet so this is a possible canidate
						if ((!$found_file) && ($current_command == 'OPEN'))
						{
							$in_header = true ;
						}

						// ignore all other commands until we have our file
						else if ((!$found_file) && ($current_command != 'OPEN'))
						{
							$current_command = '' ;
						}

						// after found, once we hit another OPEN or the CLOSE, then we are done
						else if ((($found_file) && ($current_command == 'OPEN') && (!$in_header)) || ($current_command == 'CLOSE'))
						{
							$current_command = '' ;
							break ;
						}

						// allow processing of this command
						else
						{
							$in_header = true ;
							$commands[] = array( 'command' => $current_command, 'line' => $line_num) ;
							$body[] = array() ;
						}
					}
				}

				// normal command processing
				else if ( $current_command != '')
				{
					$in_header = true ;
					$commands[] = array( 'command' => $current_command, 'line' => $line_num) ;
					$body[] = array() ;
				}
			}
		}

		// not a comment or command so this is the body of the command
		else if ( $current_command != '')
		{
			// handle special cases; make sure this is for the specific file we are looking for
			if (($mode == 'display_file') || ($mode == 'download_file'))
			{
				// not found found file yet so see if this is it
				if ((!$found_file) && ($current_command == 'OPEN'))
				{
					// found the file, excellent!
					if (trim($buffer) == $process_file)
					{
						$commands[] = array( 'command' => $current_command, 'line' => $line_num) ;
						$body[] = array() ;
						$body[ count($body)-1 ][] = $buffer ;
						$found_file = true ;
					}
				}

				// haven't found the file yet, so don't process this command (should never get in here)
				else if (!$found_file)
				{
					$current_command = '' ;
				}

				// this command relates to the file we are looking for, so go ahead
				else
				{
					$body[ count($body)-1 ][] = $buffer ;
				}
				$in_header = false ;
			}

			// store this as this body of our command
			else
			{
				$in_header = false ;
				$body[ count($body)-1 ][] = $buffer ;
			}
		}
	}
	fclose($f_mod_script);


	// load the process mod template unless we are in special case mode
	if (($mode != 'display_file') && ($mode != 'download_file'))
	{
		// set the template
		$template->set_filenames(array(
			'body' => 'admin/mod_process.tpl')
		);
	}



	$file_list = array() ;

	$search_array = array() ;		// what we are searching for
	$search_fragment = '' ;			// the IN-LINE FIND fragment we are looking for
	$find_array = array() ;			// contains lines from a FIND which potentially contain our search target

	$files_edited = 0 ;
	$num_processed = 0 ;
	$num_unprocessed = 0 ;

	$failed = true ;
	$exec_close = false ;			// did we hit the close command?

	// grab the EM settings and open the command file
	$command_file = get_em_settings( 'post_process.sh', '') ;

	// this is really more about moving the other files than is about the command file; establish the FTP connection
	//  for moving files if necessary; the $emftp var will be used globally
	$emftp = new ftp() ;
	if (!$command_file->modio_prep('move'))
	{
		message_die( GENERAL_ERROR, '<b>' . $lang['EM_err_critical_error'] . ':</b> ' . $command_file->err_msg . '<br>') ;
	}


////////////////////
//////////////////// emcopy - to be fixed and removed in 0.0.11
////////////////////
	$display_copy_warning = false ;
	$display_sql_warning = false ;


	//
	// now that we have the commands all set let's start to process them
	//

	// loop through the command and knock 'em out ;-)
	for ($i=0; $i<count($commands); $i++)
	{
		// a catch all at the end will switch to false if we fail to process
		$processed = true ;

		// protect against malformed script that didn't perform a FIND first; this acts as a gatekeeper to ensure
		//   that the find_array is being managed correctly; OPEN and FIND write out any remenants of find_array; AFTER
		//   and REPLACE destroy the array while BEFORE and the IN-LINE's preserve it to be used again
		if ((count($find_array) == 0 ) && (($commands[$i]['command'] == 'BEFOREADD') || (strstr($commands[$i]['command'], 'IN-LINE'))))
		{
			display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $commands[$i]['command'] . $lang['EM_err_no_find'] . "<br>\n" . $lang['EM_line_num'] . $commands[$i]['line']) ;
			break ;
		}


		//
		// open phpBB core file
		//
		if ($commands[$i]['command'] == 'OPEN')
		{
			// if we were doing an BEFORE or an IN-LINE command we need to write out the find_array
			write_find_array( $find_array, $file_list) ;
			$find_array = array() ;

			// if we already had a file open, close it now
			if (!complete_file_reproduction( $file_list))
			{
				// close failed; throw errors and halt
				for ($errs=0; $errs<count($file_list); $errs++)
				{
					display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $file_list[$errs]->err_msg . "<br>\n" . $lang['EM_line_num'] . $commands[$i]['line']) ;
				}

				// halt processing
				break ;
			}

			// strip the body of whitespace down and down to a single line
			$body[$i] = strip_whitespace( $body[$i], true) ;

			// if there is not exactly 1 line then throw a critical error
			if ( count($body[$i]) != 1)
			{
				display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $lang['EM_err_comm_open'] . "<br>\n" . $lang['EM_line_num'] . $commands[$i]['line']) ;
				break ;
			}

			// strip off the path and get the file name
			$splitarray = explode('/', trim($body[$i][0])) ;
			$filename = $splitarray[count($splitarray)-1] ;

			// now get the path
			$path = '' ;
			for ($k=0; $k<count($splitarray)-1; $k++)
			{
				$path .= $splitarray[$k] . '/' ;
			}


			// open the file(s)
			$file_list = array() ;
			$result = open_files( $filename, $path, $file_list, $command_file) ;

			// display any errors; if it was critical, terminate processing; if warn, remove file from list
			if ( handle_error( $result, $file_list, $commands[$i]['line']))
			{
				break ;
			}

			// increment our count
			$files_edited += count($file_list) ;
		}

		//
		// find a string or sequential group of strings in the file
		//
		else if ($commands[$i]['command'] == 'FIND')
		{
			// if we were doing an BEFORE or an IN-LINE command we need to write out the find_array
			write_find_array( $find_array, $file_list) ;

			// reinit key vars
			$find_array = array() ;
			$search_fragment = '' ;

			// strip the body of whitespace lines; allow multiple lines
			$body[$i] = strip_whitespace( $body[$i], false) ;


			// make sure we have something to search for; throw a warning if not
			$search_array = $body[$i] ;
			if ( count($search_array) == 0 )
			{
				display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $lang['EM_err_comm_find'] . "<br>\n" . $lang['EM_line_num'] . $commands[$i]['line']) ;
				break ;
			}

			// do the find and see what happens
			$result = perform_find( $file_list, $find_array, $search_array) ;

			// display any errors; if it was critical, terminate processing; if warn, remove file from list
			//   the command will also close the files that we were writing
			if ( handle_error( $result, $file_list, $commands[$i]['line'], true))
			{
				break ;
			}
		}

		//
		// write out the find array then write the body
		//
		else if ($commands[$i]['command'] == 'AFTERADD')
		{
			$insert_string = '' ;
			for ($j=0; $j<count($body[$i]); $j++)
			{
///////////////
//				$insert_string .= '>>' . $body[$i][$j] ;
				$insert_string .= $body[$i][$j] ;
			}

			write_find_array( $find_array, $file_list) ;
			write_files( $file_list, $insert_string) ;

			// we've written the find array already so we can no longer operate on it
			$find_array = array() ;
		}

		//
		// write the body then write out the find array
		//
		else if ($commands[$i]['command'] == 'BEFOREADD')
		{
			$insert_string = '' ;
			for ($j=0; $j<count($body[$i]); $j++)
			{
///////////////
//				$insert_string .= '>>' . $body[$i][$j] ;
				$insert_string .= $body[$i][$j] ;
			}

			write_files( $file_list, $insert_string) ;

			// NOTE: since we have not modified the find_array in any way we can still perform operations on it
			//   so do not write it out
		}

		//
		// write the body then throw out the find array!
		//
		else if ($commands[$i]['command'] == 'REPLACE')
		{
			// is this a totally easy command or what!?!?!  That's why it is soooo dangerous to use.  Another
			//   mod will never be able to work again if it needs to FIND what we just replaced	

			// write the replace lines and notice how we never will write the find_array lines
			for ($j=0; $j<count($body[$i]); $j++)
			{
///////////////
//				write_files( $file_list, '>>' . $body[$i][$j]) ;
				write_files( $file_list, $body[$i][$j]) ;
			}

			// we've obliterated the find array already so we can no longer operate on it
			$find_array = array() ;
		}

		//
		// IN-LINE commands; perform precision operations on a single line
		//
		else if (strstr($commands[$i]['command'], 'IN-LINE'))
		{
/////////////////////
///////////////////// wasn't there something about not trimming the left side?
/////////////////////
			// strip the body of whitespace down and down to a single line
			$body[$i] = strip_whitespace( $body[$i], true) ;

			// if there is not exactly 1 line then throw a critical error
			if ( count($body[$i]) != 1)
			{
				display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $commands[$i]['command'] . $lang['EM_err_inline_body'] . "<br>\n" . $lang['EM_line_num'] . $commands[$i]['line']) ;
				break ;
			}

			// if there is no search fragment for an AFTER, BEFORE, or REPLACE then throw a crit error
			if (($search_fragment == '') && ($commands[$i]['command'] != 'IN-LINE FIND'))
			{
				display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $commands[$i]['command'] . $lang['EM_err_no_ifind'] . "<br>\n" . $lang['EM_line_num'] .$commands[$i]['line']);
				break ;
			}


			// make the actual alteration for after, before, and replace
			if ($commands[$i]['command'] == 'IN-LINE AFTERADD')
			{
				$result = perform_inline_add( $find_array, $file_list, $search_fragment, $body[$i][0], 'after');
			}
			else if ($commands[$i]['command'] == 'IN-LINE BEFOREADD')
			{
				$result = perform_inline_add( $find_array, $file_list, $search_fragment, $body[$i][0], 'before') ;
			}
			else if ($commands[$i]['command'] == 'IN-LINE REPLACE')
			{
				$result = perform_inline_add( $find_array, $file_list, $search_fragment, $body[$i][0], 'replace') ;
			}


			// strip off white space and get our search fragment (we already know it is not an empty string)
			if ($commands[$i]['command'] == 'IN-LINE FIND')
			{
				$search_fragment = trim($body[$i][0]) ;
			}

			// display any errors; if it was critical, terminate processing; if warn, remove file from list
			//   the command will also close the files that we were writing
			else if ( handle_error( $result, $file_list, $commands[$i]['line'], true, $find_array))
			{
				break ;
			}
		}

		//
		// setup the copying of files from the mod directory to core directories
		//
		else if ($commands[$i]['command'] == 'COPY')
		{
			// strip the body of whitespace lines; allow multiple lines
			$body[$i] = strip_whitespace( $body[$i], false) ;

			// loop through the body, setting up the copy
			$bad_copy = false ;
			for ($j=0; $j<count($body[$i]); $j++)
			{
				// strip out potentially unlimited whitespace within the line
				$tmp_str = str_replace( '	', ' ', trim($body[$i][$j])) ;
				$tmp_array = explode(' ', $tmp_str) ;
				$split_array = array() ;

				// loop through elements and keep only elements with text
				for ($e=0; $e<count($tmp_array); $e++)
				{
					// got text? we want you!
					if ($tmp_array[$e] != '')
					{
						$split_array[] = $tmp_array[$e] ;
					}
				}


				// discard "copy" if it exists, and discard "to"
				if ( count($split_array) < 2)
				{
					display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . $lang['EM_err_copy_format'] . '<br>' . trim($body[$i][$j]) . "<br>\n" . $lang['EM_line_num'] .$commands[$i]['line']);
					$bad_copy = true ;
					break ;
				}
				else if ( strtolower($split_array[0]) == 'copy')
				{
					$target = $split_array[1] ;
					$destination = $split_array[3] ;
				}
				else
				{
					$target = $split_array[0] ;
					$destination = $split_array[2] ;
				}

				// get path and filename
				$split_path = explode('/', $destination) ;
				$dest_file = $split_path[count($split_path)-1] ;
				$dest_path = substr( $destination, 0, strlen($destination)-strlen($dest_file)) ;
				$split_targpath = explode('/', $target) ;
				$targ_file = $split_targpath[count($split_targpath)-1] ;
				$targ_path = substr( $target, 0, strlen($target)-strlen($targ_file)) ;


/////////////////////
///////////////////// emcopy - might need this later
/////////////////////
/*
				// if the filename to copy is *.* or nothing, then make sure at least the directory exists
				if ((($targ_file == '*.*') || ($targ_file == '')) && (file_exists($install_path . $targ_path)))
				{
*/
/////////////////////
///////////////////// emcopy - in 0.0.10 we are not dealing with multiple gets
/////////////////////
				// if the filename to copy is *.* or nothing, then make sure at least the directory exists
				if (($targ_file == '*.*') || ($targ_file == ''))
				{
//$command_file->modio_mkdirs_copy( $dest_path) ;
					$display_copy_warning = true ;
					continue ;
				}

/////////////////////
///////////////////// emcopy - fine for 0.0.10a but may need to change later
/////////////////////
				// if a destination file name was not supplied, then use the target's filename
				if ($dest_file == '')
				{
					$dest_file = $targ_file ;
				}

				// make sure the target file actually exists
				else if (!file_exists($install_path . $target))
				{
					display_error( '<b>' . $lang['EM_err_critical_error'] . "</b><br><br>\n" . sprintf($lang['EM_err_comm_copy'], $install_path, $target) . "<br>\n" . $lang['EM_line_num'] .$

Gebruikersavatar
Luuk
Berichten: 7311
Lid geworden op: 22 okt 2003, 10:07
Locatie: Delft

Bericht door Luuk » 17 apr 2004, 17:33

ten eerste, ik snap je vraag niet
ten tweede, post geen hele bestanden aub!!
Afbeelding

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 17 apr 2004, 18:14

hoe moet je easy mod installeren ik snap er niks van?

Gebruikersavatar
Luuk
Berichten: 7311
Lid geworden op: 22 okt 2003, 10:07
Locatie: Delft

Bericht door Luuk » 17 apr 2004, 19:21

lees het install.txt bestand, dat kan ook in de map 'DOCS' staan als die bestaat
Afbeelding

Gebruikersavatar
V!ncent
Berichten: 1138
Lid geworden op: 03 apr 2003, 20:08
Locatie: 127.0.0.1
Contacteer:

Bericht door V!ncent » 17 apr 2004, 20:41

je moet alles uploaden in de map admin! en dan moet je naar /admin/mods/easymod om het te installeeren.

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 18 apr 2004, 09:26

maar in het txt bestandje staat niet van open ...... en find...... en replace enzovoort.
http://www.forumfun.nl.tt dat is mijn forum!!!

Gebruikersavatar
DaMnNaTiOn
Berichten: 2555
Lid geworden op: 11 dec 2002, 18:29
Locatie: localhost
Contacteer:

Bericht door DaMnNaTiOn » 18 apr 2004, 09:35

Je hoeft ook niks te veranderen... :roll:
http://area51.phpbb.com/phpBB22/viewtop ... 17&t=13439
Hier staat hoe alles moet :roll:
lastmodified.net

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 18 apr 2004, 11:28

wat moet je allemaal bij de settings invullen??
http://www.forumfun.nl.tt dat is mijn forum!!!

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 18 apr 2004, 13:22

Hoe werkt easy mod ik heb hem al geinstalleerd?
http://www.forumfun.nl.tt dat is mijn forum!!!

Gebruikersavatar
Nick V
Berichten: 774
Lid geworden op: 18 okt 2003, 00:41
Locatie: Niet Nu!
Contacteer:

Bericht door Nick V » 18 apr 2004, 13:23

gewoon wat ze er vragen!!!!! :roll:

en je kan beter alles zelf modde, alhoewel als je easymod al niet kan installen :roll: :oops:

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 18 apr 2004, 13:24

dat is mij net gelukt
http://www.forumfun.nl.tt dat is mijn forum!!!

koudekerk
Berichten: 155
Lid geworden op: 09 apr 2004, 16:40
Contacteer:

Bericht door koudekerk » 18 apr 2004, 13:24

Hoe werkt easy mod ik heb hem al geinstalleerd?
http://www.forumfun.nl.tt dat is mijn forum!!!

abcde
Berichten: 1494
Lid geworden op: 19 feb 2004, 16:02

Bericht door abcde » 18 apr 2004, 13:45

In de Admin Controle Panel zie je een kopje staan waar staat:

-Mods Center

Dan zie je drie keuze's, kies de bovenste om nieuwe mods te instaleren.

Let op: Nieuwe mods moet je wel in bepaalde map uploaden : ...../forum/admin/mods/naam van mod

De tweede optie is de MODS geschiedenis, welke mods je met easymod dus al hebt geinstaleerd en de derde optie is om je settings te wijzigen.
Bijna 1500 posts!

Gebruikersavatar
Nick V
Berichten: 774
Lid geworden op: 18 okt 2003, 00:41
Locatie: Niet Nu!
Contacteer:

Bericht door Nick V » 18 apr 2004, 17:28

koudekerk lees voortaan ff de readme bestanden van een mod daar staat namelijk alle sin :roll: :x

Gesloten