Example #1
0
 public function post_add_page()
 {
     $rules = Config::get('rules.add_page');
     $validation = Validator::make(Input::get(), $rules);
     if ($validation->passes()) {
         if (Page::add(Input::get())) {
             return Redirect::to('add_page')->with('success', TRUE);
         }
         return Event::first('500', 'The page could not be added due to a system error. We apologize for any inconvenience.');
     }
     return Redirect::to('add_page')->with_input()->with_errors($validation);
 }
Example #2
0
	 *	N/X 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 2 of the License, or
	 *	(at your option) any later version.
	 *
	 *	N/X 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 N/X; if not, write to the Free Software
	 *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
	**********************************************************************/
	
	require_once "../../config.inc.php";
	$auth = new auth("ANY");
	require_once "nxtoday.inc.php";

	$nxtoday = new NXToday();
	$nxtoday->QuickLinks->add(new NXToday_SPLink(100140));
	$nxtoday->QuickLinks->add(new NXToday_ChannelLink("News"));
	$nxtoday->QuickLinks->add(new NXToday_SPLink(100083));
	$nxtoday->QuickLinks->add(new NXToday_ChannelLink("test"));


$page = new Page('N/X Today');
$page->add($nxtoday);
$page->draw();
?>
Example #3
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 #4
0
<?php

require 'Renderers.php';
class Page
{
    protected $renderers = [];
    public function add(Renderer $renderer)
    {
        $this->renderers[] = $renderer;
    }
    public function render()
    {
        $content = '';
        $content .= "--Start of Page--\n";
        $content .= array_reduce($this->renderers, function ($output, $r) {
            return $output .= $r->render() . "\n";
        }, '');
        $content .= "--End of Page--\n";
        return $content;
    }
}
$page = new Page();
$page->add(new BlogRenderer());
$page->add(new ArticleRenderer());
$page->add(new GraphRenderer());
// $page->add(new Page());
echo $page->render();
Example #5
0
require_once $c["path"] . "api/userinterface/wizard/stcheckarchive.php";
require_once $c["path"] . "api/userinterface/wizard/stimportimages.php";
$wizard = new Wizard($lang->get("imp_impages", "Import Images"));
$wizard->setTitleText($lang->get("wz_import_im_title", "This wizard is used for importing importing images to N/X. Pack the images into a zip archive. The wizard will then create the data."));
if ($wizard->firstRun) {
    $_SESSION["archivefolder"] = "";
}
////// STEP 1 //////
$step1 = new Step();
$step1->setTitle($lang->get("wzt_archive_file", "Select Archive"));
$step1->setExplanation($lang->get("wze_archive_file", "Please select the zip-archive you want to import. The images must be into that archive in a flat structure, having no folders."));
$step1->add(new WZUploadArchive("upload"));
$step2 = new STCheckArchive();
$step2->setTitle($lang->get("wzt_ach_check", "Check Archive"));
$step2->setExplanation($lang->get("wze_arch_check", "Please control the result of the archive checks and press next if you want to resume."));
$step3 = new Step();
$step3->setTitle($lang->get("wzt_dest_folder", "Select destination folder"));
$step3->setExplanation($lang->get("wze_dest_folder", "Please select the folder, where all the new pictures will be copied to."));
$folders = array();
createFolders($folders, ' / ', 0);
$step3->add(new WZSelect('folder', $lang->get("dest_folder", "Destination folder"), $folders));
$step4 = new STImportImages();
$step4->setTitle($lang->get("wzt_imp_imag", "Importing images..."));
$wizard->add($step1);
$wizard->add($step2);
$wizard->add($step3);
$wizard->add($step4);
$page->add($wizard);
$page->draw();
$db->close();
echo $errors;
Example #6
0
<?php

