[Easymod-cvs] easymod2/mods/easymod/includes admin_easymod.php.txt, 1.48, 1.49
Status: Beta
Brought to you by:
wgeric
From: Eric F. <wg...@us...> - 2006-10-01 22:19:08
|
Update of /cvsroot/easymod/easymod2/mods/easymod/includes In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv32211/includes Modified Files: admin_easymod.php.txt Log Message: MODX! Ready to test. CVS files were messed up and that's why this didn't go through with the other commit. Index: admin_easymod.php.txt =================================================================== RCS file: /cvsroot/easymod/easymod2/mods/easymod/includes/admin_easymod.php.txt,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** admin_easymod.php.txt 30 Sep 2006 17:59:09 -0000 1.48 --- admin_easymod.php.txt 1 Oct 2006 22:19:05 -0000 1.49 *************** *** 91,99 **** include($phpbb_root_path . 'admin/em_includes/em_modio.' . $phpEx); include($phpbb_root_path . 'admin/em_includes/em_functions.' . $phpEx); /// /// ! define('EASYMOD_VER', 'beta (0.3.5)'); define('FAQ_LINK', '<a href="http://easymod.sourceforge.net/readme/" target="_blank">'); define('REPORT_LINK', '<a href="http://area51.phpbb.com/phpBB/viewtopic.php?t=12143" target="_blank">'); --- 91,100 ---- include($phpbb_root_path . 'admin/em_includes/em_modio.' . $phpEx); include($phpbb_root_path . 'admin/em_includes/em_functions.' . $phpEx); + include($phpbb_root_path . 'admin/em_includes/parser_xml.' . $phpEx); /// /// ! define('EASYMOD_VER', 'beta (0.4.0)'); define('FAQ_LINK', '<a href="http://easymod.sourceforge.net/readme/" target="_blank">'); define('REPORT_LINK', '<a href="http://area51.phpbb.com/phpBB/viewtopic.php?t=12143" target="_blank">'); *************** *** 214,221 **** // 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) { global $phpbb_root_path, $script_path, $mod_type; // used to add a little tolerance on the Author line $faux_author = false; --- 215,228 ---- // 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, &$modx_mod = false) { global $phpbb_root_path, $script_path, $mod_type; + if ($mod_type == MODX) + { + $modx_mod = true; + return get_modx_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; *************** *** 231,240 **** $buffer = fgets($f_mod_script, 1024); - if ($mod_type == MODX) - { - get_modx_properties($buffer, &$mod_title, &$mod_author_handle, &$mod_author_email, &$mod_author_name, &$mod_author_url, &$mod_description, &$mod_version, &$compliant); - return true; - } - // see if it is EMC right away; first line starts with ## on it and contains "easymod" $compliant = false; --- 238,241 ---- *************** *** 403,410 **** } ! function get_modx_properties($buffer, &$mod_title, &$mod_author_handle, &$mod_author_email, &$mod_author_name, &$mod_author_url, &$mod_description, &$mod_version, &$compliant) { global $phpbb_root_path, $script_path; } --- 404,424 ---- } ! function get_modx_properties($file, &$mod_title, &$mod_author_handle, &$mod_author_email, &$mod_author_name, &$mod_author_url, &$mod_description, &$mod_version, &$compliant) { global $phpbb_root_path, $script_path; + $modx = new mod_parser_xml(implode("\n", file($file))); + $modx->parse_header(); + + $mod_title = $modx->header['name']; + $mod_author_handle = $modx->header['author'][0]['username']; + $mod_author_email = $modx->header['author'][0]['email']; + $mod_author_name = $modx->header['author'][0]['realname']; + $mod_author_url = $modx->header['author'][0]['website']; + $mod_description = $modx->header['desc']; + $mod_version = $modx->header['version']; + $compliant = false; + + return (!empty($mod_title) && !empty($mod_author_handle)) ? true : false; } *************** *** 727,731 **** } ! // --- 741,750 ---- } ! if (!empty($install_file)) ! { ! $extension = explode('.', $install_file); ! $extension = array_pop($extension); ! $mod_type = ($extension == 'xml') ? MODX : TEXT; ! } // *************** *** 1597,1602 **** { $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 = ''; --- 1616,1624 ---- { $file_path = $path . '/' . $file; + $extension = explode('.', $file); + $extension = array_pop($extension); // make sure it is not a dir, and that it ends with .txt or .mod ! //(eregi(".txt$", $file_path)) || (eregi(".mod$", $file_path)) || (eregi(".xml$", $file_path)))) ! if ( !is_dir( $file_path) && in_array($extension, array('txt', 'mod', 'xml'))) { $mod_title = ''; *************** *** 1608,1613 **** $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 --- 1630,1637 ---- $mod_version = ''; $compliant = false; + $modx_mod = false; + $mod_type = ($extension == 'xml') ? MODX : TEXT; ! $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, $modx_mod); // if it is a MOD and has not been processed yet then add it to the list *************** *** 1615,1618 **** --- 1639,1649 ---- { $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; + + $emc = ''; + if ($modx_mod == true) + { + $emc = '<img src="../templates/subSilver/images/modx_inside.png"><br />'; + } + $emc .= ($compliant) ? '<img src="../templates/subSilver/images/emc.gif">' : $lang['No']; $template->assign_block_vars('unprocessed', array( 'ROW_CLASS' => $row_class, *************** *** 1622,1626 **** '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, --- 1653,1657 ---- 'MOD_VERSION' => $mod_version, 'MOD_DESC' => $mod_description, ! 'MOD_EMC' => $emc, 'MOD_PATH' => $path . '/', 'MOD_FILE' => $file, *************** *** 1649,1716 **** $files = array(); check_file_scope($install_path . $install_file, $phpbb_root_path . $script_path); ! $f_mod_script = fopen($install_path . $install_file, 'rb'); ! while (!feof($f_mod_script)) { ! $buffer = fgets($f_mod_script, 4096); ! ! // if the line starts with #, this is either a comment or an action 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] == '#') { ! // if we find [ and ] and OPEN on this line, then we can be reasonably sure we've got an OPEN command ! if ((strstr($buffer, '[')) && (strstr($buffer, ']')) && (strstr($buffer, 'OPEN'))) { ! // get us past any remaining # lines ! $buffer = fgets($f_mod_script, 4096); ! while ($buffer[0] == '#') { ! if ( feof($f_mod_script)) { ! break; } ! $buffer = fgets($f_mod_script, 4096); ! } ! ! // loop until we get a filename (a non-whitespace line) or the next # line ! while (!feof($f_mod_script)) ! { ! // got a line with some text not starting with #, so we're calling this a filename ;) ! if ((strlen(trim($buffer)) > 0) && ($buffer[0] != '#')) { ! $files[] = trim($buffer); ! break; } ! ! // we found a # so get us out of here ! else if ($buffer[0] == '#') { break; } - - $buffer = fgets($f_mod_script, 4096); - } - - // if we hit eof, then get us out of here - if (feof($f_mod_script)) - { - break; } } } ! ! // not a comment or command so this is the body of the command ! else ! { ! $in_header = false; ! } } - fclose($f_mod_script); --- 1680,1763 ---- $files = array(); check_file_scope($install_path . $install_file, $phpbb_root_path . $script_path); ! ! if ($mod_type == MODX) { ! $modx = new mod_parser_xml(implode("\n", file($install_path . $install_file))); ! $modx->_parse(); ! ! $actions = $modx->data[0]['children']['ACTION-GROUP'][0]['children']; ! $open_info = (!empty($actions['OPEN'])) ? $actions['OPEN'] : array(); ! for($i = 0, $total = sizeof($open_info); $i < $total; $i++) { ! $files[] = str_replace('\\', '/', trim($open_info[$i]['attrs']['SRC'])); } ! } ! else ! { ! $f_mod_script = fopen($install_path . $install_file, 'rb'); ! while (!feof($f_mod_script)) { ! $buffer = fgets($f_mod_script, 4096); ! ! // if the line starts with #, this is either a comment or an action 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] == '#') ! { ! // if we find [ and ] and OPEN on this line, then we can be reasonably sure we've got an OPEN command ! if ((strstr($buffer, '[')) && (strstr($buffer, ']')) && (strstr($buffer, 'OPEN'))) { ! // get us past any remaining # lines ! $buffer = fgets($f_mod_script, 4096); ! while ($buffer[0] == '#') { ! if ( feof($f_mod_script)) ! { ! break; ! } ! $buffer = fgets($f_mod_script, 4096); } ! ! // loop until we get a filename (a non-whitespace line) or the next # line ! while (!feof($f_mod_script)) { ! // got a line with some text not starting with #, so we're calling this a filename ;) ! if ((strlen(trim($buffer)) > 0) && ($buffer[0] != '#')) ! { ! $files[] = trim($buffer); ! break; ! } ! ! // we found a # so get us out of here ! else if ($buffer[0] == '#') ! { ! break; ! } ! ! $buffer = fgets($f_mod_script, 4096); } ! ! // if we hit eof, then get us out of here ! if (feof($f_mod_script)) { break; } } } + + // not a comment or command so this is the body of the command + else + { + $in_header = false; + } } ! fclose($f_mod_script); } *************** *** 1812,2009 **** check_file_scope($install_path . $install_file, $phpbb_root_path . $script_path); ! $f_mod_script = fopen($install_path . $install_file, 'rb'); ! 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, 'SQL')) ! { ! $current_command = 'SQL'; ! } ! else if ( strstr($buffer, 'DIY INSTRUCTIONS') ) ! { ! $current_command = 'DIY INSTRUCTIONS'; ! } ! else if ( strstr($buffer, 'INCREMENT') ) ! { ! $current_command = 'INCREMENT'; ! } ! 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 --- 1859,2246 ---- check_file_scope($install_path . $install_file, $phpbb_root_path . $script_path); ! ! if ($mod_type == MODX) { ! $modx = new mod_parser_xml(implode("\n", file($install_path . $install_file))); ! ! $modx->parse_actions(); ! if (($mode == 'display_file') || ($mode == 'download_file')) { ! $commands[] = array('command' => 'OPEN', 'line' => 0); ! $body[] = array($process_file); ! ! $actions = $modx->actions['open'][$process_file]; ! for($i = 0, $total = sizeof($actions['edit']); $i < $total; $i++) { ! $commands[] = array('command' => 'FIND', 'line' => 0); ! $body[] = explode("\n", $actions['edit'][$i]['find']); ! ! $edit_actions = $actions['edit'][$i]['action']; ! for($j = 0, $total2 = sizeof($edit_actions); $j < $total2; $j++) { ! $code = explode("\n", $edit_actions[$j]['code']); ! for($k = 0, $total3 = sizeof($code); $k < $total3; $k++) { ! $code[$k] = rtrim($code[$k]) . "\n"; ! } ! ! switch($edit_actions[$j]['type']) ! { ! case 'after-add': ! $current_command = 'AFTERADD'; ! break; ! ! case 'before-add': ! $current_command = 'BEFOREADD'; ! break; ! ! case 'replace-with': ! $current_command = 'REPLACE'; ! break; ! ! case 'increment': ! $current_command = 'INCREMENT'; ! break; } + + $commands[] = array('command' => $current_command, 'line' => $edit_actions[$j]['line']); + $body[] = $code; } ! ! $inline_edit_actions = $actions['edit'][$i]['in-line-edit']; ! for($j = 0, $total2 = sizeof($inline_edit_actions); $j < $total2; $j++) { ! $commands[] = array('command' => 'IN-LINE FIND', 'line' => 0); ! $body[] = explode("\n", $inline_edit_actions[$j]['in-line-find']); ! ! $inline_actions = $inline_edit_actions[$j]['in-line-action']; ! for($k = 0, $total3 = sizeof($inline_actions); $k < $total3; $k++) { ! switch($inline_actions[$k]['type']) { ! case 'in-line-before-add': ! $current_command = 'IN-LINE BEFOREADD'; ! break; ! ! case 'in-line-after-add': ! $current_command = 'IN-LINE AFTERADD'; ! break; ! ! case 'in-line-replace-with': ! $current_command = 'IN-LINE REPLACE'; break; } ! ! $commands[] = array('command' => $current_command, 'line' => $inline_actions[$k]['line']); ! $body[] = array($inline_actions[$k]['code']); } } ! } ! } ! else ! { ! foreach($modx->actions as $action => $data) ! { ! switch($action) { ! case 'sql': ! $commands[] = array('command' => 'SQL', 'line' => 0); ! $body[] = $data; ! break; ! ! case 'copy': ! //copy x to y ! $copy = array(); ! for($i = 0, $total = sizeof($data); $i < $total; $i++) ! { ! $copy[] = 'copy ' . $data[$i]['from'] . ' to ' . $data[$i]['to'] . "\n"; ! } ! $commands[] = array('command' => 'COPY', 'line' => 0); ! $body[] = $copy; ! break; ! ! case 'diy-instructions': ! $commands[] = array('command' => 'DIY INSTRUCTIONS', 'line' => 0); ! $body[] = $data; ! break; ! ! case 'open': ! foreach($data as $file => $actions) ! { ! $commands[] = array('command' => 'OPEN', 'line' => 0); ! $body[] = array($file); ! ! for($i = 0, $total = sizeof($actions['edit']); $i < $total; $i++) ! { ! $commands[] = array('command' => 'FIND', 'line' => 0); ! $body[] = explode("\n", $actions['edit'][$i]['find']); ! ! $edit_actions = $actions['edit'][$i]['action']; ! for($j = 0, $total2 = sizeof($edit_actions); $j < $total2; $j++) ! { ! $code = explode("\n", $edit_actions[$j]['code']); ! for($k = 0, $total3 = sizeof($code); $k < $total3; $k++) ! { ! $code[$k] = rtrim($code[$k]) . "\n"; ! } ! ! switch($edit_actions[$j]['type']) ! { ! case 'after-add': ! $current_command = 'AFTERADD'; ! break; ! ! case 'before-add': ! $current_command = 'BEFOREADD'; ! break; ! ! case 'replace-with': ! $current_command = 'REPLACE'; ! break; ! ! case 'increment': ! $current_command = 'INCREMENT'; ! break; ! } ! ! $commands[] = array('command' => $current_command, 'line' => $edit_actions[$j]['line']); ! $body[] = $code; ! } ! ! $inline_edit_actions = $actions['edit'][$i]['in-line-edit']; ! for($j = 0, $total2 = sizeof($inline_edit_actions); $j < $total2; $j++) ! { ! $commands[] = array('command' => 'IN-LINE FIND', 'line' => 0); ! $body[] = explode("\n", $inline_edit_actions[$j]['in-line-find']); ! ! $inline_actions = $inline_edit_actions[$j]['in-line-action']; ! for($k = 0, $total3 = sizeof($inline_actions); $k < $total3; $k++) ! { ! switch($inline_actions[$k]['type']) ! { ! case 'in-line-before-add': ! $current_command = 'IN-LINE BEFOREADD'; ! break; ! ! case 'in-line-after-add': ! $current_command = 'IN-LINE AFTERADD'; ! break; ! ! case 'in-line-replace-with': ! $current_command = 'IN-LINE REPLACE'; ! break; ! } ! ! $commands[] = array('command' => $current_command, 'line' => $inline_actions[$k]['line']); ! $body[] = array($inline_actions[$k]['code']); ! } ! } ! } ! } ! break; } } + + $commands[] = array('command' => 'CLOSE', 'line' => 0); + $body[] = array(); } ! } ! else ! { ! $f_mod_script = fopen($install_path . $install_file, 'rb'); ! 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, 'SQL')) ! { ! $current_command = 'SQL'; ! } ! else if ( strstr($buffer, 'DIY INSTRUCTIONS') ) ! { ! $current_command = 'DIY INSTRUCTIONS'; ! } ! else if ( strstr($buffer, 'INCREMENT') ) ! { ! $current_command = 'INCREMENT'; ! } ! 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 |