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; }
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; }
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();