function wiki_import_content_XML(&$WS) { global $CFG, $COURSE, $infopages, $infopagesbis, $pagemaxim; check_dir_exists($CFG->dataroot . "/temp/unzip", true); $destination = $CFG->dataroot . "/temp/unzip"; unzip_file($WS->path, $destination, false); //take the .xml file $filelist = list_directories_and_files("{$CFG->dataroot}/temp/unzip"); $atachfiles = null; foreach ($filelist as $file) { $extension = explode(".", $file); $num = count($extension) - 1; if ($extension[$num] == "xml") { $goodfile = $file; } else { $atachfiles[] = $file; } } //import $xml = new XMLFile(); $file_name = $CFG->dataroot . "/temp/unzip/" . $goodfile; $xml_file = fopen("{$file_name}", "r"); $xml->read_file_handle($xml_file); $numRows = $xml->roottag->num_subtags(); //sobra //array where to save the name of the pages that we have to import their history $infopages = null; $wiki_content = wiki_pass_XML_to_Array($xml); wiki_validate_and_insert_content($wiki_content, $WS); //close the xml file that is still open fclose($xml_file); //import the associated files if ($atachfiles != null) { wiki_import_atachment($atachfiles, $WS); } //delete the folder of the zip $filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/unzip"); foreach ($filelist2 as $file2) { unlink("{$CFG->dataroot}/temp/unzip/{$file2}"); } rmdir("{$CFG->dataroot}/temp/unzip"); }
function setConfig($domainName, $fields) { global $database, $db, $event; if (empty($domainName)) return false; $domainName = $db->escape($domainName); requireComponent('LZ.PHP.XMLWriter'); $xml = new XMLFile('stdout'); $xml->startGroup('config', array('version'=>BLOGLOUNGE_VERSION)); foreach ($fields as $field) { $xml->write('field', $field['value'], $field['isCDATA'], array('name'=>$field['name'], 'type'=>$field['type'])); } $xml->endGroup(); ob_start(); $xml->close(); $configxml = ob_get_clean(); $configxml = $db->escape($configxml); if ($result = ($db->exists("SELECT domain FROM {$database['prefix']}Exports WHERE domain='{$domainName}'")) ? $db->execute("UPDATE {$database['prefix']}Exports SET settings='{$configxml}' WHERE domain='{$domainName}'") : $db->execute("INSERT INTO {$database['prefix']}Exports (domain, settings) VALUES ('{$domainName}', '{$configxml}')")) { $event->createMap(); $event->on('Export.set', $fields); return true; } return false; }
function make_entry_xml() { global $row, $xml, $comment_arr, $count; $xml = new XMLFile(); $xml->create_root(); # necessary -- no root is created until requested $xml->roottag->name = 'PIVOTXML'; $xml->roottag->add_subtag('ENTRY', array()); $entrytag =& $xml->roottag->curtag; $entrytag->add_attribute('UID', $row['id']); $entrytag->add_attribute('CODE', $row['code']); $entrytag->add_subtag('TEMPLATE', array()); $entrytag->curtag->cdata = $row['template']; $entrytag->add_subtag('DATE', array()); $entrytag->curtag->cdata = $row['date']; $entrytag->add_subtag('USER', array()); $entrytag->curtag->cdata = $row['user']; $entrytag->add_subtag('TITLE', array()); $entrytag->curtag->cdata = html_entities($row['title']); $entrytag->add_subtag('SUBTITLE', array()); $entrytag->curtag->cdata = html_entities($row['subtitle']); $entrytag->add_subtag('INTRODUCTION', array()); $entrytag->curtag->cdata = html_entities($row['introduction'], 1); $entrytag->add_subtag('BODY', array()); $entrytag->curtag->cdata = html_entities($row['body']); $entrytag->add_subtag('MEDIA', array()); $entrytag->curtag->cdata = $row['media']; $entrytag->add_subtag('LINKS', array()); if (count($row['comments']) > 0) { foreach ($row['comments'] as $comment) { $entrytag->add_subtag('COMMENT', array()); $commtag =& $entrytag->curtag; // When we start using the Thread_code, use this.. //$commtag->add_attribute( 'THREAD_CODE', $comment['thread_code']); $commtag->add_attribute('THREAD_CODE', ""); $commtag->add_subtag('NAME', array()); $commtag->curtag->cdata = html_entities($comment['name']); $commtag->add_subtag('EMAIL', array()); $commtag->curtag->cdata = html_entities($comment['email']); $commtag->add_subtag('URL', array()); $commtag->curtag->cdata = html_entities($comment['url']); $commtag->add_subtag('IP', array()); $commtag->curtag->cdata = $comment['ip']; $commtag->add_subtag('DATE', array()); $commtag->curtag->cdata = $comment['date']; $commtag->add_subtag('COMMENT', array()); $commtag->curtag->cdata = html_entities($comment['comment'], 1); } // foreach } // if $filename = str_replace("blog-", "entry", add_code_padding($row['code']) . ".php"); $fh = fopen("db/" . $filename, 'w'); $xml->write_file_handle($fh); fclose($fh); $xml->cleanup(); debug("writexml - {$filename}"); }
function read_entry($filename, $updateindex = TRUE) { global $global_pref; $xml = new XMLFile(); if ($filename == "") { $filename = $this->entry['filename']; } //debug("read entry: $filename". ( ($updateindex) ? "(T)" : "(F)")); if ($this->entry['filename'] == "ROOT") { debug("root lezen"); $this->entry['template'] = "weblog.html"; return; } @($fh = fopen($filename, 'r')); if ($fh == false) { piv_error("File Does not Exist!", "One of the xml files needed ({$filename}) could not be found. <br /><br />This can normally be fixed by recreating the index-file. Click <a href='reindex.php'>reindex</a> to do so now, and then go <a href='javascript:history.go(-1)'>back</a> to the last page.", 0); } $xml->read_file_handle($fh); fclose($fh); $row_entrypoint =& $xml->roottag->tags[0]; $row =& $xml->roottag->tags[0]->make_array(); $this->entry['code'] = rem_code_padding($row_entrypoint->attributes['CODE']); $this->entry['id'] = $this->set_id(); @($this->entry['category'] = trim($row_entrypoint->attributes['CATEGORY'])); debug("leescat2: " . $this->entry['category']); $this->entry['template'] = $row['template']; $this->entry['date'] = $row['date']; $this->entry['user'] = $row['user']; $this->entry['title'] = rem_entities($row['title']); $this->entry['subtitle'] = rem_entities($row['subtitle']); $this->entry['introduction'] = rem_entities($row['introduction']); $this->entry['body'] = rem_entities($row['body']); $this->entry['media'] = $row['media']; $this->entry['links'] = $row['links']; $this->entry['url'] = $this['url']; $this->entry['filename'] = $filename; unset($commnames); if (isset($row['comment'])) { for ($i = 0; $i < count($row['comment']); $i++) { $row['comment'][$i]['name'] = substr(rem_entities($row['comment'][$i]['name']), 0, 30); $row['comment'][$i]['email'] = rem_entities($row['comment'][$i]['email']); $row['comment'][$i]['comment'] = rem_entities($row['comment'][$i]['comment']); $commnames[] = $row['comment'][$i]['name']; } $this->entry['comments'] = $row['comment']; $this->entry['commnames'] = implode(", ", array_unique($commnames)); $commcount = count($commnames); } else { unset($this->entry['comments']); $commcount = 0; } $this->entry['commcount'] = $commcount; if ($commcount == 0) { $commcount_str = $global_pref['commentsarr'][0]; $this->entry['commcount_str'] = str_replace("%num%", $global_pref['comments_numbersarr'][0], $commcount_str); } else { if ($commcount == 1) { $commcount_str = $global_pref['commentsarr'][1]; $this->entry['commcount_str'] = str_replace("%num%", $global_pref['comments_numbersarr'][1], $commcount_str); } else { if (isset($global_pref['comments_numbersarr'][$commcount])) { $num = $global_pref['comments_numbersarr'][$commcount]; } else { $num = $commcount; } $commcount_str = $global_pref['commentsarr'][2]; $this->entry['commcount_str'] = str_replace("%num%", $num, $commcount_str); } } if ($this->entry['media'] != "") { $media_lines = explode("#", $this->entry['media']); $i = 0; unset($this->entry['media']); foreach ($media_lines as $media_line) { @(list($file, $width, $height, $name) = explode("|", $media_line)); $i++; $this->entry['media'][] = array("file" => $file, "width" => $width, "height" => $height, "name" => $name); } } if ($this->entry['category'] == "") { $this->entry['category'] = "standard"; } $xml->cleanup(); $this->update_index(FALSE); // Sometimes the code is another number than the filename would suggest. If so, // this needs to be fixed, by renaming the file. if ($filename != $this->set_filename($this->entry['code'])) { debug("rename: " . $filename . " , ", $this->set_filename($this->entry['code'])); rename($filename, $this->set_filename($this->entry['code'])); } return TRUE; }
function refresh($type = 'recent', $file = true, $value = array()) { global $database, $db, $service; requireComponent('LZ.PHP.XMLWriter'); $rssDir = ROOT . '/cache/rss'; func::mkpath($rssDir); if (!is_dir($rssDir) || !is_writeable($rssDir)) return false; $config = new Settings; $rssCount = $config->feeditemsOnRss; $myURL = 'http://'.$_SERVER['HTTP_HOST'].$service['path']; if($file) { if($type == 'focus') { $xml = new XMLFile($rssDir.'/1_focus.xml'); } else if($type == 'category') { $xml = new XMLFile($rssDir.'/1_category_'.$value['id'].'.xml'); } else { $xml = new XMLFile($rssDir.'/1.xml'); } } else { $xml = new XMLFile('stdout'); } $xml->startGroup('rss', array('version'=>'2.0')); switch($type) { case 'focus': $title = htmlspecialchars($config->title) . ' : ' . _t('포커스 목록'); break; case 'category': $title = htmlspecialchars($config->title) . ' : ' . _f('%1에 대한 분류 검색결과',$value['name']); break; default: $title = htmlspecialchars($config->title); break; } $xml->startGroup('channel'); $xml->write('title', $title); $xml->write('link', htmlspecialchars($myURL)); $xml->write('description', htmlspecialchars($config->description)); $xml->write('language', $config->language); $xml->write('pubDate', date("r", time())); $xml->write('generator', BLOGLOUNGE.' '.BLOGLOUNGE_VERSION.' '.BLOGLOUNGE_NAME); if (!Validator::is_empty($config->logo)) { $xml->startGroup('image'); $xml->write('title', htmlspecialchars($config->title)); $xml->write('url', htmlspecialchars($myURL.'/cache/logo/'.$config->logo)); list($width, $height) = getimagesize(ROOT.'/cache/logo/'.$config->logo); $xml->write('width', $width); $xml->write('height', $height); $xml->write('description', ''); $xml->endGroup(); } if($type == 'focus') { $result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND focus='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}"); } else if($type == 'category') { $result = $db->query("SELECT i.title, i.permalink, i.author, i.description, i.tags, i.written FROM {$database['prefix']}FeedItems i LEFT JOIN {$database['prefix']}CategoryRelations c ON (c.item = i.id) WHERE i.allowRedistribute='y' AND i.visibility = 'y' AND c.category = {$value['id']} ORDER BY i.written DESC LIMIT 0,{$rssCount}"); } else { $result = $db->query("SELECT title, permalink, author, description, tags, written FROM {$database['prefix']}FeedItems WHERE allowRedistribute='y' AND visibility = 'y' ORDER BY written DESC LIMIT 0,{$rssCount}"); } if ($result) { while ($item = $db->fetch()) { $xml->startGroup('item'); $item->description = str_replace('/cache/images',$myURL.'/cache/images',$item->description); $xml->write('title', htmlspecialcharS($item->title)); $xml->write('link', htmlspecialchars($item->permalink)); $xml->write('description', htmlspecialchars($item->description)); foreach (explode(',', $item->tags) as $tag) { $xml->write('category', htmlspecialchars($tag)); } $xml->write('author', htmlspecialchars($item->author)); $xml->write('guid', htmlspecialchars($item->permalink)); $xml->write('pubDate', date("r", $item->written)); $xml->endGroup(); } } $xml->endAllGroups(); $xml->close(); return true; }
<?php define('ROOT', '../../../../..'); include ROOT . '/lib/includeForAdmin.php'; requireAdmin(); requireComponent('Bloglounge.Model.Users'); $owner = User::getById($session['id']); header("Content-type: application"); header("Content-Disposition: attachment; filename=".BLOGLOUNGE."Feeds_" . date("Ymd") . ".opml"); header("Content-Description: PHP4 Generated Data"); requireComponent('LZ.PHP.XMLWriter'); $xml = new XMLFile('stdout'); $xml->startGroup('opml', array('version'=>'1.0')); $xml->startGroup('head'); $xml->write('title', BLOGLOUNGE.' '.BLOGLOUNGE_NAME.' '._t('피드 목록')); $xml->write('ownerName', $owner['name']); $xml->write('ownerEmail', $owner['email']); $xml->endGroup(); $xml->startGroup('body'); $db->query("SELECT title, description, blogURL, xmlURL FROM {$database['prefix']}Feeds"); while ($item = $db->fetchArray()) { $xml->write('outline', '', false, array('text'=>$item['title'], 'description'=>$item['description'], 'htmlUrl'=>$item['blogURL'], 'title'=>$item['title'], 'type'=>'rss', 'version'=>'RSS', 'xmlUrl'=>$item['xmlURL'])); } $db->free(); $xml->endGroup();