require 'vendor/autoload.php';
require 'modules/appSettings.inc.php';
require 'modules/JsonSettings.class.php';
require 'modules/actionsRedirector.php';
if (!$isAction) {
    require 'modules/Page.class.php';
    $page = new Page();
    $page->add("header");
    $page->add("controls");
    $page->add("footer", $page->js());
}
 function addWordpressPage(Page $p, CollectionType $ct, PageLite $pl, $xmlID)
 {
     /*		echo $pl->getPostdate();
     		exit;
     		*/
     $u = new User();
     $pageAuthor = $pl->getAuthor();
     $ui = UserInfo::getByUserName($pageAuthor);
     if (is_object($ui)) {
         $uID = $ui->getUserID();
     } else {
         $uID = $u->getUserID();
     }
     $pageData = array('cName' => $pl->getTitle(), 'cDatePublic' => $pl->getPostdate(), 'cDateAdded' => $pl->getPostdate(), 'cDescription' => $pl->getExcerpt(), 'uID' => $uID);
     $newPage = $p->add($ct, $pageData);
     if (is_array($pl->getCategory())) {
         $newPage->setAttribute('wordpress_category', $pl->getCategory());
     }
     if (is_array($pl->getTags())) {
         $newPage->setAttribute('tags', $pl->getTags());
     }
     if (count($pl->getComments()) > 0) {
         $blocks = $newPage->getBlocks("Blog Post Footer");
         $haveGuestbook = 0;
         foreach ($blocks as $block) {
             if ($block->getBlockTypeHandle() == "guestbook") {
                 $bID = $block->getBlockID();
                 $haveGuestbook = 1;
             }
         }
         if ($haveGuestbook == 0) {
             $data = array();
             $data['title'] = "Comments:";
             $data['dateFormat'] = "M jS, Y";
             $data['requireApproval'] = 0;
             $data['displayGuestBookForm'] = 1;
             $data['authenticationRequired'] = 0;
             $data['displayCaptcha'] = 1;
             $bt = BlockType::getByHandle("guestbook");
             $guestbook = $newPage->addBlock($bt, "Blog Post Footer", $data);
             $bID = $guestbook->getBlockID();
         }
         Loader::model('comment_lite', 'wordpress_site_importer');
         $comments = $pl->getComments();
         foreach ($comments as $comment) {
             if (!$comment['comment_type'] == "pingback") {
                 CommentLite::addcomment($bID, $comment['commentText'], $comment['name'], $comment['email'], $comment['approved'], $newPage->getCollectionID(), 0, $comment['comment_date']);
             }
         }
     }
     $blocks = $newPage->getBlocks("Main");
     foreach ($blocks as $block) {
         $block->delete();
     }
     $blocks = $newPage->getBlocks("Blog Post More");
     foreach ($blocks as $block) {
         $block->delete();
     }
     Loader::model('block_types');
     $bt = BlockType::getByHandle('content');
     $data = array();
     $data['content'] = $this->importImages ? $this->determineImportableMediaFromContent($pl->getContent(), $pageData) : $pl->getContent();
     //we're either importing images or not
     $newPage->addBlock($bt, "Main", $data);
     $db = Loader::db();
     $q = 'UPDATE WordpressItems SET cID = ?, wpID = ?, wpParentID = ?, wpPostType = ? WHERE id=?';
     $v = array($newPage->getCollectionID(), $pl->getPostID(), $pl->getWpParentID(), $pl->getPostType(), $xmlID);
     $res = $db->query($q, $v);
     return $newPage;
 }
Example #8
0
 *    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 N/X; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 **********************************************************************/
require_once "../../config.inc.php";
require_once "ingredient_editor.php";
require_once "tag_selector.php";
$auth = new auth("ADMINISTRATOR");
$page = new Page("Edit Recipe");
$form = new stdEDForm($lang->get("edrecipe", "Edit Recipe"));
$cond = $form->setPK("pgn_recipes", "ID");
$form->addHeaderLink(crHeaderLink($lang->get("back"), "plugin/recipe/overview.php?sid=" . $sid));
$form->add(new TextInput($lang->get("name", "NAME"), "pgn_recipes", "NAME", $cond, "type:text,size:64,width:200", "MANDATORY"));
if ($page_action == "UPDATE") {
    $values = createNameValueArrayEx("pgn_recipes_tags", "TAG", "TAG_ID", "1", "ORDER BY TAG ASC");
    $form->add(new TagEditor("Tags", "pgn_recipes_tag_relation", "REC_ID", $oid, "TAG_ID", $values));
}
$form->add(new SubTitle("st", $lang->get("ingredients", "Ingredients"), 2));
$form->add(new IngredientEditor("pgn_recipes", $cond));
$form->add(new SubTitle("st", $lang->get("preparation", "Preparation"), 2));
$form->add(new TextInput($lang->get("preparation", "Preparation"), "pgn_recipes", "PREPARATION", $cond, "type:textarea,size:6,width:300", ""));
$form->add(new TextInput($lang->get("description", "Description"), "pgn_recipes", "DESCRIPTION", $cond, "type:textarea,size:6,width:300", ""));
$deleteHandler = new ActionHandler("DELETE");
$deleteHandler->addDbAction("DELETE FROM pgn_recipes WHERE ID={$oid} ");
$deleteHandler->addDbAction("DELETE FROM pgn_recipes_tag_relation WHERE REC_ID={$oid} ");
$form->registerActionHandler($deleteHandler);
$page->add($form);
$page->draw();
<?php

