/** * Automod test * TY AJD * * @param string $phpbb_path Path to phpBB files we run the test on * @param string $details Will hold the details of the mod * @param string $results Will hold the results for output * @param string $bbcode_results Will hold the results for storage * @return bool true on success, false on failure */ public function automod($phpbb_path, &$details, &$results, &$bbcode_results) { phpbb::_include('functions_transfer', false, 'transfer'); phpbb::_include('functions_admin', 'recalc_nested_sets'); titania::_include('library/automod/acp_mods', false, 'acp_mods'); titania::_include('library/automod/editor', false, 'editor'); titania::_include('library/automod/mod_parser', false, 'parser'); titania::_include('library/automod/functions_mods', 'test_ftp_connection'); titania::add_lang('automod'); // Find the main modx file $modx_root = $this->find_root(); if ($modx_root === false) { titania::add_lang('contributions'); $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT']; return false; } $modx_root = $this->unzip_dir . $modx_root; $modx_file = false; if (file_exists($modx_root . 'install.xml')) { $modx_file = $modx_root . 'install.xml'; } else { // Find the first item with install in the name foreach (scandir($modx_root) as $item) { if (strpos($item, 'install') !== false && strpos($item, '.xml')) { $modx_file = $modx_root . $item; break; } } } if (!$modx_file) { titania::add_lang('contributions'); $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT']; return false; } // HAX global $phpbb_root_path; $phpbb_root_path = $phpbb_path; // The real stuff $acp_mods = new acp_mods(); $acp_mods->mods_dir = titania::$config->contrib_temp_path; $editor = new editor_direct(); $details = $acp_mods->mod_details($modx_file, false); $actions = $acp_mods->mod_actions($modx_file); $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false); if ($installed) { phpbb::$template->assign_var('S_EDITS_NO_ERROR', true); } // Try to launch copy actions if they exist if (isset($actions['NEW_FILES']) && !empty($actions['NEW_FILES'])) { while (list($source, $target) = each($actions['NEW_FILES'])) { if (is_array($target)) { // If we've shifted off all targets, we're done w/ that element if (empty($target)) { continue; } // Shift off first target, then rewind array pointer to get next target $target = array_shift($actions['NEW_FILES'][$source]); prev($actions['NEW_FILES']); } $status = $editor->copy_content($modx_root . str_replace('*.*', '', $source), $phpbb_root_path . str_replace('*.*', '', $target)); $actions_copy[] = $phpbb_root_path . str_replace('*.*', '', $target); if (!$status) { $actions_copy_error[] = str_replace('*.*', '', $source); phpbb::$template->assign_var('S_COPY_ERROR', true); $installed = false; } } if (isset($actions_copy_error) && sizeof($actions_copy_error)) { foreach ($actions_copy_error as $action_copy_error) { phpbb::$template->assign_block_vars('copy_files', array('FILENAME' => $action_copy_error)); } } // Time to clean our phpBB installation (located in /store/ directory) if (isset($actions_copy) && sizeof($actions_copy)) { foreach ($actions_copy as $action_copy) { unlink($action_copy); } } } // Reverse HAX $phpbb_root_path = PHPBB_ROOT_PATH; phpbb::$template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html')); phpbb::$template->assign_var('S_AUTOMOD_SUCCESS', $installed); $results = phpbb::$template->assign_display('automod'); $bbcode_results = phpbb::$template->assign_display('automod_bbcode'); return $installed; }
/** * Automod test * TY AJD * * @param string $phpbb_path Path to phpBB files we run the test on * @param string $details Will hold the details of the mod * @param string $results Will hold the results for output * @param string $bbcode_results Will hold the results for storage * @return bool true on success, false on failure */ public function automod($phpbb_path, &$details, &$results, &$bbcode_results) { phpbb::_include('functions_transfer', false, 'transfer'); phpbb::_include('functions_admin', 'recalc_nested_sets'); titania::_include('library/automod/acp_mods', false, 'acp_mods'); titania::_include('library/automod/editor', false, 'editor'); titania::_include('library/automod/mod_parser', false, 'parser'); titania::_include('library/automod/functions_mods', 'test_ftp_connection'); titania::add_lang('automod'); // Find the main modx file $modx_root = $this->find_root(); if ($modx_root === false) { titania::add_lang('contributions'); $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT']; return false; } $modx_root = $this->unzip_dir . $modx_root; $modx_file = false; if (file_exists($modx_root . 'install.xml')) { $modx_file = $modx_root . 'install.xml'; } else { // Find the first item with install in the name foreach (scandir($modx_root) as $item) { if (strpos($item, 'install') !== false && strpos($item, '.xml')) { $modx_file = $modx_root . $item; break; } } } if (!$modx_file) { titania::add_lang('contributions'); $this->error[] = phpbb::$user->lang['COULD_NOT_FIND_ROOT']; return false; } // HAX global $phpbb_root_path; $phpbb_root_path = $phpbb_path; // The real stuff $acp_mods = new acp_mods(); $acp_mods->mods_dir = titania::$config->contrib_temp_path; $editor = new editor_direct(); $details = $acp_mods->mod_details($modx_file, false); $actions = $acp_mods->mod_actions($modx_file); $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false); // Reverse HAX $phpbb_root_path = PHPBB_ROOT_PATH; phpbb::$template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html')); phpbb::$template->assign_var('S_AUTOMOD_SUCCESS', $installed); $results = phpbb::$template->assign_display('automod'); $bbcode_results = phpbb::$template->assign_display('automod_bbcode'); return $installed; }
/** * Run AutoMOD test. * * @param \phpbb\titania\entity\package $package * @param string $phpbb_path Path to phpBB files we run the test on * @param string $details Will hold the details of the mod * @param string $results Will hold the results for output * @param string $bbcode_results Will hold the results for storage * @return bool true on success, false on failure */ public function run_automod_test($package, $phpbb_path, &$details, &$results, &$bbcode_results) { require $this->phpbb_root_path . 'includes/functions_transfer.' . $this->php_ext; require $this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/acp_mods.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/editor.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/mod_parser.' . $this->php_ext; require $this->ext_root_path . 'includes/library/automod/functions_mods.' . $this->php_ext; $this->user->add_lang_ext('phpbb/titania', 'automod'); // Find the main modx file $modx_root = $package->find_directory(array('files' => array('required' => 'install*.xml'))); if ($modx_root === null) { $this->user->add_lang_ext('phpbb/titania', 'contributions'); $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT']; return false; } $modx_root = $package->get_temp_path() . '/' . $modx_root . '/'; $modx_file = false; if (file_exists($modx_root . 'install.xml')) { $modx_file = $modx_root . 'install.xml'; } else { $finder = new \Symfony\Component\Finder\Finder(); $finder->name('install*.xml')->depth(0)->in($modx_root); if ($finder->count()) { foreach ($finder as $file) { $modx_file = $file->getPathname(); break; } } } if (!$modx_file) { $this->user->add_lang_ext('phpbb/titania', 'contributions'); $this->errors[] = $this->user->lang['COULD_NOT_FIND_ROOT']; return false; } // HAX global $phpbb_root_path; $phpbb_root_path = $phpbb_path; // The real stuff $acp_mods = new \acp_mods(); $acp_mods->mods_dir = $this->ext_config->__get('contrib_temp_path'); $acp_mods->mod_root = $modx_root; $editor = new \editor_direct(); $details = $acp_mods->mod_details($modx_file, false); $actions = $acp_mods->mod_actions($modx_file); $installed = $acp_mods->process_edits($editor, $actions, $details, false, true, false); // Reverse HAX $phpbb_root_path = $this->phpbb_root_path; $this->template->set_filenames(array('automod' => 'contributions/automod.html', 'automod_bbcode' => 'contributions/automod_bbcode.html')); $this->template->assign_var('S_AUTOMOD_SUCCESS', $installed); $results = $this->template->assign_display('automod'); $bbcode_results = $this->template->assign_display('automod_bbcode'); return $installed; }