<?
/*========================================*\
| Exero CMS |
|==========================================|
| http://ecms.getox.net |
|https://sourceforge.net/projects/exerocms/|
|==========================================|
| Exero CMS is released under the |
| GNU General Public License (GPL) |
| opensource.org/licenses/gpl-license.php |
\*========================================*/
require("global.php");
if(!checkadminsession()) {
print_login();
exit;
}
if(!adminpermissions("manageplugins")) {
print_no_permission();
exit;
}
$insideitem = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $pluginname, $title, $location, $code, $sql, $install, $uninstall, $plugindata, $db;
if ($insideitem) {
$tag = $name;
} elseif ($name == "INFO") {
$insideitem = "info";
} elseif ($name == "ITEM") {
$insideitem = "item";
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $pluginname, $title, $location, $code, $sql, $install, $uninstall, $plugindata, $db;
if($name == "INFO") {
//echo "$pluginname<br/>$install<br/>$uninstall<br/>";
$db->query("INSERT INTO ".TABLE_PREFIX."plugins VALUES('','$pluginname','$uninstall')");
$plugindata = $db->insert_id();
$insideitem = "";
}
if ($name == "ITEM") {
$query = "INSERT INTO ".TABLE_PREFIX."plugin_data VALUES('','$title','$location','$code','1','".$plugindata."')";
$db->query($query);
$title = "";
$location = "";
$code = "";
$insideitem = "";
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $pluginname, $title, $location, $code, $sql, $install, $uninstall, $plugindata;
if ($insideitem == "info") {
switch ($tag) {
case "NAME":
$pluginname .= $data;
break;
case "INSTALL":
$install .= $data;
break;
case "UNINSTALL":
$uninstall .= $data;
break;
}
}
if ($insideitem == "item") {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "LOCATION":
$location .= $data;
break;
case "CODE":
$code .= $data;
break;
}
}
}
if($_REQUEST['do'] == "files") {
print_cp_header("Plugin System");
print_form_header("plugins.php","plugins");
print_form_hiddenfield("do","upload");
print_table_header("Import","2");
print_form_upload("Plugin FIle","file");
print_form_submit("Import",2,0);
print_table_footer();
print_form_footer();
print_cp_footer();
} else if($_POST['do'] == "upload") {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($_FILES["file"]["tmp_name"],"r")
or print_error("Error reading XML data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
print_redirect("plugins.php","Plugin Imported.","Plugin Imported.");
}
?>