$this->addScript('/admin/js/ckeditor/ckeditor.js');
$this->addScript('/admin/js/ckeditor/adapters/jquery.js');
$objPage = new Page($this->objLanguage);
$objForm = new Form($this->objUrl);
$objValidation = new Validation($this->objLanguage);
$expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
$required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
if (isset($_POST['name'])) {
    $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise'));
    if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'])) {
        $objValidation->add2Errors('identity', 'identity_taken');
    }
    if ($objValidation->isValid($array, $required)) {
        if ($objPage->add($array)) {
            Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index');
        }
    }
}
require_once 'header.php';
?>

<h1><?php 
echo $this->objLanguage->labels[9];
?>
</h1>

<form method="post">
	<table class="tbl_insert">
		<tr>
Example #10
0
 public static function addArticleAction()
 {
     $titre = !empty($_POST['titre']) ? $_POST['titre'] : "Draft";
     $slug = !empty($_POST['slug']) ? $_POST['slug'] : "draft";
     $content = !empty($_POST['content']) ? $_POST['content'] : "";
     $shortDesc = strip_tags($content);
     $post_status = $_POST['post_status'] == 0 ? "publish" : $_POST['post_status'];
     $visibilite = $_POST['visibilite'] == 'password' && !empty($_POST['password']) ? $_POST['password'] : $_POST['visibilite'];
     $date = !empty($_POST['date']) ? $_POST['date'] : date("Y-m-d H:i:s");
     $tags = !empty($_POST['tags']) ? $_POST['tags'] : "";
     $format = $_POST['format'];
     $terms = !empty($_POST['terms']) ? $_POST['terms'] : 0;
     // echo json_encode($_POST);
     $page = new Page();
     $page->post_author = 1;
     $page->post_date = $date;
     $page->post_date_gmt = $date;
     $page->post_content = $content;
     $page->post_short_content = $shortDesc;
     $page->post_title = $titre;
     $page->post_status = $post_status;
     $page->comment_status = "open";
     $page->post_password = "";
     $page->post_name = $slug;
     $page->post_modified = "";
     $page->post_modified_gmt = "";
     $page->post_parent = 0;
     $page->guid = Config::get('app.base_url') . "page/t/" . $slug;
     //url
     $page->post_type = "post";
     $page->post_mime_type = "";
     $page->comment_count = 0;
     $page->terms_id = $terms;
     if ($page->add()) {
         switch ($format) {
             case "image":
                 break;
             case "video":
                 $media = new Media();
                 $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
                 $media->media_type = "video";
                 $media->media_name = $_POST['video_type'];
                 $media->media_value = $_POST['videoid'];
                 $media->post_id = $getLastPosts['ID'];
                 $media->add();
                 break;
             case "audio":
                 $media = new Media();
                 $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
                 $media->media_type = "audio";
                 $media->media_name = $_POST['audio_type'];
                 $media->media_value = $_POST['audioid'];
                 $media->post_id = $getLastPosts['ID'];
                 $media->add();
                 break;
         }
         if ($tags !== "") {
             $tagsOB = new Tag();
             $getLastPosts = self::getPage("posts", "post_type='post'  ORDER BY ID DESC limit 0,1")[0];
             $tagsOB->tag_value = $tags;
             $tagsOB->post_id = $getLastPosts['ID'];
             $tagsOB->add();
         }
         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Succeful !!");
         header("Content-type: application/json; charset=utf-8");
         echo json_encode($arr);
     } else {
         $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Error d'insertion");
         header("Content-type: application/json; charset=utf-8");
         echo json_encode($arr);
     }
 }
 public function DisplayStatistics(Page $oPage)
 {
     $aStats = array('Number of objects exported' => $this->aStatistics['objects_count'], 'Total export duration' => sprintf('%.3f s', $this->aStatistics['total_duration']), 'Data retrieval duration' => sprintf('%.3f s', $this->aStatistics['data_retrieval_duration']), 'Excel build duration' => sprintf('%.3f s', $this->aStatistics['excel_build_duration']), 'Excel write duration' => sprintf('%.3f s', $this->aStatistics['excel_write_duration']), 'Peak memory usage' => self::HumanDisplay($this->aStatistics['peak_memory_usage']));
     if ($oPage instanceof CLIPage) {
         $oPage->add($this->GetStatistics('text'));
     } else {
         $oPage->add($this->GetStatistics('html'));
     }
 }
