public function up()
 {
     $table = Base::table('pages');
     $table2 = Base::table('posts');
     if ($this->has_table_column($table, 'content')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'CHANGE `content` `markdown` TEXT';
         DB::ask($sql);
     }
     if (!$this->has_table_column($table, 'html') && $this->has_table_column($table, 'markdown')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'ADD `html` TEXT NOT NULL AFTER `markdown`';
         DB::ask($sql);
         $pages = Page::sort('menu_order', 'desc')->get();
         foreach ($pages as $page) {
             Page::update($page->id, array('html' => parse($page->markdown)));
         }
     }
     if (!$this->has_table_column($table2, 'markdown') && $this->has_table_column($table2, 'html')) {
         $sql = 'ALTER TABLE `' . $table2 . '` ';
         $sql .= 'ADD `markdown` TEXT NOT NULL AFTER `description`';
         DB::ask($sql);
         $migrate_data_sql = 'update `' . $table2 . '` set `markdown` = `html`, `html` = "";';
         DB::ask($migrate_data_sql);
         $posts = Post::sort('created', 'desc')->get();
         foreach ($posts as $post) {
             Post::update($post->id, array('html' => parse($post->markdown)));
         }
     }
 }
Example #2
0
 /**
  * Recalculate post comments count
  *
  * @param type $Comment
  */
 public function hookCommentsRecount($Comment)
 {
     $post = new Post();
     $post->id = $Comment->post_id;
     if ($post->find()) {
         $post->update(array('comments' => $this->db->where(array('post_id' => $post->id, 'published' => 1))->countAll('comments', 'id', TRUE)));
     }
 }
 public function put_update()
 {
     $id = Input::get('id');
     $validation = Post::validate(Input::all(), $id);
     if ($validation->fails()) {
         return Redirect::to_route('post_edit', $id)->with_errors($validation);
     } else {
         Post::update($id, array('title' => Input::get('title'), 'body' => Input::get('body'), 'author' => Input::get('author'), 'category_id' => Input::get('category')));
         return Redirect::to_route('post_show', $id)->with('message', 'Post has been updated!');
     }
 }
Example #4
0
 public function update($id, $created)
 {
     if (!self::owner($id)) {
         throw new NotAuthorized();
     }
     if (!(int) $id) {
         throw new InvalidInput();
     }
     $timestamp = date('Y-m-d H:i:s', strtotime($created));
     $affected = Post::update($id, $timestamp);
     echo $affected . ' post(s) updated successfully.';
 }
Example #5
0
 public function put_update()
 {
     $validation = Post::validate(Input::all());
     $s = Input::get('title');
     $t = Str::slug($s);
     $post = Post::find(Input::get('id'));
     if ($validation->fails()) {
         return Redirect::to_route('post_edit', $post->slug)->with_errors($validation)->with_input();
     } else {
         Post::update(Input::get('id'), array('title' => Input::get('title'), 'body' => Input::get('body'), 'author' => Input::get('author'), 'category_id' => Input::get('category')));
         return Redirect::to_route('post_view', $post->slug)->with('message', 'Post has been updated successfully!');
     }
 }
 /**
  * Update the specified resource in storage.
  * @param $id
  * @internal param $post
  * @return Response
  */
 public function update($id)
 {
     $record = $this->blogRepository->findById($id);
     $val = $this->blogRepository->getEditForm($id);
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     if (!$this->blogRepository->update($id, $val->getInputData())) {
         return Redirect::back()->with('errors', $this->blogRepository->errors())->withInput();
     }
     $tags = is_array(Input::get('tags')) ? array_filter(Input::get('tags')) : [];
     $this->tagRepository->attachTags($record, $tags);
     return Redirect::action('AdminBlogsController@edit', $id)->with('success', 'Updated');
 }
Example #7
0
 public function update()
 {
     $data = $_POST['Post'];
     if (isset($data['post_id'])) {
         $post = new Post();
         $post->title = $data['title'];
         $post->content = strip_tags($data['content']);
         if (isset($_FILES['Post'])) {
             $post->uploadImage($_FILES['Post']);
         }
         $post->status = $data['status'];
         $post->update($data['post_id']);
         if (isset($data['tags'])) {
             $post->updateTags($data['post_id'], $data['tags']);
         }
         Application::redirect(array('post' => 'edit'), array('id' => $data['post_id']));
     }
 }
Example #8
0
 static function getPostUpdatePage()
 {
     if (isset(Router::get('ids')[0])) {
         $post = new Post(Router::get('ids')[0]);
         $id = $post->get('id');
         $title = $post->get('title');
         $content = $post->get('content');
         $author = $post->get('author');
         if (unserialize($_SESSION['user'])->get('id') != $author->get('id')) {
             http_response_code(403);
             die('<h1>403 Accès interdit !</h1><p>Vous ne pouvez pas modifier cet article, vous n\'en êtes pas l\'auteur.</p>');
         }
     } else {
         $id = null;
         $title = null;
         $content = null;
         $author = null;
     }
     if (!(isset($_SESSION['user']) && $_SESSION['user'] != null)) {
         http_response_code(403);
         die('<h1>403 Accès interdit !</h1><p>Vous devez être connecté pour créer un article.</p><p><a href="' . Conf::$BASE_URL . '/user/login">Se connecter</a></p>');
     }
     if ($_POST != null) {
         extract($_POST);
         $errors = Post::checkErrors($_POST);
         if (count($errors) == 0) {
             if (!isset(Router::get('ids')[0])) {
                 $success = Post::create($title, $content, $author);
             } else {
                 $success = Post::update(Router::get('ids')[0], $title, $content);
             }
             if ($success) {
                 header('Location: ' . Conf::$BASE_URL . '/post/' . $success);
             }
         }
     }
     $action = Router::get('uri');
     $wording = Router::get('uri') == '/post/create' ? 'Créer' : 'Modifier';
     echo self::render('postUpdatePage', array('action' => $action, 'wording' => $wording, 'id' => $id, 'title' => $title, 'content' => $content, 'author' => $author));
 }
