function emptyelement($element, $attributes = array())
 {
     $this->_indent();
     $this->xml .= '<' . $element;
     foreach ($attributes as $key => $value) {
         $this->xml .= ' ' . $key . '="' . xml_character_encode($value) . '"';
     }
     $this->xml .= " />\n";
 }
Example #2
0
function &data_query_to_xml($data_query_id) {
	global $fields_data_query_edit, $fields_data_query_item_edit;

	$hash["data_query"] = get_hash_version("data_query") . get_hash_data_query($data_query_id);
	$xml_text = "";

	$snmp_query = db_fetch_row("select * from snmp_query where id=$data_query_id");
	$snmp_query_graph = db_fetch_assoc("select * from snmp_query_graph where snmp_query_id=$data_query_id");

	if (empty($snmp_query["id"])) {
		return "Invalid data query.";
	}

	$xml_text .= "<hash_" . $hash["data_query"] . ">\n";

	/* XML Branch: <> */
	reset($fields_data_query_edit);
	while (list($field_name, $field_array) = each($fields_data_query_edit)) {
		if (($field_name == "data_input_id") && (!empty($snmp_query{$field_name}))) {
			$xml_text .= "\t<$field_name>hash_" . get_hash_version("data_input_method") . get_hash_data_input($snmp_query{$field_name}) . "</$field_name>\n";
		}else{
			if (($field_array["method"] != "hidden_zero") && ($field_array["method"] != "hidden")) {
				$xml_text .= "\t<$field_name>" . xml_character_encode($snmp_query{$field_name}) . "</$field_name>\n";
			}
		}
	}

	/* XML Branch: <graphs> */

	$xml_text .= "\t<graphs>\n";

	$i = 0;
	if (sizeof($snmp_query_graph) > 0) {
	foreach ($snmp_query_graph as $item) {
		$hash["data_query_graph"] = get_hash_version("data_query_graph") . get_hash_data_query($item["id"], "data_query_graph");

		$xml_text .= "\t\t<hash_" . $hash["data_query_graph"] . ">\n";

		reset($fields_data_query_item_edit);
		while (list($field_name, $field_array) = each($fields_data_query_item_edit)) {
			if (($field_name == "graph_template_id") && (!empty($item{$field_name}))) {
				$xml_text .= "\t\t\t<$field_name>hash_" . get_hash_version("graph_template") . get_hash_graph_template($item{$field_name}) . "</$field_name>\n";
			}else{
				if (($field_array["method"] != "hidden_zero") && ($field_array["method"] != "hidden")) {
					$xml_text .= "\t\t\t<$field_name>" . xml_character_encode($item{$field_name}) . "</$field_name>\n";
				}
			}
		}

		$snmp_query_graph_rrd_sv = db_fetch_assoc("select * from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
		$snmp_query_graph_sv = db_fetch_assoc("select * from snmp_query_graph_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
		$snmp_query_graph_rrd = db_fetch_assoc("select * from snmp_query_graph_rrd where snmp_query_graph_id=" . $item["id"] . " and data_template_id > 0");

		/* XML Branch: <graphs/rrd> */

		$xml_text .= "\t\t\t<rrd>\n";

		$i = 0;
		if (sizeof($snmp_query_graph_rrd) > 0) {
		foreach ($snmp_query_graph_rrd as $item2) {
			$xml_text .= "\t\t\t\t<item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";

			$xml_text .= "\t\t\t\t\t<snmp_field_name>" . $item2{"snmp_field_name"} . "</snmp_field_name>\n";
			$xml_text .= "\t\t\t\t\t<data_template_id>hash_" . get_hash_version("data_template") . get_hash_data_template($item2{"data_template_id"}) . "</data_template_id>\n";
			$xml_text .= "\t\t\t\t\t<data_template_rrd_id>hash_" . get_hash_version("data_template_item") . get_hash_data_template($item2{"data_template_rrd_id"}, "data_template_item") . "</data_template_rrd_id>\n";

			$xml_text .= "\t\t\t\t</item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";

			$i++;
		}
		}

		$xml_text .= "\t\t\t</rrd>\n";

		/* XML Branch: <graphs/sv_graph> */

		$xml_text .= "\t\t\t<sv_graph>\n";

		$j = 0;
		if (sizeof($snmp_query_graph_sv) > 0) {
		foreach ($snmp_query_graph_sv as $item2) {
			$hash["data_query_sv_graph"] = get_hash_version("data_query_sv_graph") . get_hash_data_query($item2["id"], "data_query_sv_graph");

			$xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_graph"] . ">\n";

			$xml_text .= "\t\t\t\t\t<field_name>" . xml_character_encode($item2{"field_name"}) . "</field_name>\n";
			$xml_text .= "\t\t\t\t\t<sequence>" . $item2{"sequence"} . "</sequence>\n";
			$xml_text .= "\t\t\t\t\t<text>" . xml_character_encode($item2{"text"}) . "</text>\n";

			$xml_text .= "\t\t\t\t</hash_" . $hash["data_query_sv_graph"] . ">\n";

			$j++;
		}
		}

		$xml_text .= "\t\t\t</sv_graph>\n";

		/* XML Branch: <graphs/sv_data_source> */

		$xml_text .= "\t\t\t<sv_data_source>\n";

		$j = 0;
		if (sizeof($snmp_query_graph_rrd_sv) > 0) {
		foreach ($snmp_query_graph_rrd_sv as $item2) {
			$hash["data_query_sv_data_source"] = get_hash_version("data_query_sv_data_source") . get_hash_data_query($item2["id"], "data_query_sv_data_source");

			$xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_data_source"] . ">\n";

			$xml_text .= "\t\t\t\t\t<field_name>" . xml_character_encode($item2{"field_name"}) . "</field_name>\n";
			$xml_text .= "\t\t\t\t\t<data_template_id>hash_" . get_hash_version("data_template") . get_hash_data_template($item2{"data_template_id"}) . "</data_template_id>\n";
			$xml_text .= "\t\t\t\t\t<sequence>" . $item2{"sequence"} . "</sequence>\n";
			$xml_text .= "\t\t\t\t\t<text>" . xml_character_encode($item2{"text"}) . "</text>\n";

			$xml_text .= "\t\t\t\t</hash_" . $hash["data_query_sv_data_source"] . ">\n";

			$j++;
		}
		}

		$xml_text .= "\t\t\t</sv_data_source>\n";

		$xml_text .= "\t\t</hash_" . $hash["data_query_graph"] . ">\n";

		$i++;
	}
	}

	$xml_text .= "\t</graphs>\n";

	$xml_text .= "</hash_" . $hash["data_query"] . ">";

	return $xml_text;
}
Example #3
0
function data_query_to_xml($data_query_id)
{
    global $fields_data_query_edit, $fields_data_query_item_edit, $export_errors;
    $hash["data_query"] = get_hash_version("data_query") . get_hash_data_query($data_query_id);
    $xml_text = "";
    $snmp_query = db_fetch_row("select * from snmp_query where id={$data_query_id}");
    $snmp_query_graph = db_fetch_assoc("select * from snmp_query_graph where snmp_query_id={$data_query_id}");
    if (empty($snmp_query["id"])) {
        $export_errors++;
        raise_message(28);
        cacti_log("ERROR: Invalid Data Query found during Export.  Please run database repair script to identify and/or correct.", false, "WEBUI");
        return;
    }
    $xml_text .= "<hash_" . $hash["data_query"] . ">\n";
    /* XML Branch: <> */
    reset($fields_data_query_edit);
    while (list($field_name, $field_array) = each($fields_data_query_edit)) {
        if ($field_name == "data_input_id" && !empty($snmp_query[$field_name])) {
            $xml_text .= "\t<{$field_name}>hash_" . get_hash_version("data_input_method") . get_hash_data_input($snmp_query[$field_name]) . "</{$field_name}>\n";
        } else {
            if ($field_array["method"] != "hidden_zero" && $field_array["method"] != "hidden") {
                $xml_text .= "\t<{$field_name}>" . xml_character_encode($snmp_query[$field_name]) . "</{$field_name}>\n";
            }
        }
    }
    /* XML Branch: <graphs> */
    $xml_text .= "\t<graphs>\n";
    $i = 0;
    if (sizeof($snmp_query_graph) > 0) {
        foreach ($snmp_query_graph as $item) {
            $hash["data_query_graph"] = get_hash_version("data_query_graph") . get_hash_data_query($item["id"], "data_query_graph");
            $xml_text .= "\t\t<hash_" . $hash["data_query_graph"] . ">\n";
            reset($fields_data_query_item_edit);
            while (list($field_name, $field_array) = each($fields_data_query_item_edit)) {
                if ($field_name == "graph_template_id" && !empty($item[$field_name])) {
                    $xml_text .= "\t\t\t<{$field_name}>hash_" . get_hash_version("graph_template") . get_hash_graph_template($item[$field_name]) . "</{$field_name}>\n";
                } else {
                    if ($field_array["method"] != "hidden_zero" && $field_array["method"] != "hidden") {
                        $xml_text .= "\t\t\t<{$field_name}>" . xml_character_encode($item[$field_name]) . "</{$field_name}>\n";
                    }
                }
            }
            $snmp_query_graph_rrd_sv = db_fetch_assoc("select * from snmp_query_graph_rrd_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
            $snmp_query_graph_sv = db_fetch_assoc("select * from snmp_query_graph_sv where snmp_query_graph_id=" . $item["id"] . " order by sequence");
            $snmp_query_graph_rrd = db_fetch_assoc("select * from snmp_query_graph_rrd where snmp_query_graph_id=" . $item["id"] . " and data_template_id > 0");
            /* XML Branch: <graphs/rrd> */
            $xml_text .= "\t\t\t<rrd>\n";
            $i = 0;
            if (sizeof($snmp_query_graph_rrd) > 0) {
                foreach ($snmp_query_graph_rrd as $item2) {
                    $xml_text .= "\t\t\t\t<item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";
                    $xml_text .= "\t\t\t\t\t<snmp_field_name>" . $item2["snmp_field_name"] . "</snmp_field_name>\n";
                    $xml_text .= "\t\t\t\t\t<data_template_id>hash_" . get_hash_version("data_template") . get_hash_data_template($item2["data_template_id"]) . "</data_template_id>\n";
                    $xml_text .= "\t\t\t\t\t<data_template_rrd_id>hash_" . get_hash_version("data_template_item") . get_hash_data_template($item2["data_template_rrd_id"], "data_template_item") . "</data_template_rrd_id>\n";
                    $xml_text .= "\t\t\t\t</item_" . str_pad(strval($i), 3, "0", STR_PAD_LEFT) . ">\n";
                    $i++;
                }
            }
            $xml_text .= "\t\t\t</rrd>\n";
            /* XML Branch: <graphs/sv_graph> */
            $xml_text .= "\t\t\t<sv_graph>\n";
            $j = 0;
            if (sizeof($snmp_query_graph_sv) > 0) {
                foreach ($snmp_query_graph_sv as $item2) {
                    $hash["data_query_sv_graph"] = get_hash_version("data_query_sv_graph") . get_hash_data_query($item2["id"], "data_query_sv_graph");
                    $xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_graph"] . ">\n";
                    $xml_text .= "\t\t\t\t\t<field_name>" . xml_character_encode($item2["field_name"]) . "</field_name>\n";
                    $xml_text .= "\t\t\t\t\t<sequence>" . $item2["sequence"] . "</sequence>\n";
                    $xml_text .= "\t\t\t\t\t<text>" . xml_character_encode($item2["text"]) . "</text>\n";
                    $xml_text .= "\t\t\t\t</hash_" . $hash["data_query_sv_graph"] . ">\n";
                    $j++;
                }
            }
            $xml_text .= "\t\t\t</sv_graph>\n";
            /* XML Branch: <graphs/sv_data_source> */
            $xml_text .= "\t\t\t<sv_data_source>\n";
            $j = 0;
            if (sizeof($snmp_query_graph_rrd_sv) > 0) {
                foreach ($snmp_query_graph_rrd_sv as $item2) {
                    $hash["data_query_sv_data_source"] = get_hash_version("data_query_sv_data_source") . get_hash_data_query($item2["id"], "data_query_sv_data_source");
                    $xml_text .= "\t\t\t\t<hash_" . $hash["data_query_sv_data_source"] . ">\n";
                    $xml_text .= "\t\t\t\t\t<field_name>" . xml_character_encode($item2["field_name"]) . "</field_name>\n";
                    $xml_text .= "\t\t\t\t\t<data_template_id>hash_" . get_hash_version("data_template") . get_hash_data_template($item2["data_template_id"]) . "</data_template_id>\n";
                    $xml_text .= "\t\t\t\t\t<sequence>" . $item2["sequence"] . "</sequence>\n";
                    $xml_text .= "\t\t\t\t\t<text>" . xml_character_encode($item2["text"]) . "</text>\n";
                    $xml_text .= "\t\t\t\t</hash_" . $hash["data_query_sv_data_source"] . ">\n";
                    $j++;
                }
            }
            $xml_text .= "\t\t\t</sv_data_source>\n";
            $xml_text .= "\t\t</hash_" . $hash["data_query_graph"] . ">\n";
            $i++;
        }
    }
    $xml_text .= "\t</graphs>\n";
    $xml_text .= "</hash_" . $hash["data_query"] . ">";
    return $xml_text;
}
function write_track($track, $file)
{
    global $config;
    /* define XML encoding */
    $XMLEncoding = "UTF-8";
    if ($config["cacti_server_os"] == "WIN") {
        $XMLEncoding = "ISO-8859-1";
    }
    /* Open file */
    if (!($track_FH = fopen($file, "w"))) {
        print "ERROR: Unable to open file for writing: {$file}\n";
        return false;
    }
    /* Write header */
    fwrite($track_FH, "<?xml version=\"1.0\" encoding=\"" . $XMLEncoding . "\" standalone=\"yes\"?");
    fwrite($track_FH, ">\n");
    fwrite($track_FH, "<track>\n");
    /* Write contents */
    foreach ($track as $customer => $data) {
        fwrite($track_FH, "  <customer name=\"" . xml_character_encode($customer) . "\">\n");
        foreach ($data as $key => $items) {
            if ($key == "last_run") {
                fwrite($track_FH, "    <last_run>" . xml_character_encode($items) . "</last_run>\n");
            } elseif ($key == "notification") {
                foreach ($items as $graph_id => $value) {
                    fwrite($track_FH, "    <notification graph_id=\"" . xml_character_encode($graph_id) . "\">" . xml_character_encode($value) . "</notification>\n");
                }
            } else {
                fwrite($track_FH, "    <cache>\n");
                foreach ($items as $graph_item_id => $graph_item_id_data) {
                    foreach ($graph_item_id_data as $start => $cache) {
                        foreach ($cache as $timestamp => $value) {
                            fwrite($track_FH, "      <item ");
                            fwrite($track_FH, "start=\"" . xml_character_encode($start) . "\" ");
                            fwrite($track_FH, "date=\"" . xml_character_encode($timestamp) . "\" ");
                            fwrite($track_FH, "graph_id=\"" . xml_character_encode($key) . "\" ");
                            fwrite($track_FH, "graph_item_id=\"" . xml_character_encode($graph_item_id) . "\">");
                            fwrite($track_FH, xml_character_encode($value));
                            fwrite($track_FH, "</item>\n");
                        }
                    }
                }
                fwrite($track_FH, "    </cache>\n");
            }
        }
        fwrite($track_FH, "  </customer>\n");
    }
    /* Write footer */
    fwrite($track_FH, "</track>\n");
    /* Close file */
    fclose($track_FH);
    return true;
}
Example #5
0
        array_multisort($tsmpaf, $dattaf, $mattaf, $idtaf, $proftaf, $preftaf, $texttaf, $idtafcrypt);
    }
}
echo '<?xml version="1.0" encoding="ISO-8859-15" ?>' . "\n";
echo '<rss version="2.0">
<channel>
<generator>LCS RSS</generator>
<title>Travail &#224; faire en ' . $ch . '</title>
<link>http://' . $hostn . '/</link>
<description>Travaux donn&#233;s &#224; la classe enti&#232;re ET &#224; tous les groupes</description>
<image>
<url>../images/appli22_on.png</url>
</image>
<language>fr</language>
<ttl>5</ttl>' . "\n\n";
if (count($mattaf) > 0) {
    for ($loop = 0; $loop < count($dattaf); $loop++) {
        echo '<item>
        <title>' . stripslashes(xml_character_encode($mattaf[$loop])) . ' :  ' . $preftaf[$loop] . '  ' . $proftaf[$loop] . '</title>
        <description> Pour le ' . $dattaf[$loop] . "/&lt;br /&gt;" . stripslashes(xml_character_encode($texttaf[$loop])) . ' </description>
        <link>http://' . $hostn . '/Plugins/Cdt/scripts/poprss.php?id=' . $idtafcrypt[$loop] . '</link>
        </item>' . "\n";
    }
} else {
    echo '<item>
    <title>Rien de programm&#233; !</title>
    <description> Mais en cherchant bien ...</description>
    <link>http://' . $hostn . '/</link>
    </item>' . "\n";
}
echo '</channel>' . "\n" . '</rss>' . "\n";
function emailreqtag_func($atts)
{
    extract(shortcode_atts(array('download_id' => NULL, 'contact_form_id' => NULL, 'title' => NULL, 'file' => NULL, 'format' => NULL, 'delivered_as' => NULL, 'masked' => NULL, 'attachment' => NULL, 'force_download' => NULL, 'email_from' => NULL, 'checked' => NULL, 'hidden_form' => NULL, 'use_radio' => NULL), $atts));
    global $wpdb, $wp_dlm_root, $wp_dlm_db, $wp_dlm_db_taxonomies, $def_format, $dlm_url, $downloadurl, $downloadtype, $wp_dlm_db_meta;
    $str = '';
    $chekboxes = "";
    $chekboxesL = "";
    //$title = '';
    $url = '';
    $hf = '';
    $dldArray = array();
    $table_item = $wpdb->prefix . "ebd_item";
    $is_new_dm = false;
    if ($download_id != NULL) {
        $ebd_item = $wpdb->get_row("SELECT * FROM {$table_item}  WHERE download_id = '" . esc_sql($download_id) . "';");
        $old_rep = error_reporting(E_ERROR | E_PARSE);
        $pd =& get_file_data(WP_PLUGIN_DIR . "/download-monitor/download-monitor.php", array("Version" => "Version"), 'plugin');
        if (!$pd['Version']) {
        } else {
            $is_new_dm = true;
        }
        $new = error_reporting($old_rep);
        $dldArray = explode(",", $download_id);
        $title_tmp = '';
        foreach ($dldArray as $dl_id) {
            $d = NULL;
            if (!$is_new_dm) {
                $dl = $wpdb->get_row("SELECT * FROM {$wp_dlm_db}  WHERE id = '" . esc_sql($dl_id) . "';");
                $d = new downloadable_file($dl);
            } else {
                $d = new stdClass();
                $d->title = do_shortcode('[download_data id="' . $dl_id . '" data="title"]');
            }
            $checked_state_html = 'checked="true"';
            $checked_state = get_option('email_before_download_chekboxes_state');
            if ($checked != NULL) {
                $checked_state = $checked;
            }
            if ($checked_state == 'no') {
                $checked_state_html = '';
            }
            $checkbox = 'checkbox';
            $is_radio = get_option('email_before_download_is_radio');
            if ($use_radio != NULL) {
                $is_radio = $use_radio;
            }
            if ($is_radio == 'yes') {
                $checkbox = 'radio';
                $checked_state_html = '';
            }
            if (!empty($d)) {
                //$date = date("jS M Y", strtotime($d->date));
                if ($title == NULL || $title == '') {
                    $title_tmp .= $d->title . '|';
                }
                $chekboxes .= '<br />' . $d->title . ' <input type="' . $checkbox . '" ' . $checked_state_html . ' name="ebd_downloads[]" value="' . $dl_id . '"/>';
                $chekboxesL .= '<br /> <input type="' . $checkbox . '" ' . $checked_state_html . ' name="ebd_downloads[]" value="' . $dl_id . '"/> ' . $d->title;
            }
        }
        if (count($title_tmp) > 0) {
            $title = rtrim($title_tmp, '|');
        }
        if (empty($ebd_item)) {
            $wpdb->insert($table_item, array("download_id" => $download_id, "title" => $title));
            $download_id = $wpdb->insert_id;
            $ebd_item = $wpdb->get_row("SELECT * FROM {$table_item}  WHERE id = '" . esc_sql($download_id) . "';");
        } else {
            $download_id = $ebd_item->id;
        }
        //update title if needed
        if (($title != NULL || $title != '') && $ebd_item->title != $title) {
            $wpdb->update($table_item, array("title" => $title), array("id" => $download_id));
        }
    } else {
        if ($file) {
            if ($title == NULL || $title == '') {
                $title = basename($file);
            }
            $ebd_item = $wpdb->get_row("SELECT * FROM {$table_item}  WHERE file = '" . esc_sql($file) . "';");
            if (empty($ebd_item)) {
                $wpdb->insert($table_item, array("file" => esc_sql($file), "title" => $title));
                $download_id = $wpdb->insert_id;
                $ebd_item = $wpdb->get_row("SELECT * FROM {$table_item}  WHERE file = '" . esc_sql($file) . "';");
            } else {
                $download_id = $ebd_item->id;
            }
            //update title if needed
            if (($title != NULL || $title != '') && $ebd_item->title != $title) {
                $wpdb->update($table_item, array("title" => $title), array("id" => $download_id));
            }
        }
    }
    $contact_form = do_shortcode("[contact-form-7 id=\"{$contact_form_id}\" \"{$title}\"]");
    if (strpos($contact_form, 'contact-form-7 404') !== false) {
        $contact_form = do_shortcode("[contact-form id=\"{$contact_form_id}\" \"{$title}\"]");
    }
    // add checkboxes if count is more than one
    $hidden = get_option('email_before_download_hidden_form');
    if ($hidden_form != NULL) {
        $hidden = $hidden_form == 'yes';
    }
    if (count($dldArray) > 1) {
        if ($hidden) {
            $doc = new DOMDocument();
            $doc->loadXML(xml_character_encode($contact_form));
            $form = $doc->getElementsByTagName('form')->item(0);
            $form_children = array();
            $domElemsToRemove = array();
            foreach ($form->childNodes as $child) {
                $domElemsToRemove[] = $child;
            }
            foreach ($domElemsToRemove as $child) {
                $form_children[] = $form->removeChild($child);
            }
            $f = $doc->createDocumentFragment();
            if (strpos($contact_form, "<ebd_left />") !== false) {
                $f->appendXML($chekboxesL);
            } else {
                $f->appendXML($chekboxes);
            }
            $form->appendChild($f);
            $hidden_css = 'display:none;';
            $css_option = get_option('email_before_hidden_div_css');
            if ($css_option) {
                $hidden_css = $css_option;
            }
            $hidden_div = $doc->createDocumentFragment();
            $hidden_div->appendXML('<div  id="downloadinputform" style="' . $hidden_css . '" />');
            $hidden_div = $form->appendChild($hidden_div);
            foreach ($form_children as $child) {
                $hidden_div->appendChild($child);
            }
            $contact_form = $doc->saveHTML();
            $js = '<script>
       function countChecked() {
         var n = jQuery( "input:checked[name*=ebd_downloads]" ).length;
         if(n > 0) jQuery( "#downloadinputform" ).show();
         else jQuery( "#downloadinputform" ).hide();
         };
        jQuery(document).ready(function(){
         jQuery( "input[name*=ebd_downloads]" ).on( "click", countChecked );
         countChecked();
       });
       
      </script>';
            $contact_form .= $js;
        } else {
            $contact_form = str_replace("<ebd />", $chekboxes, $contact_form);
            $contact_form = str_replace("<ebd_left />", $chekboxesL, $contact_form);
        }
    } else {
        $contact_form = str_replace("<ebd />", "", $contact_form);
        $contact_form = str_replace("<ebd_left />", "", $contact_form);
    }
    if ($delivered_as != NULL) {
        $hf .= '<input type="hidden" name="delivered_as" value="' . $delivered_as . '" />';
    }
    //masked
    if ($masked != NULL) {
        $hf .= '<input type="hidden" name="masked" value="' . $masked . '" />';
    }
    if ($force_download != NULL) {
        $hf .= '<input type="hidden" name="force_download" value="' . $force_download . '" />';
    }
    if ($attachment != NULL) {
        $hf .= '<input type="hidden" name="attachment" value="' . $attachment . '" />';
    }
    if ($format != NULL) {
        $hf .= '<input type="hidden" name="format" value="' . $format . '" />';
    }
    if ($email_from != NULL) {
        $hf .= '<input type="hidden" name="email_from" value="' . urlencode($email_from) . '" />';
    }
    $hf .= '<input type="hidden" name="_wpcf7_download_id" value="' . $download_id . '" /></form>';
    $contact_form = str_replace("</form>", $hf, $contact_form);
    $wrap_in_div = get_option('email_before_download_wrap_in_div');
    $div_class = '';
    if (strlen(trim($wrap_in_div)) > 0) {
        $div_class = 'class="' . trim($wrap_in_div) . '"';
    }
    return "<br/>" . $contact_form . '<div id="wpm_download_' . $download_id . '" ' . $div_class . ' style="display:none;">  </div>';
}
Example #7
0
function &package_script_export($script_id, $indent = 3) {
	require_once(CACTI_BASE_PATH . "/lib/script/script_info.php");

	$xml = "";

	/*
	 * XML Tag: <script>
	 */

	/* obtain a list of all script specific fields */
	$script_fields = api_script_form_list();
	/* obtain a copy of this specfic script */
	$script = api_script_get($script_id);

	$_xml = "";
	foreach (array_keys($script_fields) as $field_name) {
		/* create an XML key for each script field */
		$_xml .= package_xml_tag_get($field_name, xml_character_encode($script[$field_name]), $indent + 2);
	}

	/* append the result onto the final XML string */
	$xml .= package_xml_tag_get("script", $_xml, $indent + 1, true);

	/*
	 * XML Tag: <fields>
	 */

	/* obtain a list of all script field specific fields */
	$script_field_fields = api_script_field_form_list();
	/* obtain a list of all script fields associated with this script */
	$script_fields = api_script_field_list($script_id);

	$_xml = "";
	if (sizeof($script_fields) > 0) {
		$i = 0;
		foreach ($script_fields as $script_field) {
			$__xml = "";
			foreach (array_keys($script_field_fields) as $field_name) {
				/* create an XML key for each script field field */
				$__xml .= package_xml_tag_get($field_name, xml_character_encode($script_field[$field_name]), $indent + 3);
			}

			/* append the result onto a temporary XML string */
			$_xml .= package_xml_tag_get("item_" . str_pad($i, 5, "0", STR_PAD_LEFT), $__xml, $indent + 2, true);

			$i++;
		}
	}

	/* append the result onto the final XML string */
	$xml .= package_xml_tag_get("fields", $_xml, $indent + 1, true);

	/* wrap the whole XML string into a 'script' tag and return it */
	$xml = package_xml_tag_get(package_hash_get($script_id, "script"), $xml, $indent, true);

	return $xml;
}