Example #12
0
File: Basic.php Project: atk4/atk4
 /**
  * Creates log-in form.
  * Override if you want to use your own form. If you need to change template used by a log-in form,
  * add template/default/page/login.html.
  *
  * @param Page $page
  *
  * @return Form
  */
 public function createForm($page)
 {
     /** @type Form $form */
     $form = $page->add('Form', null, null, array('form/minimal'));
     /** @type Field $email */
     $email = $this->model->hasField($this->login_field);
     $email = $email ? $email->caption() : 'E-mail';
     /** @type Field $password */
     $password = $this->model->hasField($this->password_field);
     $password = $password ? $password->caption() : 'Password';
     $form->addField('Line', 'username', $email);
     $form->addField('Password', 'password', $password);
     $form->addSubmit('Login')->addClass('atk-jackscrew')->addClass('atk-swatch-green');
     //$form->add('View',null,'button_row_left')->addClass('atk-jackscrew');
     return $form;
 }
Example #13
0
function Usage(Page $oP)
{
    if (Utils::IsModeCLI()) {
        $oP->p('Usage: php ' . basename(__FILE__) . ' --auth_user=<user> --auth_pwd=<password> --expression=<OQL Query> --query=<phrasebook_id> [--arg_xxx=<query_arguments>] [--no_localize=0|1] [--format=<format>] [--format-options...]');
        $oP->p("Parameters:");
        $oP->p(" * auth_user: the iTop user account for authentication");
        $oP->p(" * auth_pwd: the password of the iTop user account");
    } else {
        $oP->p("Parameters:");
    }
    $oP->p(" * expression: an OQL expression (e.g. SELECT Contact WHERE name LIKE 'm%')");
    $oP->p(" * query: (alternative to 'expression') the id of an entry from the query phrasebook");
    $oP->p(" * arg_xxx: (needed if the query has parameters) the value of the parameter 'xxx'");
    $aSupportedFormats = BulkExport::FindSupportedFormats();
    $oP->p(" * format: (optional, default is html) the desired output format. Can be one of '" . implode("', '", array_keys($aSupportedFormats)) . "'");
    foreach ($aSupportedFormats as $sFormatCode => $sLabel) {
        $oExporter = BulkExport::FindExporter($sFormatCode);
        if ($oExporter !== null) {
            if (!Utils::IsModeCLI()) {
                $oP->add('<hr/>');
            }
            $oExporter->DisplayUsage($oP);
            if (!Utils::IsModeCLI()) {
                $oP->add('</div>');
            }
        }
    }
    if (!Utils::IsModeCLI()) {
        //$oP->add('</pre>');
    }
}
Example #14
0
     $response = Group::add(_::str('name'), _::str('description'));
     break;
 case 'group.all':
     $response = Page::all();
     break;
 case 'group.get':
     $response = Group::get(_::int('group'));
     break;
 case 'group.student':
     $response = Group::student(_::int('group'), _::int('student'));
     break;
 case 'group.notify':
     $response = Group::notify(_::int('group'), _::int('author'), _::str('header'), _::str('text'));
     break;
 case 'page.add':
     $response = Page::add(_::str('title'), _::raw('text'), _::int('author'));
     break;
 case 'page.all':
     $response = Page::all();
     break;
 case 'page.get':
     $response = Page::get(_::int('id'));
     break;
 case 'page.edit':
     $response = Page::edit(_::int('id'), _::str('title'), _::raw('text'));
     break;
     /** @subsection Обработка ошибочного запроса */
 /** @subsection Обработка ошибочного запроса */
 default:
     Api::error(0, $method . ' : Неверный запрос к Api');
     // Все прочие запросы игнорируются