Example #9
0
    /**
     * The plugin sink for the auth_ajax_wp_import_posts hook.
     * Responds via authenticated ajax to requests for post importing.
     *
     * @param AjaxHandler $handler The handler that handled the request, contains $_POST info
     */
    public function action_auth_ajax_wp_import_posts($handler)
    {
        $valid_fields = array('db_name', 'db_host', 'db_user', 'db_pass', 'db_prefix', 'postindex', 'category_import', 'utw_import');
        $inputs = array_intersect_key($_POST->getArrayCopy(), array_flip($valid_fields));
        extract($inputs);
        if (!isset($inputs['category_import'])) {
            $inputs['category_import'] = 0;
        }
        if (!isset($inputs['utw_import'])) {
            $inputs['utw_import'] = 0;
        }
        $wpdb = $this->wp_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix);
        if ($wpdb) {
            if (!DB::in_transaction()) {
                DB::begin_transaction();
            }
            $has_taxonomy = count($wpdb->get_column("SHOW TABLES LIKE '{$db_prefix}term_taxonomy';"));
            $postcount = $wpdb->get_value("SELECT count( id ) FROM {$db_prefix}posts;");
            $min = $postindex * IMPORT_BATCH + ($postindex == 0 ? 0 : 1);
            $max = min(($postindex + 1) * IMPORT_BATCH, $postcount);
            $user_map = array();
            $userinfo = DB::table('userinfo');
            $user_info = DB::get_results("SELECT user_id, value FROM {$userinfo} WHERE name= 'wp_id';");
            foreach ($user_info as $info) {
                $user_map[$info->value] = $info->user_id;
            }
            echo "<p>Importing posts {$min}-{$max} of {$postcount}.</p>";
            $posts = $wpdb->get_results("\n\t\t\t\tSELECT\n\t\t\t\t\tpost_content as content,\n\t\t\t\t\tID as id,\n\t\t\t\t\tpost_title as title,\n\t\t\t\t\tpost_name as slug,\n\t\t\t\t\tpost_author as user_id,\n\t\t\t\t\tguid as guid,\n\t\t\t\t\tpost_date as pubdate,\n\t\t\t\t\tpost_modified as updated,\n\t\t\t\t\tpost_status,\n\t\t\t\t\tpost_type\n\t\t\t\tFROM {$db_prefix}posts\n\t\t\t\tWHERE post_type != 'revision' AND post_type != 'attachment'\n\t\t\t\tORDER BY ID DESC\n\t\t\t\tLIMIT {$min}, " . IMPORT_BATCH, array(), 'Post');
            $post_map = DB::get_column("SELECT value FROM {postinfo} WHERE name='wp_id';");
            foreach ($posts as $post) {
                if (in_array($post->id, $post_map)) {
                    continue;
                }
                if ($has_taxonomy) {
                    // Importing from >= WP2.3
                    if ($category_import == 1) {
                        // Import WP category and tags as tags
                        $taxonomies = "({$db_prefix}term_taxonomy.taxonomy= 'category' OR {$db_prefix}term_taxonomy.taxonomy= 'post_tag')";
                    } else {
                        // Import WP tags as tags
                        $taxonomies = "{$db_prefix}term_taxonomy.taxonomy= 'post_tag'";
                    }
                    $tags = $wpdb->get_column("SELECT DISTINCT name\n\t\t\t\t\t\tFROM {$db_prefix}terms\n\t\t\t\t\t\tINNER JOIN {$db_prefix}term_taxonomy\n\t\t\t\t\t\tON ( {$db_prefix}terms.term_id= {$db_prefix}term_taxonomy.term_id AND {$taxonomies} )\n\t\t\t\t\t\tINNER JOIN {$db_prefix}term_relationships\n\t\t\t\t\t\tON ({$db_prefix}term_taxonomy.term_taxonomy_id= {$db_prefix}term_relationships.term_taxonomy_id)\n\t\t\t\t\t\tWHERE {$db_prefix}term_relationships.object_id= {$post->id}");
                } else {
                    // Importing from < WP2.3
                    if ($category_import == 1) {
                        // Import WP category as tags
                        $tags = $wpdb->get_column("SELECT category_nicename\n\t\t\t\t\t\t\tFROM {$db_prefix}post2cat\n\t\t\t\t\t\t\tINNER JOIN {$db_prefix}categories\n\t\t\t\t\t\t\tON ( {$db_prefix}categories.cat_ID= {$db_prefix}post2cat.category_id )\n\t\t\t\t\t\t\tWHERE post_id= {$post->id}");
                    } else {
                        $tags = array();
                    }
                }
                // we want to include the Ultimate Tag Warrior in that list of tags
                if ($utw_import == 1 && count(DB::get_results("show tables like 'post2tag'"))) {
                    $utw_tags = $wpdb->get_column("SELECT tag\n\t\t\t\t\tFROM {$db_prefix}post2tag\n\t\t\t\t\tINNER JOIN {$db_prefix}tags\n\t\t\t\t\tON ( {$db_prefix}tags.tag_ID= {$db_prefix}post2tag.tag_id )\n\t\t\t\t\tWHERE post_id= {$post->id}");
                    // UTW substitutes underscores and hyphens for spaces, so let's do the same
                    $utw_tag_formatter = create_function('$a', 'return preg_replace( "/_|-/", " ", $a );');
                    // can this be done in just two calls instead of three? I think so.
                    $tags = array_unique(array_merge($tags, array_map($utw_tag_formatter, $utw_tags)));
                }
                $post->content = MultiByte::convert_encoding($post->content);
                $post->title = MultiByte::convert_encoding($post->title);
                $tags = implode(',', $tags);
                $tags = MultiByte::convert_encoding($tags);
                $post_array = $post->to_array();
                switch ($post_array['post_status']) {
                    case 'publish':
                        $post_array['status'] = Post::status('published');
                        break;
                    default:
                        $post_array['status'] = Post::status($post_array['post_status']);
                        break;
                }
                unset($post_array['post_status']);
                switch ($post_array['post_type']) {
                    case 'post':
                        $post_array['content_type'] = Post::type('entry');
                        break;
                    case 'page':
                        $post_array['content_type'] = Post::type('page');
                        break;
                    default:
                        // We're not inserting WP's media records.  That would be silly.
                        continue;
                }
                unset($post_array['post_type']);
                $p = new Post($post_array);
                $p->slug = $post->slug;
                if (isset($user_map[$p->user_id])) {
                    $p->user_id = $user_map[$p->user_id];
                } else {
                    $errors = Options::get('import_errors');
                    $errors[] = _t('Post author id %s was not found in WP database, assigning post "%s" (WP post id #%d) to current user.', array($p->user_id, $p->title, $post_array['id']));
                    Options::set('import_errors', $errors);
                    $p->user_id = User::identify()->id;
                }
                $p->guid = $p->guid;
                // Looks fishy, but actually causes the guid to be set.
                $p->tags = $tags;
                $p->info->wp_id = $post_array['id'];
                // Store the WP post id in the post_info table for later
                try {
                    $p->insert();
                    $p->updated = $post_array['updated'];
                    $p->update();
                } catch (Exception $e) {
                    EventLog::log($e->getMessage(), 'err', null, null, print_r(array($p, $e), 1));
                    Session::error($e->getMessage());
                    $errors = Options::get('import_errors');
                    $errors[] = $p->title . ' : ' . $e->getMessage();
                    Options::set('import_errors', $errors);
                }
            }
            if (DB::in_transaction()) {
                DB::commit();
            }
            if ($max < $postcount) {
                $ajax_url = URL::get('auth_ajax', array('context' => 'wp_import_posts'));
                $postindex++;
                $vars = Utils::addslashes(array('host' => $db_host, 'name' => $db_name, 'user' => $db_user, 'pass' => $db_pass, 'prefix' => $db_prefix));
                echo <<<WP_IMPORT_AJAX1
\t\t\t\t\t<script type="text/javascript">
\t\t\t\t\t\$( '#import_progress' ).load(
\t\t\t\t\t\t"{$ajax_url}",
\t\t\t\t\t\t{
\t\t\t\t\t\t\tdb_host: "{$vars['host']}",
\t\t\t\t\t\t\tdb_name: "{$vars['name']}",
\t\t\t\t\t\t\tdb_user: "******",
\t\t\t\t\t\t\tdb_pass: "******",
\t\t\t\t\t\t\tdb_prefix: "{$vars['prefix']}",
\t\t\t\t\t\t\tcategory_import: "{$category_import}",
\t\t\t\t\t\t\tutw_import: "{$utw_import}",
\t\t\t\t\t\t\tpostindex: {$postindex}
\t\t\t\t\t\t}
\t\t\t\t\t );

\t\t\t\t</script>
WP_IMPORT_AJAX1;
            } else {
                $ajax_url = URL::get('auth_ajax', array('context' => 'wp_import_comments'));
                $vars = Utils::addslashes(array('host' => $db_host, 'name' => $db_name, 'user' => $db_user, 'pass' => $db_pass, 'prefix' => $db_prefix));
                echo <<<WP_IMPORT_AJAX2
\t\t\t\t\t<script type="text/javascript">
\t\t\t\t\t\$( '#import_progress' ).load(
\t\t\t\t\t\t"{$ajax_url}",
\t\t\t\t\t\t{
\t\t\t\t\t\t\tdb_host: "{$vars['host']}",
\t\t\t\t\t\t\tdb_name: "{$vars['name']}",
\t\t\t\t\t\t\tdb_user: "******",
\t\t\t\t\t\t\tdb_pass: "******",
\t\t\t\t\t\t\tdb_prefix: "{$vars['prefix']}",
\t\t\t\t\t\t\tcategory_import: "{$category_import}",
\t\t\t\t\t\t\tutw_import: "{$utw_import}",
\t\t\t\t\t\t\tcommentindex: 0
\t\t\t\t\t\t}
\t\t\t\t\t );

\t\t\t\t</script>
WP_IMPORT_AJAX2;
            }
        } else {
            EventLog::log(sprintf(_t('Failed to import from "%s"'), $db_name), 'crit');
            Session::error($e->getMessage());
            echo '<p>' . _t('The database connection details have failed to connect.') . '</p>';
        }
    }
        break;
    case 'edit':
        //各条件
        $cont->edit(20);
        break;
    case 'destroy':
        //各条件
        $cont->destroy(10);
        break;
    case 'view':
        //各条件
        $modl->view(10);
        break;
    case 'update':
        //各条件
        $modl->update(10);
        break;
    case 'delete':
        //各条件
        $modl->delete(10);
        break;
    default:
        echo 'It is error';
        break;
}
//controller class
class PostController
{
    //property
    private $resouce = '';
    private $action = '';
Example #11
0
         Notify::error($errors);
         return Response::redirect('admin/posts/edit/' . $id);
     }
     $current_post = Post::find($id);
     if ($current_post->status == 'draft') {
         $input['created'] = Date::mysql('now');
     } else {
         unset($input['created']);
     }
     if (is_null($input['comments'])) {
         $input['comments'] = 0;
     }
     if (empty($input['html'])) {
         $input['status'] = 'draft';
     }
     Post::update($id, $input);
     Extend::process('post', $id);
     Notify::success(__('posts.updated'));
     return Response::redirect('admin/posts/edit/' . $id);
 });
 /*
 	Add new post
 */
 Route::get('admin/posts/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['page'] = Registry::get('posts_page');
     // extended fields
     $vars['fields'] = Extend::fields('post');
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     $vars['categories'] = Category::dropdown();
Example #12
0
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);
            }
    }
}
Example #13
0
function updateProcess($id)
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'min:1|slashes', 'send.keywords' => 'slashes', 'tags' => 'slashes', 'send.catid' => 'slashes', 'send.type' => 'slashes', 'send.allowcomment' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request. Error: " . Validator::getMessage());
    }
    $uploadMethod = Request::get('uploadMethod');
    $loadData = Post::get(array('where' => "where postid='{$id}'"));
    if (!isset($loadData[0]['postid'])) {
        throw new Exception("This post not exists.");
    }
    switch ($uploadMethod) {
        case 'frompc':
            if (Request::hasFile('imageFromPC')) {
                if (Request::isImage('imageFromPC')) {
                    $send['image'] = File::upload('imageFromPC');
                    File::remove($loadData[0]['image']);
                }
            }
            break;
        case 'fromurl':
            if (Request::isImage('imageFromUrl')) {
                $url = Request::get('imageFromUrl');
                $send['image'] = File::upload('uploadFromUrl');
                File::remove($loadData[0]['image']);
            }
            break;
    }
    $send['userid'] = Users::getCookieUserId();
    if (!Request::has('send.catid')) {
        $loadCat = Categories::get(array('limitShow' => 1));
        if (isset($loadCat[0]['catid'])) {
            $send['catid'] = $loadCat[0]['catid'];
        }
    }
    if (!Post::update($id, $send)) {
        throw new Exception("Error. " . Database::$error);
    }
    PostTags::remove($id, " postid='{$id}' ");
    $tags = trim(Request::get('tags'));
    $parse = explode(',', $tags);
    $total = count($parse);
    $insertData = array();
    for ($i = 0; $i < $total; $i++) {
        $insertData[$i]['title'] = trim($parse[$i]);
        $insertData[$i]['postid'] = $id;
    }
    PostTags::insert($insertData);
}
Example #14
0
 public function update_one($params = [])
 {
     global $_PUT;
     Post::update($_PUT, $params['id']);
     Render::json(Post::read_formatted($params['id']));
 }
 /**
  * Approve a comment
  */
 function approveComment()
 {
     Doo::loadModel('Comment');
     $c = new Comment();
     $c->id = intval($this->params['cid']);
     $comment = $c->find(array('limit' => 1, 'select' => 'id, post_id'));
     //if not exists, show error
     if ($comment == Null) {
         return 404;
     }
     //change status to Approved
     $comment->status = 1;
     $comment->update(array('field' => 'status'));
     Doo::loadModel('Post');
     Doo::autoload('DooDbExpression');
     //Update totalcomment field in Post
     $p = new Post();
     $p->id = $comment->post_id;
     $p->totalcomment = new DooDbExpression('totalcomment+1');
     $p->update(array('field' => 'totalcomment'));
     $data['rootUrl'] = Doo::conf()->APP_URL;
     $data['title'] = 'Comment Approved!';
     $data['content'] = "<p>Comment is approved successfully!</p>";
     $data['content'] .= "<p>View the comment <a href=\"{$data['rootUrl']}article/{$p->id}#comment{$comment->id}\">here</a></p>";
     $this->render('admin_msg', $data);
 }
