Ejemplo n.º 1
0
 /**
  * Convert a numeric column index into an alpha column heading.
  * 
  * @params $return : string - Indicates how the xml should be output. D forces an xls download. S returns the xml as a string.
  * @author Daniel Razafsky
  * @return void/string - No value is returned unless $return is 'S' in which case the xml string representing the worksheet is returned.
  */
 function output($return = 'D', $nmfile)
 {
     // Create the workbook object that acts as the root element
     $workbook = create_element($this->_dom, 'Workbook');
     append_child($this->_dom, $workbook);
     append_child($workbook, create_attribute($this->_dom, 'xmlns', 'urn:schemas-microsoft-com:office:spreadsheet'));
     append_child($workbook, create_attribute($this->_dom, 'xmlns:o', 'urn:schemas-microsoft-com:office:office'));
     append_child($workbook, create_attribute($this->_dom, 'xmlns:x', 'urn:schemas-microsoft-com:office:excel'));
     append_child($workbook, create_attribute($this->_dom, 'xmlns:ss', 'urn:schemas-microsoft-com:office:spreadsheet'));
     append_child($workbook, create_attribute($this->_dom, 'xmlns:html', 'http://www.w3.org/TR/REC-html40'));
     // Add in the styles section (assuming we have styles)
     if (!empty($this->_styles)) {
         $styles = create_element($this->_dom, 'Styles');
         foreach ($this->_styles as $style_id => $cur_style) {
             append_child($styles, $cur_style);
         }
         append_child($workbook, $styles);
     }
     // Loop over all the worksheets adding them to the workbook
     foreach ($this->_worksheets as $cur_worksheet) {
         $worksheet = create_element($this->_dom, 'Worksheet');
         append_child($worksheet, create_attribute($this->_dom, 'ss:Name', $cur_worksheet->name));
         $table = create_element($this->_dom, 'Table');
         // Loop over all of the current worksheet's rows and append them
         foreach ($cur_worksheet->cells['row'] as $row_index => $cur_row) {
             $row = create_element($this->_dom, 'Row');
             append_child($row, create_attribute($this->_dom, 'ss:Index', $row_index));
             // Loop over all the columns in the row and append them
             foreach ($cur_row['col'] as $col_index => $cur_cell) {
                 $cell = create_element($this->_dom, 'Cell');
                 append_child($cell, create_attribute($this->_dom, 'ss:Index', $col_index));
                 if (!empty($cur_cell['style'])) {
                     append_child($cell, create_attribute($this->_dom, 'ss:StyleID', $cur_cell['style']));
                 }
                 if (!empty($cur_cell['formula'])) {
                     if ('=' != substr($cur_cell['formula'], 0, 1)) {
                         $cur_cell['formula'] = '=' . $cur_cell['formula'];
                     }
                     append_child($cell, create_attribute($this->_dom, 'ss:Formula', $cur_cell['formula']));
                 }
                 $data = create_element($this->_dom, 'Data');
                 append_child($data, create_text_node($this->_dom, $cur_cell['data']));
                 append_child($data, create_attribute($this->_dom, 'ss:Type', !empty($cur_cell['type']) ? $cur_cell['type'] : 'String'));
                 // We do still want to set an empty data element for the cell though
                 append_child($cell, $data);
                 append_child($row, $cell);
             }
             append_child($table, $row);
         }
         // Add the table to the workshet
         append_child($worksheet, $table);
         // Let's not forget to add the worksheet to the workbook
         append_child($workbook, $worksheet);
     }
     switch ($return) {
         case 'S':
             return save_xml($this->_dom);
             break;
         case 'D':
         default:
             $export_file = 'data_' . str_replace("-", "_", $nmfile) . '.xls';
             ini_set('zlib.output_compression', 'Off');
             header('Pragma: public');
             header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
             // Date in the past
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
             header('Cache-Control: no-store, no-cache, must-revalidate');
             // HTTP/1.1
             header('Cache-Control: pre-check=0, post-check=0, max-age=0');
             // HTTP/1.1
             header('Pragma: no-cache');
             header('Expires: 0');
             header('Content-Transfer-Encoding: none');
             header('Content-Type: application/vnd.ms-excel;');
             // This should work for IE & Opera
             header('Content-type: application/x-msexcel');
             // This should work for the rest
             header('Content-Disposition: attachment; filename="' . basename($export_file) . '"');
             $CI =& get_instance();
             $CI->output->append_output(save_xml($this->_dom));
             break;
     }
 }
