2013-04-22, 04:55 AM
I'm trying to upload and parse an XML file to the server, which is generated by my wiki plugin and offered as a download. Problem - absolutely nothing is happening.
This is the contents of my import.php file:
Absolutely nothing happens, no error messages, nothing. The file is not inserted into the db. What am I doing wrong?
This is the contents of my import.php file:
<?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$lang->load('wiki');
$page->add_breadcrumb_item($lang->wiki_import, 'index.php?module=wiki-import');
$page->output_header($lang->wiki_import);
$sub_tabs['wiki_import'] = array(
'title' => $lang->wiki_import,
'link' => 'index.php?module=wiki-import',
'description' => $lang->wiki_import_description
);
$page->output_nav_tabs($sub_tabs, 'wiki_import');
if($mybb->request_method != 'POST')
{
$form = new Form('', 'POST', '', 1, '', false, '');
$form_container = new FormContainer($lang->wiki_import);
$form_container->output_row($lang->wiki_xml_file, $lang->wiki_xml_file_desc, $form->generate_file_upload_box('xml_file', "", array('id' => 'xml_file')));
$form_container->end();
$buttons = array();
$buttons[] = $form->generate_submit_button($lang->wiki_commit);
$form->output_submit_wrapper($buttons);
$form->end();
}
else
{
$info = pathinfo($_FILES['xml_file']['tmp_name']);
$extension = $info['extension'];
if($extension != 'xml')
{
flash_message($lang->wiki_invalid_file, 'error');
admin_redirect('index.php?module=wiki-import');
}
else
{
$string = file_get_contents($_FILES['xml_file']['tmp_name']);
$xml = new SimpleXMLElement($string);
foreach($xml->wiki->article as $article)
{
$query = "INSERT INTO " . TABLE_PREFIX . "wiki('authors','title','content','protected','lastauthor','lastauthorid','category') VALUES('" . $article->authors . "','" . $article->title . "','" . $article->content . "','" . $article->protected . "','" . $article->lastauthor . "','" . $article->lastauthorid . "','" . $article->category . "',)";
$db->write_query($query);
if($db->error_number > 0)
{
flash_message($lang->wiki_import_error, 'error');
admin_redirect('index.php?module=wiki-import');
}
else
{
flash_message($lang->wiki_import_success, 'success');
admin_redirect('index.php?module=wiki-import');
}
}
}
}
$page->output_footer();
?>
Absolutely nothing happens, no error messages, nothing. The file is not inserted into the db. What am I doing wrong?
Please don't PM me for support.