Example #15
0
File: Admin.php Project: eadz/chyrp
 /**
  * Function: import_movabletype
  * MovableType importing.
  */
 public function import_movabletype()
 {
     if (empty($_POST)) {
         redirect("/admin/?action=import");
     }
     if (!Visitor::current()->group->can("add_post")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
     }
     $config = Config::current();
     $trigger = Trigger::current();
     $dbcon = $dbsel = false;
     if ($link = @mysql_connect($_POST['host'], $_POST['username'], $_POST['password'])) {
         $dbcon = true;
         $dbsel = @mysql_select_db($_POST['database'], $link);
     }
     if (!$dbcon or !$dbsel) {
         Flash::warning(__("Could not connect to the specified MovableType database."), "/admin/?action=import");
     }
     mysql_query("SET NAMES 'utf8'");
     $get_authors = mysql_query("SELECT * FROM mt_author ORDER BY author_id ASC", $link) or error(__("Database Error"), mysql_error());
     $users = array();
     while ($author = mysql_fetch_array($get_authors)) {
         # Try to figure out if this author is the same as the person doing the import.
         if ($author["author_name"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->login or $author["author_nickname"] == Visitor::current()->full_name or $author["author_url"] == Visitor::current()->website or $author["author_email"] == Visitor::current()->email) {
             $users[$author["author_id"]] = Visitor::current();
         } else {
             $users[$author["author_id"]] = User::add($author["author_name"], $author["author_password"], $author["author_email"], $author["author_nickname"] != $author["author_name"] ? $author["author_nickname"] : "", $author["author_url"], $author["author_can_create_blog"] == "1" ? Visitor::current()->group : null, $author["author_created_on"], false);
         }
     }
     $get_posts = mysql_query("SELECT * FROM mt_entry ORDER BY entry_id ASC", $link) or error(__("Database Error"), mysql_error());
     $posts = array();
     while ($post = mysql_fetch_array($get_posts)) {
         $posts[$post["entry_id"]] = $post;
     }
     foreach ($posts as $post) {
         $body = $post["entry_text"];
         if (!empty($post["entry_text_more"])) {
             $body .= "\n\n<!--more-->\n\n" . $post["entry_text_more"];
         }
         $regexp_url = preg_quote($_POST['media_url'], "/");
         if (!empty($_POST['media_url']) and preg_match_all("/{$regexp_url}([^\\.\\!,\\?;\"\\'<>\\(\\)\\[\\]\\{\\}\\s\t ]+)\\.([a-zA-Z0-9]+)/", $body, $media)) {
             foreach ($media[0] as $matched_url) {
                 $filename = upload_from_url($matched_url);
                 $body = str_replace($matched_url, $config->url . $config->uploads_path . $filename, $body);
             }
         }
         $status_translate = array(1 => "draft", 2 => "public", 3 => "draft", 4 => "draft");
         $clean = oneof($post["entry_basename"], sanitize($post["entry_title"]));
         if (empty($post["entry_class"]) or $post["entry_class"] == "entry") {
             $new_post = Post::add(array("title" => $post["entry_title"], "body" => $body, "imported_from" => "movabletype"), $clean, Post::check_url($clean), "text", @$users[$post["entry_author_id"]], false, $status_translate[$post["entry_status"]], oneof(@$post["entry_authored_on"], @$post["entry_created_on"], datetime()), $post["entry_modified_on"], "", false);
             $trigger->call("import_movabletype_post", $post, $new_post, $link);
         } elseif (@$post["entry_class"] == "page") {
             $new_page = Page::add($post["entry_title"], $body, null, 0, true, 0, $clean, Page::check_url($clean));
             $trigger->call("import_movabletype_page", $post, $new_page, $link);
         }
     }
     mysql_close($link);
     Flash::notice(__("MovableType content successfully imported!"), "/admin/?action=import");
 }
Example #16
0
    if (isset($_POST['lat'], $_POST['lng'])) {
        $_SESSION['id'] = uniqid();
        $_SESSION['status'] = 'alerted';
        // Try alerting the database
    } else {
        if (isset($_POST['phone']) || isset($_POST['fname']) || isset($_POST['lname'])) {
            htmlspecialchars($_POST['phone'], ENT_QUOTES);
            htmlspecialchars($_POST['fname'], ENT_QUOTES);
            htmlspecialchars($_POST['lname'], ENT_QUOTES);
            $_SESSION['status'] = 'identified';
        }
    }
}
require_once __DIR__ . '/source/php/ast/Page.php';
$index = new Page('en');
$index->add(__DIR__ . '/source/template/head.tpl');
switch ($_SESSION['status']) {
    case 'new':
        $index->add(__DIR__ . '/source/template/index.tpl');
        break;
    case 'alerted':
        $index->add(__DIR__ . '/source/template/alert.tpl');
        break;
    case 'identified':
        $index->add(__DIR__ . '/source/template/ident.tpl');
        break;
}
$index->add(__DIR__ . '/source/template/call_links.tpl');
$index->add(__DIR__ . '/source/template/footer.tpl');
$index->setPath(__DIR__ . '/source/locale/home_{LANG}.json');
$index->setFall('en');
Example #17
0
            $_config->set("ordertype", $httpParam->ordertype(), "options");
        }
        $db->query($_config->query(), $_config->options());
        $xmlString = $db->fetch_all();
    }
} else {
    // execute activities without database
    $activity = new Activity($httpParam, $_config);
    $xmlString = $_config->html();
}
// =====================================
// transform data for display
$xml = new Xml($xmlString);
// add parameters for xslt transformation
# page data
$page_obj->add("script", $_SERVER["SCRIPT_NAME"]);
$page_obj->add("lang", $lang);
$page_obj->add("order", $order);
$page_obj->add("ordertype", $ordertype);
if ($scroll) {
    $page_obj->add("scroll", $scroll);
}
if ($httpParam->cmd()) {
    $page_obj->add("cmd", $httpParam->cmd());
}
# authentivication data
if (isset($_SESSION["logged"])) {
    $page_obj->add("auth", $_SESSION["logged"]);
    $page_obj->add("user", $_SESSION["user"]);
}
# page call id
Example #18
0
function DoExport(Page $oP, BulkExport $oExporter, $bInteractive = false)
{
    $exportResult = $oExporter->GetHeader();
    $aStatus = array();
    do {
        $exportResult .= $oExporter->GetNextChunk($aStatus);
    } while ($aStatus['code'] != 'done' && $aStatus['code'] != 'error');
    if ($aStatus['code'] == 'error') {
        $oExporter->Cleanup();
        ReportErrorAndExit("Export failed: '{$aStatus['message']}'");
    } else {
        $exportResult .= $oExporter->GetFooter();
        $oP->SetContentType($oExporter->GetMimeType());
        $oP->add($exportResult);
        $oExporter->Cleanup();
    }
}
Example #19
0
<?php

include_once __DIR__ . "/../autoloader.php";
switch ($_POST["type"]) {
    case "Page":
        $id = isset($_POST["id"]) ? $_POST["id"] : "";
        $is_event = isset($_POST["is_event"]) ? TRUE : FALSE;
        $title = isset($_POST["title"]) ? $_POST["title"] : "";
        $content = isset($_POST["content"]) ? $_POST["content"] : "";
        $date = isset($_POST["date"]) ? $_POST["date"] : "";
        $author = isset($_POST["author"]) ? $_POST["author"] : "";
        $page = new Page($title, $content, $date, "", $author, $is_event);
        //echo $title, $content, $author;
        $pdo_singleton = new PDOSingleton();
        if ($_GET["mode"] == 1) {
            $page->add();
            echo "Adding complete";
            header("location: admin.php?page=page&mode=2");
        } elseif ($_GET["mode"] == 2) {
            $page->modify($id);
            echo 'Modification complete';
            header("location: admin.php?page=page&mode=2");
        } else {
            echo "Error : no correct mode";
        }
        break;
}