Example #16
0
/* ------------------------------------------------- *\
    Method all
\* ------------------------------------------------- */
var_dump($postModel->all());
$posts = $postModel->all();
foreach ($posts as $post) {
    echo "<h1>{$post->title}...</h1>";
}
/* ------------------------------------------------- *\
    method find
\* ------------------------------------------------- */
var_dump($postModel->find(1));
/* ------------------------------------------------- *\
    Create
\* ------------------------------------------------- */
$postModel->create(['title' => 'foo', 'status' => 'published']);
/* ------------------------------------------------- *\
    User model
\* ------------------------------------------------- */
$userModel = new User($connect->getDB());
var_dump($userModel->all());
/* ------------------------------------------------- *\
    Destroy
\* ------------------------------------------------- */
//var_dump($postModel->destroy(17));
/* ------------------------------------------------- *\
    Update
\* ------------------------------------------------- */
$data = ['title' => 'foo bar baz', 'status' => 'published'];
var_dump($postModel->update(50, $data));
 /**
  * The plugin sink for the auth_ajax_hab_import_posts hook.
  * Responds via authenticated ajax to requests for post importing.
  *
  * @param AjaxHandler $handler The handler that handled the request, contains $_POST info
  */
 public function action_auth_ajax_hab_import_posts($handler)
 {
     $inputs = $_POST->filter_keys('db_type', 'db_name', 'db_host', 'db_user', 'db_pass', 'db_prefix', 'postindex', 'tag_import');
     $inputs = $inputs->getArrayCopy($inputs);
     $inputs = array_merge($this->default_values, $inputs);
     $connect_string = $this->get_connect_string($inputs['db_type'], $inputs['db_host'], $inputs['db_name']);
     $db = $this->hab_connect($connect_string, $inputs['db_user'], $inputs['db_pass']);
     if (!$db) {
         EventLog::log(sprintf(_t('Failed to import from "%s"'), $inputs['db_name']), 'crit');
         Session::error($e->getMessage());
         echo '<p>' . _t('The database connection details have failed to connect.') . '</p>';
     }
     DB::begin_transaction();
     $old_db_version = (int) $db->get_value("SELECT value FROM {$inputs['db_prefix']}options WHERE name = ?", array('db_version'));
     $postcount = $db->get_value("SELECT count( id ) FROM {$inputs['db_prefix']}posts;");
     $min = $inputs['import_index'] * IMPORT_BATCH + ($inputs['import_index'] == 0 ? 0 : 1);
     $max = min(($inputs['import_index'] + 1) * IMPORT_BATCH, $postcount);
     $user_map = array();
     $user_info = DB::get_results("SELECT user_id, value FROM {userinfo} WHERE name= 'old_id';");
     foreach ($user_info as $info) {
         $user_map[$info->value] = $info->user_id;
     }
     echo "<p>Importing posts {$min}-{$max} of {$postcount}.</p>";
     $posts = $db->get_results("\r\n\t\t\tSELECT\r\n\t\t\t\tcontent,\r\n\t\t\t\tid,\r\n\t\t\t\ttitle,\r\n\t\t\t\tslug,\r\n\t\t\t\tuser_id,\r\n\t\t\t\tguid,\r\n\t\t\t\tpubdate,\r\n\t\t\t\tupdated,\r\n\t\t\t\tmodified,\r\n\t\t\t\tstatus,\r\n\t\t\t\tcontent_type\r\n\t\t\tFROM {$inputs['db_prefix']}posts\r\n\t\t\tORDER BY id DESC\r\n\t\t\tLIMIT {$min}, " . IMPORT_BATCH, array(), 'Post');
     $post_map = DB::get_column("SELECT value FROM {$inputs['db_prefix']}postinfo WHERE name='old_id';");
     foreach ($posts as $post) {
         if (in_array($post->id, $post_map)) {
             continue;
         }
         if ($inputs['tag_import'] == 1) {
             // Import tags
             if ($old_db_version < 3749) {
                 $tags = $db->get_column("SELECT tag_text\r\n\t\t\t\t\t\tFROM {$inputs['db_prefix']}tags\r\n\t\t\t\t\t\tINNER JOIN {$inputs['db_prefix']}tag2post\r\n\t\t\t\t\t\tON {$inputs['db_prefix']}tags.id = {$inputs['db_prefix']}tag2post.tag_id\r\n\t\t\t\t\t\tWHERE post_id = {$post->id}");
             } else {
                 $tags = $db->get_column("SELECT term_display\r\n\t\t\t\t\t\tFROM {$inputs['db_prefix']}terms\r\n\t\t\t\t\t\tINNER JOIN {$inputs['db_prefix']}object_terms\r\n\t\t\t\t\t\tON {$inputs['db_prefix']}terms.id = {$inputs['db_prefix']}object_terms.term_id\r\n\t\t\t\t\t\tWHERE object_id = ? AND object_type_id = ?", array($post->id, Vocabulary::object_type_id('post')));
             }
         } else {
             $tags = array();
         }
         $tags = implode(',', $tags);
         $post_array = $post->to_array();
         $p = new Post($post_array);
         $p->slug = $post->slug;
         if (isset($user_map[$p->user_id])) {
             $p->user_id = $user_map[$p->user_id];
         } else {
             $errors = Options::get('import_errors');
             $errors[] = _t('Post author id %s was not found in the external database, assigning post "%s" (external post id #%d) to current user.', array($p->user_id, $p->title, $post_array['id']));
             Options::set('import_errors', $errors);
             $p->user_id = User::identify()->id;
         }
         $p->guid = $p->guid;
         // Looks fishy, but actually causes the guid to be set.
         $p->tags = $tags;
         $infos = $db->get_results("SELECT name, value, type FROM {$inputs['db_prefix']}postinfo WHERE post_id = ?", array($post_array['id']));
         $p->info->old_id = $post_array['id'];
         // Store the old post id in the post_info table for later
         try {
             $p->insert();
             $p->updated = $post_array['updated'];
             $p->update();
             foreach ($infos as $info) {
                 $fields = $info->get_url_args();
                 $fields['post_id'] = $p->id;
                 DB::insert(DB::table('postinfo'), $fields);
             }
         } catch (Exception $e) {
             EventLog::log($e->getMessage(), 'err', null, null, print_r(array($p, $e), 1));
             Session::error($e->getMessage());
             $errors = Options::get('import_errors');
             $errors[] = $p->title . ' : ' . $e->getMessage();
             Options::set('import_errors', $errors);
         }
     }
     if (DB::in_transaction()) {
         DB::commit();
     }
     if ($max < $postcount) {
         $inputs['import_index']++;
         $ajax_url = URL::get('auth_ajax', array('context' => 'hab_import_posts'));
     } else {
         $inputs['import_index'] = 0;
         $ajax_url = URL::get('auth_ajax', array('context' => 'hab_import_comments'));
     }
     echo $this->get_ajax($ajax_url, $inputs);
 }
        $posts->index();
        break;
    case 'show':
        $posts->show(1);
        break;
    case 'edit':
        $posts->edit(1);
        break;
    case 'destroy':
        $posts->destroy(1);
        break;
    case 'view':
        $post->view(1);
        break;
    case 'update':
        $post->update(1);
        break;
    case 'delete':
        $post->delete(1);
    default:
        # code...
        break;
}
function changesingular($value)
{
    //複数形から単数形へ変換
    if ($value == 'posts') {
        return 'post';
    }
}
/**
Example #19
0
        public function __construct() {
            require_once 'Zend/Loader.php';
            Zend_Loader::loadClass('Zend_Gdata_Photos');
            Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
            Zend_Loader::loadClass('Zend_Gdata_AuthSub'); 

            $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
            $username = '******';
            $password = '******';
            $client = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, $serviceName );

            $gp = new Zend_Gdata_Photos( $client, 'Dionyziz-Life-1.0' );

            $query = $gp->newAlbumQuery();

            $query->setUser( 'default' );
            $query->setAlbumName( 'Sikinos' );

            $albumFeed = $gp->getAlbumFeed( $query );

            $i = 0;
            foreach ( $albumFeed as $albumEntry ) {
                try { 
                    $albumid = $albumEntry->getGphotoAlbumId();

                    $exif = $albumEntry->getExifTags();
                    $time = $exif->getTime();
                    if ( $time == null ) {
                        echo "Photo does not contain time information.\n";
                        continue;
                    }
                    $timestamp = $time->getText();

                    $mediaContentArray = $albumEntry->getMediaGroup()->getContent();
                    $contentUrl = $mediaContentArray[ 0 ]->getUrl();
                    $mediaThumbnailArray = $albumEntry->getMediaGroup()->getThumbnail();
                    if ( $mediaThumbnailArray == null ) {
                        echo "Photo does not contain thumbnail.\n";
                        continue;
                    }
                    $maxwidth = 0;
                    $maxid = 0;
                    foreach ( $mediaThumbnailArray as $id => $thumb ) {
                        if ( $thumb->getWidth() > $maxwidth ) {
                            $maxwidth = $thumb->getWidth();
                            $maxid = $id;
                            $thumbnailUrl = $thumb->getUrl();
                        }
                    }

                    // echo "Importing image " . $contentUrl . " from Picasa... ";
                    // $diff = 1310008564116;
                    $link = $albumEntry->getAlternateLink()->getHref();
                    $parts = explode( '/', $link );
                    $userid = $parts[ 3 ];
                    $parts = explode( '#', $link );
                    $photoid = $parts[ 1 ];
                    $link = 'https://plus.google.com/photos/' . $userid . '/albums/' . $albumid . '/' . $photoid;
                    // echo( $link . ': ' . date( "Y-m-d H:i:s", $timestamp - $diff ) . "\n" );
                    Post::update( 
                        Post::create( 'picasa:' . $contentUrl . ' ' . $thumbnailUrl . ' ' . $link, 1, 'photo', 'public' ),
                        date( "Y-m-d H:i:s", $timestamp / 1000 )
                    );
                    ++$i;
                    echo $i . ' / ' . count( $albumFeed ) . "\n";
                }
                catch ( Exception $e ) {
                    echo "Failed to retrieve photo EXIF information.\n";
                }
            }
        }
 /**
  * Handler thread creation form
  */
 public function filter_handle_thread_reply($output, $form, $thread, $forum)
 {
     if (!self::has_permission('reply', $thread)) {
         return _t('<p>You are not authorized to reply to this thread.</p>');
     }
     $postdata = array('user_id' => User::identify()->id, 'pubdate' => HabariDateTime::date_create(), 'content_type' => Post::type('reply'), 'content' => $form->content->value, 'status' => Post::status('published'));
     $reply = new Post($postdata);
     $reply->insert();
     if (self::$anonymity && $form->anonymous->value == TRUE) {
         $reply->info->anonymous = TRUE;
     }
     // Do vocab stuff
     $vocab = Vocabulary::get(self::$vocab);
     $parent_term = $vocab->get_term($thread->slug);
     $reply_term = $vocab->add_term($reply->slug, $parent_term);
     $reply->update();
     Utils::redirect($reply->permalink);
     return '...';
 }
    /**
     * The plugin sink for the auth_ajax_chyrp_import_posts hook.
     * Responds via authenticated ajax to requests for post importing.
     *
     * @param AjaxHandler $handler The handler that handled the request, contains $_POST info
     */
    public function action_auth_ajax_chyrp_import_posts($handler)
    {
        $inputs = $_POST->filter_keys('db_type', 'db_name', 'db_host', 'db_user', 'db_pass', 'postindex');
        foreach ($inputs as $key => $value) {
            ${$key} = $value;
        }
        $connect_string = $this->get_connect_string($db_type, $db_host, $db_name);
        $db = $this->chryp_connect($connect_string, $db_user, $db_pass);
        if ($db) {
            DB::begin_transaction();
            $postcount = $db->get_value("SELECT count(id) FROM posts;");
            $min = $postindex * IMPORT_BATCH + ($postindex == 0 ? 0 : 1);
            $max = min(($postindex + 1) * IMPORT_BATCH, $postcount);
            // old_id was set when we imported the users
            $user_map = array();
            $user_info = DB::get_results("SELECT user_id, value FROM {userinfo} WHERE name='old_id';");
            foreach ($user_info as $info) {
                $user_map[$info->value] = $info->user_id;
            }
            // Posts
            // id INTEGER PRIMARY KEY AUTOINCREMENT,
            // feather VARCHAR(32) DEFAULT '',
            // clean VARCHAR(128) DEFAULT '',
            // url VARCHAR(128) DEFAULT '',
            // pinned BOOLEAN DEFAULT FALSE,
            // status VARCHAR(32) DEFAULT 'public',
            // user_id INTEGER DEFAULT 0,
            // created_at DATETIME DEFAULT NULL,
            // updated_at DATETIME DEFAULT NULL
            //
            // Post attributes
            // post_id INTEGER NOT NULL ,
            // name VARCHAR(100) DEFAULT '',
            // value LONGTEXT,
            echo "<p>Importing posts {$min}-{$max} of {$postcount}.</p>";
            $posts = $db->get_results("\r\n\t\t\t\tSELECT\r\n\t\t\t\t\tattr_body.value as content,\r\n\t\t\t\t\tid,\r\n\t\t\t\t\tattr_title.value as title,\r\n\t\t\t\t\tuser_id,\r\n\t\t\t\t\tcreated_at as pubdate,\r\n\t\t\t\t\tupdated_at as updated,\r\n\t\t\t\t\tupdated_at as modified,\r\n\t\t\t\t\tstatus\r\n\t\t\t\tFROM posts\r\n\t\t\t\tINNER JOIN post_attributes attr_title ON posts.id = attr_title.post_id AND attr_title.name = 'title'\r\n\t\t\t\tINNER JOIN post_attributes attr_body ON posts.id = attr_body.post_id AND attr_body.name = 'body'\r\n\t\t\t\tORDER BY id DESC\r\n\t\t\t\tLIMIT {$min}, " . IMPORT_BATCH, array(), 'Post');
            $post_map = DB::get_column("SELECT value FROM {postinfo} WHERE name='old_id';");
            foreach ($posts as $post) {
                if (in_array($post->id, $post_map)) {
                    continue;
                }
                $post_array = $post->to_array();
                $post_array['content_type'] = Post::type('entry');
                $p = new Post($post_array);
                $p->slug = $post->slug;
                if (isset($user_map[$p->user_id])) {
                    $p->user_id = $user_map[$p->user_id];
                } else {
                    $errors = Options::get('import_errors');
                    $errors[] = _t('Post author id %s was not found in the external database, assigning post "%s" (external post id #%d) to current user.', array($p->user_id, $p->title, $post_array['id']));
                    Options::set('import_errors', $errors);
                    $p->user_id = User::identify()->id;
                }
                $p->guid = $p->guid;
                // Looks fishy, but actually causes the guid to be set.
                $p->info->old_id = $post_array['id'];
                // Store the old post id in the post_info table for later
                try {
                    $p->insert();
                    $p->updated = $post_array['updated'];
                    $p->update();
                } catch (Exception $e) {
                    EventLog::log($e->getMessage(), 'err', null, null, print_r(array($p, $e), 1));
                    Session::error($e->getMessage());
                    $errors = Options::get('import_errors');
                    $errors[] = $p->title . ' : ' . $e->getMessage();
                    Options::set('import_errors', $errors);
                }
            }
            if (DB::in_transaction()) {
                DB::commit();
            }
            if ($max < $postcount) {
                $ajax_url = URL::get('auth_ajax', array('context' => 'chyrp_import_posts'));
                $postindex++;
                $vars = Utils::addslashes(array('host' => $db_host, 'name' => $db_name, 'user' => $db_user, 'pass' => $db_pass));
                echo <<<IMPORT_POSTS
\t\t\t\t\t<script type="text/javascript">
\t\t\t\t\t\$( '#import_progress' ).load(
\t\t\t\t\t\t"{$ajax_url}",
\t\t\t\t\t\t{
\t\t\t\t\t\t\tdb_type: "{$db_type}",
\t\t\t\t\t\t\tdb_host: "{$vars['host']}",
\t\t\t\t\t\t\tdb_name: "{$vars['name']}",
\t\t\t\t\t\t\tdb_user: "******",
\t\t\t\t\t\t\tdb_pass: "******",
\t\t\t\t\t\t\tpostindex: {$postindex}
\t\t\t\t\t\t}
\t\t\t\t\t);

\t\t\t\t</script>
IMPORT_POSTS;
            } else {
                EventLog::log('Import complete from "' . $db_name . '"');
                echo '<p>' . _t('Import is complete.') . '</p>';
                $errors = Options::get('import_errors');
                if (count($errors) > 0) {
                    echo '<p>' . _t('There were errors during import:') . '</p>';
                    echo '<ul>';
                    foreach ($errors as $error) {
                        echo '<li>' . $error . '</li>';
                    }
                    echo '</ul>';
                }
            }
        } else {
            EventLog::log(sprintf(_t('Failed to import from "%s"'), $db_name), 'crit');
            Session::error($e->getMessage());
            echo '<p>' . _t('The database connection details have failed to connect.') . '</p>';
        }
    }
    $mail->From = '*****@*****.**';
    $mail->FromName = 'Selenium分享';
    foreach ($user_list as $ldap_name => $name) {
        $mail->addAddress($ldap_name . "@rd.xxx.com", $name);
        // Add a recipient
    }
    $mail->WordWrap = 50;
    // Set word wrap to 50 characters
    $mail->isHTML(true);
    // Set email format to HTML
    $mail->Subject = "[Selenium有新分享]: " . $subject;
    $mail->Body = "<b>{$user}于{$time}在<a href='http://selenium.iyoudao.net'>论坛</a>分享了他的心得:</b><br><pre>" . $body . "</pre>";
    if (!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
        return false;
    }
    return true;
}
$post = new Post();
if ($postid == "-1") {
    $result = $post->insert($title, $author, $type, $tag, $content);
    if ($mail_send == "1") {
        send_mail($user_list, $title, $content, $author);
    }
    echo "1";
} else {
    $post->update($postid, $title, $author, $type, $tag, $content);
    echo "1";
}
$post->closeDB();
Example #23
0
 function retrieveCallback($lines, $uid)
 {
     $this->appendUid($uid);
     $mail = $this->pop3->parse($lines);
     if (isset($mail['date_string'])) {
         $slogan = $mail['date_string'];
         $docid = $mail['time_string'];
     } else {
         $slogan = date("Y-m-d");
         $docid = date("H:i:s");
     }
     if (in_array($mail['subject'], array('제목없음'))) {
         $mail['subject'] = '';
     }
     if (!$this->isAllowed($mail)) {
         return false;
     }
     if (false && empty($mail['attachments'])) {
         $this->logMail($mail, "SKIP");
         return false;
     }
     $post = new Post();
     $moblog_begin = "\n<div class=\"moblog-entry\">";
     $moblog_end = "\n</div>\n";
     if ($post->open("slogan = '{$slogan}'")) {
         $post->loadTags();
         $this->log("* 기존 글을 엽니다. (SLOGAN:{$slogan})");
         if (empty($post->tags)) {
             $post->tags = array();
         }
         $tags = $this->extractTags($mail);
         /* mail content will be changed */
         $post->tags = array_merge($post->tags, $tags);
         $post->content .= $moblog_begin . $this->_getDecoratedContent($mail, $docid);
         $post->modified = $mail['date'];
         $post->visibility = $this->visibility;
     } else {
         $this->log("* 새 글을 작성합니다. (SLOGAN:{$slogan})");
         if (isset($mail['date_year'])) {
             $post->title = str_replace(array('%Y', '%M', '%D'), array($mail['date_year'], $mail['date_month'], $mail['date_day']), $this->subject);
         } else {
             $post->title = str_replace(array('%Y', '%M', '%D'), array(date("Y"), date("m"), date("d")), $this->subject);
         }
         $post->userid = $this->userid;
         $post->category = $this->category;
         $post->tags = $this->extractTags($mail);
         /* Go with csv string, Tag class supports both string and array */
         $post->content = $moblog_begin . $this->_getDecoratedContent($mail, $docid);
         $post->contentformatter = getDefaultFormatter();
         $post->contenteditor = getDefaultEditor();
         $post->created = time();
         $post->acceptcomment = true;
         $post->accepttrackback = true;
         $post->visibility = $this->visibility;
         $post->published = time();
         $post->modified = $mail['date'];
         $post->slogan = $slogan;
         if (!$post->add()) {
             $this->logMail($mail, "ERROR");
             $this->log(_t("실패: 글을 추가하지 못하였습니다") . " : " . $post->error);
             return false;
         } else {
             CacheControl::flushCategory($post->category);
         }
     }
     /* 슬로건을 지워야만 문제가 발생하지 않습니다. */
     //unset($post->slogan);
     if (isset($mail['attachments']) && count($mail['attachments'])) {
         importlib("model.blog.api");
         $post->content .= "<div class=\"moblog-attachments\">\n";
         foreach ($mail['attachments'] as $mail_att) {
             $this->log("* " . _t("첨부") . " : {$mail_att['filename']}");
             $att = api_addAttachment(getBlogId(), $post->id, array('name' => $mail_att['filename'], 'content' => $mail_att['decoded_content'], 'size' => $mail_att['length']));
             if (!$att) {
                 $this->logMail($mail, "ERROR");
                 $this->log(_t("실패: 첨부파일을 추가하지 못하였습니다") . " : " . $post->error);
                 return false;
             }
             $alt = htmlentities($mail_att['filename'], ENT_QUOTES, 'utf-8');
             $content = '[##_1C|$FILENAME|width="$WIDTH" height="$HEIGHT" alt="' . $alt . '"|_##]';
             $content = str_replace('$FILENAME', $att['name'], $content);
             $content = str_replace('$WIDTH', $att['width'], $content);
             $content = str_replace('$HEIGHT', $att['height'], $content);
             $post->content .= $content;
         }
         $post->content .= "\n</div>";
     }
     $post->content .= $moblog_end;
     if (!$post->update()) {
         $this->logMail($mail, "ERROR");
         $this->log(_t("실패: 첨부파일을 본문에 연결하지 못하였습니다") . ". : " . $post->error);
         return false;
     }
     $this->logMail($mail, "OK");
     return true;
 }
 $undertitle = $database->escapeString($_POST['undertitle']);
 $pageId = $database->escapeString($_POST['pageId']);
 $body = $database->escapeString($_POST['body']);
 $d = new DateTime();
 $date = $d->format('Y-m-d H:i');
 $userId = $_SESSION['USID'];
 $post->setTitle($title);
 $post->setUnderTitle($undertitle);
 $post->setPageId($pageId);
 $post->setBody($body);
 $post->setDate($date);
 $post->setUserId($userId);
 if (isset($_POST['postId'])) {
     $postId = $database->escapeString($_POST['postId']);
     $post->setPostId($postId);
     $post->update($database);
     $post->deleteCategories($database);
 } else {
     $postId = $post->create($database);
 }
 if (isset($_POST['categories'])) {
     $categoriesArray = $_POST['categories'];
     foreach ($categoriesArray as $cat) {
         $post->givePostCategories($database, $postId, $cat);
     }
 }
 if (count($_FILES) != 0) {
     $error = 0;
     $files = array();
     $uploaddir = "../images/posts/large/";
     $uploaddirthumb = "../images/posts/thumb/";
Example #25
0
 public function update($datas = null, $where = null)
 {
     $this->unlink('image', $datas);
     parent::update($datas, $where);
 }
 public function updateStatut(Post $post)
 {
     $post->draft = Input::get('draft');
     $post->update();
     return Redirect::route('posts.index')->withMessage("L'article a été modifié");
 }
Example #27
0
function mt_setPostCategories()
{
    $params = func_get_args();
    $result = api_login($params[1], $params[2]);
    if ($result) {
        return $result;
    }
    $post = new Post();
    if (!$post->open($params[0])) {
        return new XMLRPCFault(1, "Posting error");
    }
    $category = null;
    if (is_null($params[3])) {
        $params[3] = array();
    }
    foreach ($params[3] as $cat) {
        if (array_key_exists('isPrimary', $cat) && $cat['isPrimary']) {
            $category = $cat['categoryId'];
        } else {
            if (is_null($category)) {
                $category = $cat['categoryId'];
            }
        }
    }
    if (!is_null($category)) {
        $post->category = intval($category);
        $post->update();
    }
    $post->close();
    return true;
}
Example #28
0
});
// Logout page
$app->get('/logout', function () use($app) {
    session_destroy();
    $app->redirect('/');
});
// Edit a post
$app->get('/edit/:id', $admin_logged_in($app), function ($id) use($app) {
    Data::$data['post'] = R::load('post', $id);
    $app->render('edit.php', Data::$data);
});
// Update a post
$app->post('/edit_post/:id', $admin_logged_in($app), function ($id) use($app) {
    $title = $app->request()->post('title');
    $body = $app->request()->post('body');
    if (Post::update($id, $title, $body)) {
        $app->redirect('/');
    } else {
        $app->redirect('/edit/' . $id);
    }
});
// Blog post page
$app->get('/:page', function ($page) use($app) {
    Data::$data['posts_all'] = R::find('post', '1 ORDER BY id DESC ');
    Data::$data['post'] = R::findOne('post', '1 ORDER BY id DESC LIMIT ' . $page . ',1');
    $count = count(Data::$data['posts_all']);
    Data::$data['next_page'] = $page;
    if ($count > $page + 1) {
        Data::$data['next_page'] += 1;
    } else {
        Data::$data['next_page'] = 0;