Ejemplo n.º 2
0
                    $forum_xml = $forums_xml->addChild('forum');
                    $forum_xml->addChild('id', $cur_forum['id']);
                    $forum_xml->addChild('name', $cur_forum['forum_name']);
                    $forum_xml->addChild('cat_id', $cur_forum['cat_id']);
                    $forum_xml->addChild('sort_position', $cur_forum['disp_position']);
                    $forum_xml->addChild('description', $cur_forum['forum_desc']);
                }
                $result = $db->query('SELECT * FROM ' . $db->prefix . 'categories') or error('Failed to get categories', __FILE__, __LINE__, $db->error());
                $categories_xml = $xml->addChild('categories');
                while ($cur_category = $db->fetch_assoc($result)) {
                    $category_xml = $categories_xml->addChild('category');
                    $category_xml->addChild('id', $cur_category['id']);
                    $category_xml->addChild('name', $cur_category['cat_name']);
                    $category_xml->addChild('sort_position', $cur_category['disp_position']);
                }
                save_xml($xml);
                redirect('converter.php?completed', 'Posts completed');
                break;
            default:
                message('Invalid data given');
        }
    } else {
        if (file_exists(FORUM_CACHE_DIR . 'converter.xml')) {
            unlink(FORUM_CACHE_DIR . 'converter.xml');
        }
        ?>
	<h2>FutureBB Converter</h2>
	<p>This page will convert your forum database to a file that you can import into FutureBB. This will allow you to easily transition between the two forum systems.</p>
	<form action="converter.php" method="get">
		<p><input type="hidden" name="part" value="config" /><input type="submit" name="genfile" value="Start &rarr;" /></p>
	</form>
Ejemplo n.º 3
0
function create_guilds_xml($shard)
{
    global $time, $guilds_cache_timeout;
    $xml = simplexml_load_string('<guilds/>');
    $cache = $xml->addChild('cache');
    $cache->addAttribute('created', $time);
    $cache->addAttribute('expire', $time + $guilds_cache_timeout);
    $xml->addChild('shard', $shard);
    foreach (glob("/home/api/public_html/data/cache/guilds/guild_?????.xml") as $fn) {
        create_guild($xml, $fn, $shard);
    }
    //	$dirname = "tmp/$shard";
    //	if ($handle = opendir($dirname)) {
    //		while (false !== ($file = readdir($handle))) {
    //			if (end(explode(".", $file)) == 'xml') {
    //				create_guild($xml, "$dirname/$file");
    //			}
    //		}
    //		closedir($handle);
    //	}
    save_xml("guilds_{$shard}", $xml);
}
function addnode_xml($xml, $user, $song, $name, $set, $xmlFile)
{
    $root = $xml->documentElement;
    $rating = $xml->createElement('rating');
    $domUser = $xml->createAttribute('user');
    $domUser->value = $user;
    $rating->appendChild($domUser);
    $domSong = $xml->createAttribute('song');
    $domSong->value = htmlspecialchars($song, ENT_QUOTES, "ISO-8859-1");
    $rating->appendChild($domSong);
    $domName = $xml->createAttribute('name');
    $domName->value = htmlspecialchars($name, ENT_QUOTES, "ISO-8859-1");
    $rating->appendChild($domName);
    $domSet = $xml->createAttribute('set');
    $domSet->value = $set;
    $rating->appendChild($domSet);
    $root->appendChild($rating);
    save_xml($xml, $xmlFile);
}