public static function resource($path, array $options) { $options = array_replace_recursive(["class" => null, "list_mode" => "list", "sql" => ["table" => null, "raw" => null, "primary_key" => "id"]], $options); $path = rtrim($path, "/") ?: "/"; $resource = $options["class"]; $table = $options["sql"]["table"]; $raw = $options["sql"]["raw"]; $pkey = $options["sql"]["primary_key"]; $sql_list = $raw ?: "SELECT * FROM {$table}"; $sql_single = strpos($sql_list, "WHERE") === false ? "{$sql_list} WHERE {$pkey}=:{$pkey}" : str_replace("WHERE ", "WHERE {$pkey}=:{$pkey} AND ", $sql_list); $sql_single .= " LIMIT 1"; // Ensure endpoint options sanity if (class_exists($resource, false) && ($table || $raw) && $pkey) { // List Route::on($path, function () use($resource, $table, $sql_list, $options) { $resource::setExposure($options["list_mode"]); return $resource::fromSQL($sql_list); }); // Single Route::on("{$path}/:id", function ($id) use($resource, $table, $pkey, $sql_single) { return ['data' => $resource::singleFromSQL($sql_single, ["{$pkey}" => $id]) ?: API::error("Not found", 404)]; }); // Projection short-hand Route::on("{$path}/:id/:parameter", function ($id, $parameter) use($resource, $table, $pkey, $sql_single) { Filter::add("api.{$resource}.getProjectionFields", function ($t) use($parameter) { return $parameter; }); return ['data' => $resource::singleFromSQL($sql_single, ["{$pkey}" => $id]) ?: API::error("Not found", 404)]; }); } }
/** * Test using a closure as a filter * * @return null */ public function testFilterAsClosure() { global $_GET; global $_POST; global $_REQUEST; global $_FILES; global $_SERVER; $validEmail = '*****@*****.**'; // create and register a Filter instance $filter = new Filter(); $filter->add('testVal', function ($value) { return 'returned: ' . $value; }); $input = new Input($filter); $input->set('get', 'testVal', $validEmail); $result = $input->get('testVal'); $this->assertEquals('returned: ' . $validEmail, $result); }
} return str_replace(array('`{{', '}}`'), array('{{', '}}'), $content); }, 30); /** * Other(s) * -------- * * I'm trying to not touching the source code of the Markdown plugin at all. * * [1]. Add bordered class for tables in content. * [2]. Add `rel="nofollow"` attribute in external links. * */ if ($config->html_parser) { Filter::add('content', function ($content) use($config) { return preg_replace(array('#<table>#', '#<a href="(?!' . preg_quote($config->url, '/') . '|javascript:|[\\.\\/\\?\\#])#'), array('<table class="table-bordered table-full-width">', '<a rel="nofollow" href="'), $content); return $content; }, 20); } /** * Set Page Metadata * ----------------- */ Weapon::add('meta', function () { $config = Config::get(); $speak = Config::speak(); $html = O_BEGIN . Cell::meta(null, null, array('charset' => $config->charset)) . NL; $html .= Cell::meta('viewport', 'width=device-width', array(), 2) . NL; if (isset($config->article->description)) { $description = strip_tags($config->article->description); } else { if (isset($config->page->description)) {
* [1]. / * */ Route::accept('/', function () use($config, $excludes) { Session::kill('search.query'); Session::kill('search.results'); $s = Get::articles(); if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) { $articles = Mecha::walk($articles, function ($path) use($excludes) { return Get::article($path, $excludes); }); } else { $articles = false; } Filter::add('pager:url', function ($url) { return Filter::apply('index:url', $url); }); Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug))); Shield::attach('page-home'); }, 110); /** * Route Hook: after * ----------------- */ Weapon::fire('routes_after'); /** * Do Routing * ---------- */ Route::execute(); /**
* Frog CMS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Frog CMS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Frog CMS. If not, see <http://www.gnu.org/licenses/>. * * Frog CMS has made an exception to the GNU General Public License for plugins. * See exception.txt for details and the full text. */ /** * The Textile plugin allows users to edit pages using the textile syntax. * * @package frog * @subpackage plugin.textile * * @author Philippe Archambault <*****@*****.**> * @version 1.0.0 * @since Frog version 0.9.0 * @license http://www.gnu.org/licenses/gpl.html GPL License * @copyright Philippe Archambault, 2008 */ Plugin::setInfos(array('id' => 'textile', 'title' => 'Textile filter', 'description' => 'Allows you to compose page parts or snippets using the Textile text filter.', 'version' => '1.0.0', 'website' => 'http://www.madebyfrog.com/', 'update_url' => 'http://www.madebyfrog.com/plugin-versions.xml')); Filter::add('textile', 'textile/filter_textile.php');
<?php Plugin::setInfos(array('id' => 'hello_world', 'title' => 'Hello world!', 'description' => 'Allows you to display "Hello World! where you want.', 'version' => '1.0.0', 'license' => 'GPL', 'author' => 'Martijn van der Kleijn', 'website' => 'http://www.wolfcms.org/', 'update_url' => 'http://www.siforster.net/plugin-versions.xml', 'require_wolf_version' => '0.5.0')); function hello() { echo 'Hello World!'; } Filter::add('hello_world', 'hello_world/filter_hello_world.php');
<?php function do_asset_version($url, $source) { $path = Asset::path($source); if ($path && strpos($path, '://') === false) { return $url . '?v=' . File::T($path); } return $url; } Filter::add('asset:url', 'do_asset_version');
<?php Weapon::add('shield_before', function () { $config = Config::get(); if ($config->comments->allow) { $comment_service_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize(); Config::set('plugins.comment_service_config', $comment_service_config); $active = $comment_service_config['service']; if ($s = Config::get($config->page_type)) { $active = isset($s->fields->comment_service) && trim($s->fields->comment_service) !== "" ? $s->fields->comment_service : $active; } if ($launch = File::exist(__DIR__ . DS . 'workers' . DS . $active . DS . 'launch.php')) { require $launch; } Filter::add('chunk:path', function ($path) use($active) { if ($active !== 0 && File::N($path) === 'comments') { return __DIR__ . DS . 'workers' . DS . $active . DS . 'comments.php'; } return $path; }); } });
$config->html_minifier = true; Config::set('html_minifier', $config->html_minifier); $content = Converter::detractSkeleton($content); } // Minify URL if (isset($c['url_minifier']) && Text::check($content)->has('="' . $url)) { $content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content); } // Minify Embedded CSS if (isset($c['css_minifier'])) { $content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c, $url) { $css = Converter::detractShell($matches[2]); if (isset($c['url_minifier'])) { $css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css); } return '<style' . $matches[1] . $css . '</style>'; }, $content); } // Minify Embedded JavaScript if (isset($c['js_minifier'])) { $content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) { $js = Converter::detractSword($matches[2]); return '<script' . $matches[1] . $js . '</script>'; }, $content); } return $content; } if ($config->url_path === $config->manager->slug . '/login' || $config->page_type !== 'manager') { // Apply `do_minify` filter Filter::add('shield:input', 'do_minify', 1); }
<?php function do_shortcode_php($content) { if (strpos($content, '{{php}}') === false) { return $content; } global $config, $speak; return preg_replace_callback('#(?<!`)\\{\\{php\\}\\}(?!`)([\\s\\S]*?)(?<!`)\\{\\{\\/php\\}\\}(?!`)#', function ($matches) use($config, $speak) { return Converter::phpEval($matches[1], array('config' => $config, 'speak' => $speak)); }, $content); } if (!Guardian::happy() || Guardian::happy(1)) { Filter::add('shortcode', 'do_shortcode_php', 20.1); } // Create a new comment if (!Guardian::happy(1)) { // Disallow `{{php}}` shortcode in comment to prevent PHP script injection Filter::add('request:comment', function ($lot) { if (isset($lot['message'])) { $lot['message'] = str_replace(array('{{php}}', '{{/php}}'), "", $lot['message']); } return $lot; }); }
<?php Filter::add(array('plugin:shortcode', 'shield:shortcode'), function ($content) use($config, $speak) { if (strpos($content, '<!-- block:') === false) { return $content; } $form = '--- <form class="form-donate" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input name="cmd" type="hidden" value="_s-xclick"> <input name="hosted_button_id" type="hidden" value="TNVGH7NQ7E4EU"> <input name="submit" type="image" class="help" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAAAaCAMAAAANMMsbAAABQVBMVEUAAAD/mTP/qigAM2b/tUL/wWH/7Mj/79L/8tv/zYD/9uX/2Z7/+e7+6cD/5b3+57r//fj/8dv+5rT/rzP/rC3+5K/+4KX+4ar+36H+0oT/sTj/sz0gSW/+tUJgdH5AUVb/t0i+uaCOlIpAXnUQPmtwgIW+qnx/g3X/x2wQOmKAb0fu266uq5een49/i4kgQl//vln/u06vhj3PljjvpjL/6MPOv5dQan0QPmr/w2W/jjv/4rLe0Knu1qPOwJ3+2pe+tZaeoZRAYHv+zXowVHMwUWwwSltAUVhQWVTu3rr/3KjOxajey5+epJ7/1JN/iYT+zn2OjHdgb3FAW24gR2ogQl5gYFBwaE2ff0SPdkO/kEDfnzn/3Kfu1J1/jpO+tJKuqpF/jZCelnlweXNQZW9wZ0uPeUmffT//sju/jDjfmzAzmEmSAAAAAXRSTlMAQObYZgAAAilJREFUeNq1lmlX2kAUhgmvKNpaW7KRGmNYJWHfQUAQUHC37t339f//gN4JSIFUPyXPOblz5705z5kTPgyeCZxjeObh6u/8zx1hpZHgZtWJpacO4l/mptzyisOUuYm74XecRW7sVpZcoDGy8+VFN8hbB/et2jkBoX44WH2cg5OHZ9aPKtTX7MSgdrtRVNce5Uj9/PDwXKCD/8rLARtdhAKBZhRHbBMKJcdxMtQMTCVVpKyQ3rXjW+c83EY+IdoAklRjCIvibhRAzMoy1KbGya4oskUTWag2bQYlv0FyXdd78hw7UNmSQUZOo5ZO9ZGmDP2UhojcQi0VRk0+jgGZnTD6HQ3VeUM7r+vs5IQvKM0QhsYWOrmkoiNJn1CV0lBbVGhAVABJ6iAiSTUcSy3azdJjVpKvMxYS7eAUGsJsUVGpQKXmIyKUnY0G7zUVoCB4hliwQl0kAgSnaPd0S0ryl2P0xLlyzx7iVF/hSonj0uourMwql/gW38JXRbnAF5pfbTGUCYncvZHkAm8H4PnSD+AN/xbZEl8yqAPGA/YMcMfzWRTZnOeLBf4/CCT3Cja2MeKO+gH2zSxuKNsXRiWL4RDYFgTgtiAMMbg1UBTseDkP2W0UNhnmH9aXvhu4Nln2elx+XxumuVn0ek0DP72lGwO0sUNuJncJkpN9wRXIbcl9LkDykT237Dg57t/t/MRh6tOXqH74zEEO9bn7P3dafuEI5dPJJ3H1T9Ff6nuMWGU5acwAAAAASUVORK5CYII=" alt="PayPal – The safer, easier way to pay online!" title="' . Text::parse($speak->manager->description_donate, '->encoded_html') . '"> <img alt="" src="https://www.paypalobjects.com/id_ID/i/scr/pixel.gif" width="1" height="1"> </form>'; return str_replace('<!-- block:donate -->', $form, $content); });
// HTML output manipulation Filter::add('chunk:output', function ($content, $path) use($config, $speak) { $name = File::N($path); // Add an icon to the log in form button if ($name === 'page.body' && Route::is($config->manager->slug . '/login')) { return str_replace('>' . $speak->login . '</button>', '><i class="fa fa-key"></i> ' . trim(strip_tags($speak->login)) . '</button>', $content); } // Add an icon to the older and newer link text if ($name === 'pager') { $content = str_replace('>' . $speak->newer . '</a>', '><i class="fa fa-angle-left"></i> ' . trim(strip_tags($speak->newer)) . '</a>', $content); $content = str_replace('>' . $speak->older . '</a>', '>' . trim(strip_tags($speak->older)) . ' <i class="fa fa-angle-right"></i></a>', $content); } // Add an icon to the article date if ($name === 'article.time') { $content = str_replace('<time ', '<i class="fa fa-calendar"></i> <time ', $content); } // Add an icon to the comments title if ($name === 'comments.header') { $content = str_replace('<h3>', '<h3><i class="fa fa-comments"></i> ', $content); } // Add an icon to the comment form button if ($name === 'comment.form') { $content = str_replace('>' . $speak->publish . '</button>', '><i class="fa fa-check-circle"></i> ' . trim(strip_tags($speak->publish)) . '</button>', $content); } // Add an icon to the log in/out link if ($name === 'block.footer.bar') { $content = str_replace('>' . $speak->log_in . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_in)) . '</a>', $content); $content = str_replace('>' . $speak->log_out . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_out)) . '</a>', $content); } return $content; }); // Exclude these fields on index, tag, archive, search page ...
return $speak->plugin_private_post->description; } $s = isset($results->fields->pass) ? $results->fields->pass : ""; if (strpos($s, ':') !== false) { $s = explode(':', $s, 2); if (isset($s[1])) { $speak->plugin_private_post->hint = ltrim($s[1]); } // override password hint $s = $s[0]; } $hash = md5($s . PRIVATE_POST_SALT); $html = Notify::read(false) . '<div class="overlay--' . File::B(__DIR__) . '"></div><form class="form--' . File::B(__DIR__) . '" action="' . $config->url . '/' . File::B(__DIR__) . '/do:access" method="post">' . NL; $html .= TAB . Form::hidden('token', Guardian::token()) . NL; $html .= TAB . Form::hidden('_', $hash) . NL; $html .= TAB . Form::hidden('kick', $config->url_current) . NL; $html .= TAB . '<p>' . $speak->plugin_private_post->hint . '</p>' . NL; $html .= TAB . '<p>' . Form::text('access', "", $speak->password . '…', array('autocomplete' => 'off')) . ' ' . Form::button($speak->submit, null, 'submit') . '</p>' . NL; $html .= '</form>' . O_END; if ($results && isset($results->fields->pass) && trim($results->fields->pass) !== "") { if (!Guardian::happy() && Session::get('is_allow_post_access') !== $hash) { return $html; } } return $content; } $filters = Mecha::walk(glob(POST . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR), function ($v) { return File::B($v) . ':content'; }); Filter::add($filters, 'do_private_post', 30);
$parser->empty_element_suffix = ES; $parser->table_align_class_tmpl = 'text-%%'; // table align class, example: `<td class="text-right">` return preg_replace(array('#<table>#', '#<a href="(?!javascript:|[./?\\#]|' . preg_quote($config->url, '/') . ')#'), array('<table class="table-bordered table-full-width">', '<a rel="nofollow" href="'), trim($parser->transform($url . "\n\n" . $abbr . "\n\n" . $input))); }); function do_markdown($content, $results = array()) { global $config; $results = (object) $results; if (!isset($results->content_type) || $results->content_type === 'Markdown' || $results->content_type === 'Markdown Extra') { return Text::parse($content, '->html'); } return $content; } // Apply `do_markdown` filter Filter::add(array('content', 'message'), 'do_markdown', 1); // Set new `html_parser` type $config->html_parser->type = array_merge((array) $config->html_parser->type, array('Markdown' => 'Markdown Extra')); // --ibid Config::set('html_parser.type', $config->html_parser->type); // Re-write `comment_wizard` value if ($config->html_parser->active === 'Markdown' || $config->html_parser->active === 'Markdown Extra') { Config::set('speak.comment_wizard', $speak->__comment_wizard); } // Create a new comment if ($config->is->post && Request::method('post')) { if (isset($_POST['message'])) { // **Markdown Extra** does not support syntax to generate `del`, `ins` and `mark` tag $_POST['message'] = Text::parse($_POST['message'], '->text', '<br><del><ins><mark>', false); // Temporarily disallow image(s) in comment to prevent XSS $_POST['message'] = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $_POST['message']);
<?php /// Copyright (c) 2004-2012, Needlworks / Tatter Network Foundation /// All rights reserved. Licensed under the GPL. /// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT) $IV = array('GET' => array('command' => array('any', 'mandatory' => false, 'default' => 'block'), 'id' => array('id', 'mandatory' => false), 'mode' => array(array('ip', 'url', 'content', 'name', 'whiteurl')), 'value' => array('string', 'mandatory' => false))); require ROOT . '/library/preprocessor.php'; requireStrictRoute(); $isAjaxRequest = checkAjaxRequest(); $filter = new Filter(); if ($_GET['command'] == 'unblock') { if (empty($_GET['id'])) { $filter->type = $_GET['mode']; $filter->pattern = $_GET['value']; } else { $filter->id = $_GET['id']; } if ($filter->remove()) { $isAjaxRequest ? Respond::PrintResult(array('error' => 0)) : header("Location: " . $_SERVER['HTTP_REFERER']); } else { $isAjaxRequest ? Respond::PrintResult(array('error' => 1, 'msg' => POD::error())) : header("Location: " . $_SERVER['HTTP_REFERER']); } } else { $filter->type = $_GET['mode']; $filter->pattern = $_GET['value']; if ($filter->add()) { $isAjaxRequest ? Respond::PrintResult(array('error' => 0, 'id' => $filter->id)) : header("Location: " . $_SERVER['HTTP_REFERER']); } else { $isAjaxRequest ? Respond::PrintResult(array('error' => 1, 'msg' => POD::error())) : header("Location: " . $_SERVER['HTTP_REFERER']); } }
function importer($path, $node, $line) { global $blogid, $migrational, $items, $item; switch ($path) { case '/blog/setting': setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.')); $setting = new BlogSetting(); if (isset($node['title'][0]['.value'])) { $setting->title = $node['title'][0]['.value']; } if (isset($node['description'][0]['.value'])) { $setting->description = $node['description'][0]['.value']; } if (isset($node['banner'][0]['name'][0]['.value'])) { $setting->banner = $node['banner'][0]['name'][0]['.value']; } if (isset($node['useSloganOnPost'][0]['.value'])) { $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value']; } if (isset($node['postsOnPage'][0]['.value'])) { $setting->postsOnPage = $node['postsOnPage'][0]['.value']; } if (isset($node['postsOnList'][0]['.value'])) { $setting->postsOnList = $node['postsOnList'][0]['.value']; } if (isset($node['postsOnFeed'][0]['.value'])) { $setting->postsOnFeed = $node['postsOnFeed'][0]['.value']; } if (isset($node['publishWholeOnFeed'][0]['.value'])) { $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value']; } if (isset($node['acceptGuestComment'][0]['.value'])) { $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value']; } if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) { $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value']; } if (isset($node['language'][0]['.value'])) { $setting->language = $node['language'][0]['.value']; } if (isset($node['timezone'][0]['.value'])) { $setting->timezone = $node['timezone'][0]['.value']; } if (!$setting->save()) { user_error(__LINE__ . $setting->error); } if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) { Attachment::confirmFolder(); Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner)); Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner)); fclose($node['banner'][0]['content'][0]['.stream']); unset($node['banner'][0]['content'][0]['.stream']); } return true; case '/blog/category': setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.')); $category = new Category(); $category->name = $node['name'][0]['.value']; $category->priority = $node['priority'][0]['.value']; if (isset($node['root'][0]['.value'])) { $category->id = 0; } if (!$category->add()) { user_error(__LINE__ . $category->error); } if (isset($node['category'])) { for ($i = 0; $i < count($node['category']); $i++) { $childCategory = new Category(); $childCategory->parent = $category->id; $cursor =& $node['category'][$i]; $childCategory->name = $cursor['name'][0]['.value']; $childCategory->priority = $cursor['priority'][0]['.value']; if (!$childCategory->add()) { user_error(__LINE__ . $childCategory->error); } } } return true; case '/blog/post': setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.')); $post = new Post(); $post->id = $node['id'][0]['.value']; $post->slogan = @$node['.attributes']['slogan']; $post->visibility = $node['visibility'][0]['.value']; if (isset($node['starred'][0]['.value'])) { $post->starred = $node['starred'][0]['.value']; } else { $post->starred = 0; } $post->title = $node['title'][0]['.value']; $post->content = $node['content'][0]['.value']; $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml'; $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern'; $post->location = $node['location'][0]['.value']; $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null; $post->acceptcomment = $node['acceptComment'][0]['.value']; $post->accepttrackback = $node['acceptTrackback'][0]['.value']; $post->published = $node['published'][0]['.value']; if (isset($node['longitude'][0]['.value'])) { $post->longitude = $node['longitude'][0]['.value']; } if (isset($node['latitude'][0]['.value'])) { $post->latitude = $node['latitude'][0]['.value']; } $post->created = @$node['created'][0]['.value']; $post->modified = @$node['modified'][0]['.value']; if ($post->visibility == 'private' && intval($post->published) > $_SERVER['REQUEST_TIME'] || !empty($node['appointed'][0]['.value']) && $node['appointed'][0]['.value'] == 'true') { // for compatibility of appointed entries $post->visibility = 'appointed'; } if ($post->slogan == '') { $post->slogan = 'Untitled' . $post->id; } if (!empty($node['category'][0]['.value'])) { $post->category = Category::getId($node['category'][0]['.value']); } if (isset($node['tag'])) { $post->tags = array(); for ($i = 0; $i < count($node['tag']); $i++) { if (!empty($node['tag'][$i]['.value'])) { array_push($post->tags, $node['tag'][$i]['.value']); } } } if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) { $post->content = nl2brWithHTML($post->content); } if (!$post->add()) { user_error(__LINE__ . $post->error); } if (isset($node['attachment'])) { for ($i = 0; $i < count($node['attachment']); $i++) { $attachment = new Attachment(); $attachment->parent = $post->id; $cursor =& $node['attachment'][$i]; $attachment->name = $cursor['name'][0]['.value']; $attachment->label = $cursor['label'][0]['.value']; $attachment->mime = @$cursor['.attributes']['mime']; $attachment->size = $cursor['.attributes']['size']; $attachment->width = $cursor['.attributes']['width']; $attachment->height = $cursor['.attributes']['height']; $attachment->enclosure = @$cursor['enclosure'][0]['.value']; $attachment->attached = $cursor['attached'][0]['.value']; $attachment->downloads = @$cursor['downloads'][0]['.value']; if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } else { if ($cursor['name'][0]['.value'] != $attachment->name) { $post2 = new Post(); if ($post2->open($post->id, 'id, content')) { $post2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $post2->content); $post2->loadTags(); $post2->update(); $post2->close(); } unset($post2); } } if (!empty($cursor['content'][0]['.stream'])) { Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name)); Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name)); fclose($cursor['content'][0]['.stream']); unset($cursor['content'][0]['.stream']); } } } if (isset($node['comment'])) { for ($i = 0; $i < count($node['comment']); $i++) { $comment = new Comment(); $comment->entry = $post->id; $cursor =& $node['comment'][$i]; $comment->name = $cursor['commenter'][0]['name'][0]['.value']; if (!empty($cursor['id'][0]['.value'])) { $comment->id = $cursor['id'][0]['.value']; } if (!empty($cursor['commenter'][0]['.attributes']['id'])) { $comment->commenter = $cursor['commenter'][0]['.attributes']['id']; } if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) { $comment->homepage = $cursor['commenter'][0]['homepage'][0]['.value']; } if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) { $comment->ip = $cursor['commenter'][0]['ip'][0]['.value']; } if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) { $comment->openid = $cursor['commenter'][0]['openid'][0]['.value']; } $comment->password = $cursor['password'][0]['.value']; $comment->secret = $cursor['secret'][0]['.value']; $comment->written = $cursor['written'][0]['.value']; if (isset($cursor['longitude'][0]['.value'])) { $comment->longitude = $cursor['longitude'][0]['.value']; } if (isset($cursor['latitude'][0]['.value'])) { $comment->latitude = $cursor['latitude'][0]['.value']; } $comment->content = $cursor['content'][0]['.value']; if (!empty($cursor['isFiltered'][0]['.value'])) { $comment->isfiltered = $cursor['isFiltered'][0]['.value']; } if (!$comment->add()) { user_error(__LINE__ . $comment->error); } if (isset($node['comment'][$i]['comment'])) { for ($j = 0; $j < count($node['comment'][$i]['comment']); $j++) { $childComment = new Comment(); $childComment->entry = $post->id; $childComment->parent = $comment->id; $cursor =& $node['comment'][$i]['comment'][$j]; if (!empty($cursor['id'][0]['.value'])) { $childComment->id = $cursor['id'][0]['.value']; } if (!empty($cursor['commenter'][0]['.attributes']['id'])) { $childComment->commenter = $cursor['commenter'][0]['.attributes']['id']; } $childComment->name = $cursor['commenter'][0]['name'][0]['.value']; if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) { $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value']; } if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) { $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value']; } if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) { $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value']; } $childComment->password = $cursor['password'][0]['.value']; $childComment->secret = $cursor['secret'][0]['.value']; $childComment->written = $cursor['written'][0]['.value']; if (isset($cursor['longitude'][0]['.value'])) { $comment->longitude = $cursor['longitude'][0]['.value']; } if (isset($cursor['latitude'][0]['.value'])) { $comment->latitude = $cursor['latitude'][0]['.value']; } $childComment->content = $cursor['content'][0]['.value']; if (!empty($cursor['isFiltered'][0]['.value'])) { $childComment->isfiltered = $cursor['isFiltered'][0]['.value']; } if (!$childComment->add()) { user_error(__LINE__ . $childComment->error); } } } } } if (isset($node['trackback'])) { for ($i = 0; $i < count($node['trackback']); $i++) { $trackback = new Trackback(); $trackback->entry = $post->id; $cursor =& $node['trackback'][$i]; $trackback->url = $cursor['url'][0]['.value']; $trackback->site = $cursor['site'][0]['.value']; $trackback->title = $cursor['title'][0]['.value']; $trackback->excerpt = @$cursor['excerpt'][0]['.value']; if (!empty($cursor['ip'][0]['.value'])) { $trackback->ip = $cursor['ip'][0]['.value']; } if (!empty($cursor['received'][0]['.value'])) { $trackback->received = $cursor['received'][0]['.value']; } if (!empty($cursor['isFiltered'][0]['.value'])) { $trackback->isFiltered = $cursor['isFiltered'][0]['.value']; } if (!$trackback->add()) { user_error(__LINE__ . $trackback->error); } } } if (isset($node['logs'][0]['trackback'])) { for ($i = 0; $i < count($node['logs'][0]['trackback']); $i++) { $log = new TrackbackLog(); $log->entry = $post->id; $cursor =& $node['logs'][0]['trackback'][$i]; $log->url = $cursor['url'][0]['.value']; if (!empty($cursor['sent'][0]['.value'])) { $log->sent = $cursor['sent'][0]['.value']; } if (!$log->add()) { user_error(__LINE__ . $log->error); } } } return true; case '/blog/page': setProgress($item++ / $items * 100, _t('페이지를 복원하고 있습니다.')); $page = new Page(); $page->id = $node['id'][0]['.value']; $page->slogan = @$node['.attributes']['slogan']; $page->visibility = $node['visibility'][0]['.value']; if (isset($node['starred'][0]['.value'])) { $page->starred = $node['starred'][0]['.value']; } else { $page->starred = 0; } $page->title = $node['title'][0]['.value']; $page->content = $node['content'][0]['.value']; $page->contentformatter = isset($node['content']['.attributes']['formatter']) ? $node['content']['.attributes']['formatter'] : getDefaultFormatter(); $page->contenteditor = isset($node['content']['.attributes']['editor']) ? $node['content']['.attributes']['editor'] : getDefaultEditor(); $page->published = $node['published'][0]['.value']; $page->created = @$node['created'][0]['.value']; $page->modified = @$node['modified'][0]['.value']; if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) { $page->content = nl2brWithHTML($page->content); } if (!$page->add()) { user_error(__LINE__ . $page->error); } if (isset($node['attachment'])) { for ($i = 0; $i < count($node['attachment']); $i++) { $attachment = new Attachment(); $attachment->parent = $page->id; $cursor =& $node['attachment'][$i]; $attachment->name = $cursor['name'][0]['.value']; $attachment->label = $cursor['label'][0]['.value']; $attachment->mime = @$cursor['.attributes']['mime']; $attachment->size = $cursor['.attributes']['size']; $attachment->width = $cursor['.attributes']['width']; $attachment->height = $cursor['.attributes']['height']; $attachment->enclosure = @$cursor['enclosure'][0]['.value']; $attachment->attached = $cursor['attached'][0]['.value']; $attachment->downloads = @$cursor['downloads'][0]['.value']; if (Attachment::doesExist($attachment->name)) { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } $page2 = new Page(); if ($page2->open($page->id, 'id, content')) { $page2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $page2->content); $page2->update(); $page2->close(); } unset($page2); } else { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } } if (!empty($cursor['content'][0]['.stream'])) { Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name)); Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name)); fclose($cursor['content'][0]['.stream']); unset($cursor['content'][0]['.stream']); } } } return true; case '/blog/notice': setProgress($item++ / $items * 100, _t('공지를 복원하고 있습니다.')); $notice = new Notice(); $notice->id = $node['id'][0]['.value']; $notice->slogan = @$node['.attributes']['slogan']; $notice->visibility = $node['visibility'][0]['.value']; if (isset($node['starred'][0]['.value'])) { $notice->starred = $node['starred'][0]['.value']; } else { $notice->starred = 0; } $notice->title = $node['title'][0]['.value']; $notice->content = $node['content'][0]['.value']; $notice->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : getDefaultFormatter(); $notice->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : getDefaultEditor(); $notice->published = intval($node['published'][0]['.value']); $notice->created = @$node['created'][0]['.value']; $notice->modified = @$node['modified'][0]['.value']; if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) { $notice->content = nl2brWithHTML($notice->content); } if (!$notice->add()) { user_error(__LINE__ . $notice->error); } if (isset($node['attachment'])) { for ($i = 0; $i < count($node['attachment']); $i++) { $attachment = new Attachment(); $attachment->parent = $notice->id; $cursor =& $node['attachment'][$i]; $attachment->name = $cursor['name'][0]['.value']; $attachment->label = $cursor['label'][0]['.value']; $attachment->mime = @$cursor['.attributes']['mime']; $attachment->size = $cursor['.attributes']['size']; $attachment->width = $cursor['.attributes']['width']; $attachment->height = $cursor['.attributes']['height']; $attachment->enclosure = @$cursor['enclosure'][0]['.value']; $attachment->attached = $cursor['attached'][0]['.value']; $attachment->downloads = @$cursor['downloads'][0]['.value']; if (Attachment::doesExist($attachment->name)) { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } $notice2 = new Notice(); if ($notice2->open($notice->id, 'id, content')) { $notice2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $notice2->content); $notice2->update(); $notice2->close(); } unset($notice2); } else { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } } if (!empty($cursor['content'][0]['.stream'])) { Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name)); Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name)); fclose($cursor['content'][0]['.stream']); unset($cursor['content'][0]['.stream']); } } } return true; case '/blog/keyword': setProgress($item++ / $items * 100, _t('키워드를 복원하고 있습니다.')); $keyword = new Keyword(); $keyword->id = $node['id'][0]['.value']; $keyword->visibility = $node['visibility'][0]['.value']; if (isset($node['starred'][0]['.value'])) { $keyword->starred = $node['starred'][0]['.value']; } else { $keyword->starred = 0; } $keyword->name = $node['name'][0]['.value']; $keyword->description = $node['description'][0]['.value']; $keyword->descriptionEditor = isset($node['description'][0]['.attributes']['editor']) ? $node['description'][0]['.attributes']['editor'] : getDefaultEditor(); $keyword->descriptionFormatter = isset($node['description'][0]['.attributes']['formatter']) ? $node['description'][0]['.attributes']['formatter'] : getDefaultFormatter(); $keyword->published = intval($node['published'][0]['.value']); $keyword->created = @$node['created'][0]['.value']; $keyword->modified = @$node['modified'][0]['.value']; if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) { $keyword->description = nl2brWithHTML($keyword->description); } if (!$keyword->add()) { user_error(__LINE__ . $keyword->error); } if (isset($node['attachment'])) { for ($i = 0; $i < count($node['attachment']); $i++) { $attachment = new Attachment(); $attachment->parent = $keyword->id; $cursor =& $node['attachment'][$i]; $attachment->name = $cursor['name'][0]['.value']; $attachment->label = $cursor['label'][0]['.value']; $attachment->mime = @$cursor['.attributes']['mime']; $attachment->size = $cursor['.attributes']['size']; $attachment->width = $cursor['.attributes']['width']; $attachment->height = $cursor['.attributes']['height']; $attachment->enclosure = @$cursor['enclosure'][0]['.value']; $attachment->attached = $cursor['attached'][0]['.value']; $attachment->downloads = @$cursor['downloads'][0]['.value']; if (Attachment::doesExist($attachment->name)) { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } $keyword2 = new Keyword(); if ($keyword2->open($keyword->id, 'id, content')) { $keyword2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $keyword2->content); $keyword2->update(); $keyword2->close(); } unset($keyword2); } else { if (!$attachment->add()) { user_error(__LINE__ . $attachment->error); } } if (!empty($cursor['content'][0]['.stream'])) { Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name)); Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name)); fclose($cursor['content'][0]['.stream']); unset($cursor['content'][0]['.stream']); } } } return true; case '/blog/linkCategories': setProgress($item++ / $items * 100, _t('링크 카테고리를 복원하고 있습니다.')); $linkCategory = new LinkCategories(); $linkCategory->name = $node['name'][0]['.value']; $linkCategory->priority = $node['priority'][0]['.value']; $linkCategory->visibility = !isset($node['visibility'][0]['.value']) || empty($node['visibility'][0]['.value']) ? 2 : $node['visibility'][0]['.value']; $linkCategory->id = LinkCategories::getId($linkCategory->name); if ($linkCategory->id) { if (!$linkCategory->update()) { user_error(__LINE__ . $linkCategory->error); } } else { if (!$linkCategory->add()) { user_error(__LINE__ . $linkCategory->error); } } return true; case '/blog/link': setProgress($item++ / $items * 100, _t('링크를 복원하고 있습니다.')); $link = new Link(); $link->category = empty($node['category'][0]['.value']) ? 0 : $node['category'][0]['.value']; $link->url = $node['url'][0]['.value']; $link->title = $node['title'][0]['.value']; if (!empty($node['feed'][0]['.value'])) { $link->feed = $node['feed'][0]['.value']; } if (!empty($node['registered'][0]['.value'])) { $link->registered = $node['registered'][0]['.value']; } if (!empty($node['xfn'][0]['.value'])) { $link->xfn = $node['xfn'][0]['.value']; } $link->id = Link::getId($link->url); if ($link->id) { if (!$link->update()) { user_error(__LINE__ . $link->error); } } else { if (!$link->add()) { user_error(__LINE__ . $link->error); } } return true; case '/blog/logs/referer': setProgress($item++ / $items * 100, _t('리퍼러 로그를 복원하고 있습니다.')); $log = new RefererLog(); if (isset($node['path'][0]['.value'])) { $log->url = $node['path'][0]['.value']; } else { $log->url = $node['url'][0]['.value']; } $log->referred = $node['referred'][0]['.value']; if (!$log->add(false)) { user_error(__LINE__ . $log->error); } return true; case '/blog/commentsNotified/comment': setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.')); $cmtNotified = new CommentNotified(); $cmtNotified->id = $node['id'][0]['.value']; $cursor =& $node['commenter'][0]; $cmtNotified->name = $cursor['name'][0]['.value']; $cmtNotified->homepage = $cursor['homepage'][0]['.value']; $cmtNotified->ip = $cursor['ip'][0]['.value']; $cmtNotified->entry = $node['entry'][0]['.value']; $cmtNotified->password = $node['password'][0]['.value']; $cmtNotified->content = $node['content'][0]['.value']; $cmtNotified->parent = $node['parent'][0]['.value']; $cmtNotified->secret = $node['secret'][0]['.value']; $cmtNotified->written = $node['written'][0]['.value']; $cmtNotified->modified = $node['modified'][0]['.value']; $cmtNotified->url = $node['url'][0]['.value']; $cmtNotified->isnew = $node['isNew'][0]['.value']; $site = new CommentNotifiedSiteInfo(); if (!$site->open("url = '{$node['site'][0]['.value']}'")) { $site->title = ''; $site->name = ''; $site->modified = 31536000; $site->url = $node['site'][0]['.value']; $site->add(); } $cmtNotified->siteid = $site->id; $site->close(); $cmtNotified->remoteid = $node['remoteId'][0]['.value']; $cmtNotified->entrytitle = !isset($node['entryTitle'][0]['.value']) || empty($node['entryTitle'][0]['.value']) ? 'No title' : $node['entryTitle'][0]['.value']; $cmtNotified->entryurl = $node['entryUrl'][0]['.value']; if (!$cmtNotified->add()) { user_error(__LINE__ . $cmtNotified->error); } return true; case '/blog/commentsNotifiedSiteInfo/site': setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.')); $cmtNotifiedSite = new CommentNotifiedSiteInfo(); if ($cmtNotifiedSite->open("url = '{$node['url'][0]['.value']}'")) { if (intval($node['modified'][0]['.value']) > intval($cmtNotifiedSite->modified)) { $cmtNotifiedSite->title = $node['title'][0]['.value']; $cmtNotifiedSite->name = $node['name'][0]['.value']; $cmtNotifiedSite->modified = $node['modified'][0]['.value']; } if (!$cmtNotifiedSite->update()) { user_error(__LINE__ . $cmtNotifiedSite->error); } } else { $cmtNotifiedSite->url = $node['url'][0]['.value']; $cmtNotifiedSite->title = $node['title'][0]['.value']; $cmtNotifiedSite->name = $node['name'][0]['.value']; $cmtNotifiedSite->modified = $node['modified'][0]['.value']; if (!$cmtNotifiedSite->add()) { user_error(__LINE__ . $cmtNotifiedSite->error); } } return true; case '/blog/statistics/referer': setProgress($item++ / $items * 100, _t('리퍼러 통계를 복원하고 있습니다.')); $statistics = new RefererStatistics(); $statistics->host = $node['host'][0]['.value']; $statistics->count = $node['count'][0]['.value']; if (!$statistics->add()) { user_error(__LINE__ . $statistics->error); } return true; case '/blog/statistics/visits': setProgress($item++ / $items * 100, _t('블로그 통계 정보를 복원하고 있습니다.')); $statistics = new BlogStatistics(); $statistics->visits = $node['.value']; if (!$statistics->add()) { user_error(__LINE__ . $statistics->error); } return true; case '/blog/statistics/daily': setProgress($item++ / $items * 100, _t('일별 통계 정보를 복원하고 있습니다.')); $statistics = new DailyStatistics(); $statistics->date = $node['date'][0]['.value']; $statistics->visits = $node['visits'][0]['.value']; if (!$statistics->add()) { user_error(__LINE__ . $statistics->error); } return true; case '/blog/skin': setProgress($item++ / $items * 100, _t('스킨 설정을 복원하고 있습니다.')); $setting = new SkinSetting(); if (false) { $setting->skin = $node['name'][0]['.value']; if (!$setting->save()) { user_error(__LINE__ . $setting->error); } $setting->skin = null; } $setting->entriesOnRecent = $node['entriesOnRecent'][0]['.value']; $setting->commentsOnRecent = $node['commentsOnRecent'][0]['.value']; $setting->trackbacksOnRecent = $node['trackbacksOnRecent'][0]['.value']; $setting->commentsOnGuestbook = $node['commentsOnGuestbook'][0]['.value']; $setting->tagsOnTagbox = $node['tagsOnTagbox'][0]['.value']; $setting->alignOnTagbox = $node['alignOnTagbox'][0]['.value']; $setting->expandComment = $node['expandComment'][0]['.value']; $setting->expandTrackback = $node['expandTrackback'][0]['.value']; if (!empty($node['recentNoticeLength'][0]['.value'])) { $setting->recentNoticeLength = $node['recentNoticeLength'][0]['.value']; } $setting->recentEntryLength = $node['recentEntryLength'][0]['.value']; $setting->recentTrackbackLength = $node['recentTrackbackLength'][0]['.value']; $setting->linkLength = $node['linkLength'][0]['.value']; $setting->showListOnCategory = $node['showListOnCategory'][0]['.value']; $setting->showListOnArchive = $node['showListOnArchive'][0]['.value']; if (isset($node['tree'])) { $cursor =& $node['tree'][0]; $setting->tree = $cursor['name'][0]['.value']; $setting->colorOnTree = $cursor['color'][0]['.value']; $setting->bgcolorOnTree = $cursor['bgColor'][0]['.value']; $setting->activecolorOnTree = $cursor['activeColor'][0]['.value']; $setting->activebgcolorOnTree = $cursor['activeBgColor'][0]['.value']; $setting->labelLengthOnTree = $cursor['labelLength'][0]['.value']; $setting->showValueOnTree = $cursor['showValue'][0]['.value']; } if (!$setting->save()) { user_error(__LINE__ . $setting->error); } return true; case '/blog/plugin': // setProgress($item++ / $items * 100, _t('플러그인 설정을 복원하고 있습니다.')); // $setting = new PluginSetting(); // $setting->name = $node['name'][0]['.value']; // $setting->setting = $node['setting'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); return true; case '/blog/personalization': // setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다.')); // $setting = new UserSetting(); // $setting->name = 'rowsPerPage'; // $setting->value = $node['rowsPerPage'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); // $setting->name = 'readerPannelVisibility'; // $setting->value = $node['readerPannelVisibility'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); // $setting->name = 'readerPannelHeight'; // $setting->value = $node['readerPannelHeight'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); // $setting->name = 'lastVisitNotifiedPage'; // $setting->value = $node['lastVisitNotifiedPage'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); return true; case '/blog/userSetting': // setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다')); // $setting = new UserSetting(); // $setting->name = $node['name'][0]['.value']; // $setting->value = $node['value'][0]['.value']; // if (!$setting->add()) // user_error(__LINE__ . $setting->error); return true; case '/blog/guestbook/comment': setProgress($item++ / $items * 100, _t('방명록을 복원하고 있습니다.')); $comment = new GuestComment(); $comment->name = $node['commenter'][0]['name'][0]['.value']; if (!empty($node['id'][0]['.value'])) { $comment->id = $node['id'][0]['.value']; } if (!empty($node['commenter'][0]['.attributes']['id'])) { $comment->commenter = $node['commenter'][0]['.attributes']['id']; } if (!empty($node['commenter'][0]['homepage'][0]['.value'])) { $comment->homepage = $node['commenter'][0]['homepage'][0]['.value']; } if (!empty($node['commenter'][0]['ip'][0]['.value'])) { $comment->ip = $node['commenter'][0]['ip'][0]['.value']; } if (!empty($node['commenter'][0]['openid'][0]['.value'])) { $comment->openid = $node['commenter'][0]['openid'][0]['.value']; } $comment->password = $node['password'][0]['.value']; $comment->secret = @$node['secret'][0]['.value']; $comment->written = $node['written'][0]['.value']; $comment->content = $node['content'][0]['.value']; if (!$comment->add()) { user_error(__LINE__ . $comment->error); } if (isset($node['comment'])) { for ($j = 0; $j < count($node['comment']); $j++) { $childComment = new GuestComment(); $childComment->parent = $comment->id; $cursor =& $node['comment'][$j]; $childComment->name = $cursor['commenter'][0]['name'][0]['.value']; if (!empty($cursor['id'][0]['.value'])) { $comment->id = $cursor['id'][0]['.value']; } if (!empty($cursor['commenter'][0]['.attributes']['id'])) { $childComment->commenter = $cursor['commenter'][0]['.attributes']['id']; } if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) { $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value']; } if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) { $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value']; } if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) { $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value']; } $childComment->password = $cursor['password'][0]['.value']; $childComment->secret = @$cursor['secret'][0]['.value']; $childComment->written = $cursor['written'][0]['.value']; $childComment->content = $cursor['content'][0]['.value']; if (!$childComment->add()) { user_error(__LINE__ . $childComment->error); } } } return true; case '/blog/filter': setProgress($item++ / $items * 100, _t('필터 설정을 복원하고 있습니다.')); $filter = new Filter(); $filter->type = $node['.attributes']['type']; $filter->pattern = $node['pattern'][0]['.value']; if (!$filter->add()) { user_error(__LINE__ . $filter->error); } return true; case '/blog/feed': setProgress($item++ / $items * 100, _t('리더 데이터를 복원하고 있습니다.')); $feed = new Feed(); if (!empty($node['group'][0]['.value'])) { $feed->group = FeedGroup::getId($node['group'][0]['.value'], true); } $feed->url = $node['url'][0]['.value']; if (!$feed->add()) { user_error(__LINE__ . $feed->error); } return true; case '/blog/line': setProgress($item++ / $items * 100, _t('라인을 복원하고 있습니다.')); $line = Model_Line::getInstance(); $line->reset(); if (!empty($node['author'][0]['.value'])) { $line->author = $node['author'][0]['.value']; } if (!empty($node['category'][0]['.value'])) { $line->category = $node['category'][0]['.value']; } if (!empty($node['root'][0]['.value'])) { $line->root = $node['root'][0]['.value']; } if (!empty($node['permalink'][0]['.value'])) { $line->permalink = $node['permalink'][0]['.value']; } if (!empty($node['content'][0]['.value'])) { $line->content = $node['content'][0]['.value']; } if (!empty($node['created'][0]['.value'])) { $line->created = intval($node['created'][0]['.value']); } if ($line->add()) { return true; } else { user_error(__LINE__ . $line->_error); } } }
public function __construct($mimeSpec) { $this->readSpec = $mimeSpec['read']; $this->writeSpec = $mimeSpec['write']; Filter::add($mimeSpec['write']['target'], $this); }
* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ /** * The CKEditor plugin for Wolf cms * * @package wolf * @subpackage plugin.ckeditor * * @author Andri Kusumah <*****@*****.**> * @version 1.0 * @since Wolf version 0.5.5 * @license http://www.gnu.org/licenses/gpl.html GPL License * @copyright Andri Kusumah, 2009 */ Plugin::setInfos(array('id' => 'ckeditor', 'title' => __('CKEditor'), 'description' => __('CKEditor Text Filter'), 'version' => '1.1', 'license' => 'GPLv3', 'author' => 'Andri Kusumah (Goroworks)', 'website' => 'http://www.goroworks.com/', 'update_url' => 'http://ulin.goroworks.com/files/oss/wolf/ckeditor-wolf-version.xml', 'require_wolf_version' => '0.7.3')); Plugin::addController('ckeditor', __('CKEditor'), 'administrator', false); Filter::add('ckeditor', 'ckeditor/filter_ckeditor.php'); Plugin::addController('ckeditor', 'ckeditor', 'administrator,developer', false); Plugin::addJavascript('ckeditor', 'init.js.php'); Plugin::addJavascript('ckeditor', 'ckeditor/ckeditor.js');
foreach (Get::state_shortcode() as $key => $value) { $key = preg_quote($key, '#'); // %[a,b,c]: option(s) ... accept `a`, `b`, or `c` if (strpos($key, '%\\[') !== false) { $key = preg_replace_callback('#%\\\\\\[(.*?)\\\\\\]#', function ($matches) { return '(' . str_replace(array(',', '&\\#44;'), array('|', ','), $matches[1]) . ')'; }, $key); } // %s: accept any value(s) without line break(s) // %m: accept any value(s) with/without line break(s) // %i: accept integer number(s) // %f: accept float number(s) // %b: accept boolean value(s) $key = str_replace(array('%s', '%m', '%i', '%f', '%b'), array('(.+?)', '([\\s\\S]+?)', '(\\d+?)', '((?:\\d*\\.)?\\d+?)', '\\b(TRUE|FALSE|YES|NO|Y|N|ON|OFF|true|false|yes|no|y|n|on|off|1|0|\\+|\\-)\\b'), $key); $content = preg_replace('#(?<!`)' . $key . '|' . $key . '(?!`)#', Converter::DW($value), $content); } return $content; } function do_shortcode_x($content) { if (strpos($content, '`{{') === false) { return $content; } return str_replace(array('`{{', '}}`'), array('{{', '}}'), $content); } Filter::add('shortcode', 'do_shortcode', 20); // YOU ARE HERE! -- Specify your own shortcode priority to be greater // than the default shortcode file priority, but lesser than the shortcode // deactivation priority by determining the shortcode priority between 20 - 30 Filter::add('shortcode', 'do_shortcode_x', 30);
$prefix = File::B(File::D($response->path)); $to = Config::speak($prefix . '_reply_to_', Cell::a('#' . $prefix . '-' . $parent, $response->name)); echo Cell::h4($to); } }); } } // Error if ($s = Request::post('parent', false)) { Filter::add('guardian:kick', function ($url) use($config, $s) { if (!Notify::errors()) { return $url; } $ss = explode('#', $url, 2); return $config->url_current . HTTP::query('reply', $s) . '#' . $ss[1]; }); } } function do_response_ping($message, $results = array()) { $results = (object) $results; if (isset($results->parent) && !is_null($results->parent)) { $prefix = File::B(File::D($results->path)); $name = is_callable('Get::' . $prefix . 'Anchor') ? call_user_func('Get::' . $prefix . 'Anchor', $results->parent)->name : $results->parent; $to = '<a href="#' . $prefix . '-' . $results->parent . '">@' . $name . '</a>'; return strpos($message, '<p>') === 0 ? str_replace('^<p>', '<p>' . $to . ' ', '^' . $message) : $message . '<p>' . $to . '</p>'; } return $message; } Filter::add('comment:message', 'do_response_ping');
<?php defined('MONSTRA_ACCESS') or die('No direct script access.'); /** * Evaluate a string as PHP code */ if (MONSTRA_EVAL_PHP) { Filter::add('content', 'evalPHP'); } function obEval($mathes) { ob_start(); eval($mathes[1]); $mathes = ob_get_contents(); ob_end_clean(); return $mathes; } function evalPHP($str) { return preg_replace_callback('/\\[php\\](.*?)\\[\\/php\\]/ms', 'obEval', $str); } /** * Add shortcode parser filter */ Filter::add('content', 'Shortcode::parse', 11);
return preg_replace(array('#<table>#', '#<a href="(?!javascript:|[./?\\#]|' . preg_quote($config->url, '/') . ')#'), array('<table class="table-bordered table-full-width">', '<a rel="nofollow" href="'), trim($parser->transform($url . "\n\n" . $abbr . "\n\n" . $input))); }); function do_markdown($content, $results = array()) { global $config; $results = (object) $results; if (!isset($results->content_type) || $results->content_type === 'Markdown' || $results->content_type === 'Markdown Extra') { return Text::parse($content, '->html'); } return $content; } // Apply `do_markdown` filter Filter::add(array('content', 'message'), 'do_markdown', 1); // Set new `html_parser` type $config->html_parser->type = array_merge((array) $config->html_parser->type, array('Markdown' => 'Markdown Extra')); // --ibid Config::set('html_parser.type', $config->html_parser->type); if ($config->html_parser->active === 'Markdown' || $config->html_parser->active === 'Markdown Extra') { // Re-write `comment_wizard` value Config::set('speak.comment_wizard', $speak->__comment_wizard); // Create a new comment Filter::add('request:comment', function ($lot) { if (isset($lot['message'])) { // **Markdown Extra** does not support syntax to generate `del`, `ins` and `mark` tag $lot['message'] = Text::parse($lot['message'], '->text', '<br><del><ins><mark>', false); // Temporarily disallow image(s) in comment to prevent XSS $lot['message'] = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $lot['message']); } return $lot; }); }
<?php /** * Markdown plugin * * @package Monstra * @subpackage Plugins * @author Romanenko Sergey / Awilum * @copyright 2014 Romanenko Sergey / Awilum * @version 1.0.0 * */ // Register plugin Plugin::register(__FILE__, __('Markdown'), __('Markdown markup language plugin for Monstra'), '1.0.0', 'Awilum', 'http://monstra.org/'); // Uncomment code below to use Markdown on Site Content Filter::add('content', 'markdown', 1); use Michelf\MarkdownExtra; include PLUGINS . '/markdown/php-markdown/Michelf/Markdown.php'; include PLUGINS . '/markdown/php-markdown/Michelf/MarkdownExtra.php'; function markdown($content) { return MarkdownExtra::defaultTransform($content); }
<?php if (!defined('IN_CMS')) { exit; } // Provide the neccessary plugin information for Wolf. Plugin::setInfos(array('id' => 'ssp', 'title' => 'Slide Show Pro', 'description' => 'Slide Show Pro integration for Wolf', 'version' => '1.5.0', 'author' => 'Arik Savage', 'website' => 'http://www.example.com', 'require_wolf_version' => '0.5.5')); /** * Load the plugin controller. * * addController explained: * 'menu' => The plugin ID. * 'Menu' => The plugin tab label. * 'administrator' => permission name or group name - restricts who can access the controller. * 'true' => If set to true, a plugin tab is displayed in the backend navigation menu (default = false). */ Plugin::addController('ssp', 'SlideShow Pro', 'administrator', true); Filter::add('slideshow', 'ssp/filter_slideshow.php'); // Load the plugin models. AutoLoader::addFolder(PLUGINS_ROOT . DS . 'ssp' . DS . 'models'); //load javascript for backend Plugin::addJavascript('ssp', 'js/ssp_scripts.js'); Plugin::addJavascript('ssp', 'js/slideshow.js');
* =================================================================== * APPLY FILTER WITH PREFIX * =================================================================== * * -- CODE: ---------------------------------------------------------- * * Filter::colon('page:title', $content); * * // is equal to ... * * Filter::apply(array('page:title', 'title'), $content); * * ------------------------------------------------------------------- * */ Filter::plug('colon', function ($name, $value) { $arguments = func_get_args(); if (strpos($name, ':') !== false) { $s = explode(':', $name, 2); $arguments[0] = array($name, $s[1]); } return call_user_func_array('Filter::apply', $arguments); }); // Set response, comment and user `status` as `pilot`, `passenger` and `intruder` Filter::add(array('response:status', 'comment:status', 'user:status'), function ($status) { return Mecha::alter($status, array(0 => 'intruder', 1 => 'pilot', 2 => 'passenger')); }, 1); // Decode the obfuscated `email` value Filter::add(array('response:email', 'comment:email', 'user:email'), function ($data) { return Text::parse($data, '->decoded_html'); }, 1);
<?php Filter::add(array('plugin:shortcode', 'shield:shortcode'), function ($content) use($config) { if (!Text::check($content)->has('<!-- block:')) { return $content; } $tip = $config->language === 'id_ID' ? 'Menggunakan proyek kode sumber terbuka itu sangatlah menyenangkan dan murah, akan tetapi kita juga perlu biaya untuk memelihara dan menjaga mereka tetap ada di <code>www</code>.' : 'Using an open source project is incredibly fun and cheap, but we also need costs to maintain and keep them exist in the <code>www</code>.'; $donate = '--- <form class="form-donate" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <input name="cmd" type="hidden" value="_s-xclick"> <input name="hosted_button_id" type="hidden" value="TNVGH7NQ7E4EU"> <input name="submit" type="image" class="help" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="PayPal – The safer, easier way to pay online!" title="' . $tip . '"> <img alt="" src="https://www.paypalobjects.com/id_ID/i/scr/pixel.gif" width="1" height="1"> </form>'; return str_replace('<!-- block:donate -->', $donate, $content); });
* Frog CMS is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Frog CMS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Frog CMS. If not, see <http://www.gnu.org/licenses/>. * * Frog CMS has made an exception to the GNU General Public License for plugins. * See exception.txt for details and the full text. */ /** * The Markdown plugin allows users edit pages using the markdown syntax. * * @package frog * @subpackage plugin.markdown * * @author Philippe Archambault <*****@*****.**> * @version 1.0.0 * @since Frog version 0.9.0 * @license http://www.gnu.org/licenses/gpl.html GPL License * @copyright Philippe Archambault, 2008 */ Plugin::setInfos(array('id' => 'markdown', 'title' => 'Markdown filter', 'description' => 'Allows you to compose page parts or snippets using the Markdown text filter.', 'version' => '1.0.0', 'website' => 'http://www.madebyfrog.com/', 'update_url' => 'http://www.madebyfrog.com/plugin-versions.xml')); Filter::add('markdown', 'markdown/filter_markdown.php');
<?php /** * This file is part of the Fansoro. * * (c) Romanenko Sergey / Awilum <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // Add Shortcode parser filter Filter::add('content', 'Shortcode::parse', 1); // Add Parsedown parser filter Filter::add('content', 'Markdown::parse', 2);
$bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999); $bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999); $bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001); } else { $link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article)); $link .= ' · '; $link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page)); $bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999); } Config::merge('manager_menu', $menus); Config::merge('manager_bar', $bars); }); } // Loading frontend task(s) and route(s) Weapon::add('routes_before', function () use($config, $speak) { require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php'; require __DIR__ . DS . 'workers' . DS . 'route.login.php'; }); // Add log in/out link in shield footer function do_footer_manager_link($content, $path) { global $config, $speak; if (File::N($path) === 'block.footer.bar') { $s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>'; return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content); } return $content; } // Apply `do_footer_manager_link` filter Filter::add('chunk:output', 'do_footer_manager_link');
<?php Filter::add('shield:path', function ($path) { if (Config::get('page_type') === '404') { return __DIR__ . DS . 'workers' . DS . '404.php'; } return $path; });