コード例 #1
0
ファイル: export.php プロジェクト: songchin/Cacti
function get_item_xml($type, $id, $follow_deps) {
	$xml_text = "";
	$xml_indent = "";

	if ($follow_deps == true) {
		/* follow all dependencies recursively */
		$dep_array = resolve_dependencies($type, $id, array());
	}else{
		/* we are not supposed to resolve dependencies */
		$dep_array[$type][$id] = $id;
	}

	if (sizeof($dep_array) > 0) {
		while (list($dep_type, $dep_arr) = each($dep_array)) {
			while (list($dep_id, $dep_id) = each($dep_arr)) {
				switch($dep_type) {
				case 'graph_template':
					$xml_text .= "\n" . graph_template_to_xml($dep_id);
					break;
				case 'data_template':
					$xml_text .= "\n" . data_template_to_xml($dep_id);
					break;
				case 'host_template':
					$xml_text .= "\n" . host_template_to_xml($dep_id);
					break;
				case 'data_input_method':
					$xml_text .= "\n" . data_input_method_to_xml($dep_id);
					break;
				case 'data_query':
					$xml_text .= "\n" . data_query_to_xml($dep_id);
					break;
				case 'gprint_preset':
					$xml_text .= "\n" . gprint_preset_to_xml($dep_id);
					break;
				case 'cdef':
					$xml_text .= "\n" . cdef_to_xml($dep_id);
					break;
				case 'round_robin_archive':
					$xml_text .= "\n" . round_robin_archive_to_xml($dep_id);
					break;
				}
			}
		}
	}

	$xml_array = explode("\n", $xml_text);

	for ($i=0; $i<count($xml_array); $i++) {
		$xml_indent .= "\t" . $xml_array[$i] . "\n";
	}

	$xml_text = "<cacti>" . $xml_indent . "</cacti>";

	return $xml_text;
}
コード例 #2
0
ファイル: system.php プロジェクト: letsdodjango/furasta-org
/**
 * settings_rewrite 
 * 
 * Used to change any of the variables written in the
 * settings.php file, executes htaccess_rewrite also as
 * it is possible within settings_rewrite that the active
 * plugins are changed.
 *
 * @param mixed $SETTINGS
 * @param mixed $DB
 * @param mixed $PLUGINS
 * @param mixed $constants optional
 * @access public
 * @return void
 */
function settings_rewrite($SETTINGS, $DB, $PLUGINS, $constants = array())
{
    require_once HOME . '_inc/function/defaults.php';
    $constants = defaults_constants($constants);
    $Plugins = Plugins::getInstance();
    /**
     * calculate plugin dependencies
     */
    $plugins = array();
    foreach ($PLUGINS as $p_name => $version) {
        $plugin = $Plugins->plugins($p_name);
        if (!$plugin) {
            require HOME . '_plugins/' . $p_name . '/plugin.php';
        }
        array_push($plugins, array('sys_name' => $p_name, 'name' => $plugin['name'], 'version' => $plugin['version'], 'dependencies' => @$plugin['dependencies']));
    }
    $PLUGINS = resolve_dependencies($plugins, $PLUGINS);
    /**
     * plugins - filter the settings, constants and plugins arrays 
     */
    list($SETTINGS, $constants, $PLUGINS) = $Plugins->filter('general', 'filter_settings', array($SETTINGS, $constants, $PLUGINS));
    $filecontents = defaults_settings_content($SETTINGS, $DB, $PLUGINS, $constants);
    /**
     * write file or throw error
     */
    file_put_contents(HOME . '.settings.php', $filecontents) or error('You must grant <i>0777</i> write access to the <i>' . HOME . '</i> directory for <a href="http://furasta.org">Furasta.Org</a> to function correctly.' . 'Please do so then reload this page to save the settings.', 'Runtime Error');
    return htaccess_rewrite();
}