public function run() { if (WY_Request::isPost()) { $table_sql = array(); $migration = new WY_Migration(); $table_sql[] = $migration->createTable('wy_users', array('user_id' => 'pk', 'username' => 'string NOT NULL', 'pass' => 'string NOT NULL', 'email' => 'string NOT NULL', 'url' => 'string NOT NULL', 'date_registered' => 'datetime NOT NULL', 'activation' => 'string DEFAULT NULL', 'status' => 'string NOT NULL', 'display_name' => 'string NOT NULL')); $table_sql[] = $migration->createTable('wy_categories', array('cat_id' => 'pk', 'title' => 'string NOT NULL', 'date_add' => 'datetime NOT NULL', 'published' => 'tinyint(4) NOT NULL DEFAULT 0', 'date_modified' => 'datetime NULL', 'permalink' => 'string NOT NULL')); $table_sql[] = $migration->createTable('wy_comments', array('c_id' => 'pk', 'name' => 'string NOT NULL', 'email' => 'string NOT NULL', 'url' => 'string NOT NULL', 'date' => 'datetime NOT NULL', 'content' => 'text NOT NULL', 'post_id' => 'integer NULL', 'page_id' => 'integer NULL', 'ip' => 'varchar(15) NOT NULL', 'is_parent' => 'integer NOT NULL DEFAULT 0')); $table_sql[] = $migration->createTable('wy_pages', array('page_id' => 'pk', 'author' => 'integer NOT NULL', 'title' => 'string NOT NULL', 'date_add' => 'datetime NOT NULL', 'content' => 'longtext DEFAULT NULL', 'comment_open' => 'tinyint(4) NOT NULL', 'published' => 'tinyint(4) NOT NULL', 'date_modified' => 'datetime NULL', 'use_plugin' => 'string NULL', 'is_parent' => 'integer NOT NULL', 'permalink' => 'string NOT NULL', 'tag' => 'string NOT NULL')); $table_sql[] = $migration->createTable('wy_plugins', array('plugin_id' => 'pk', 'plugin_name' => 'string NOT NULL', 'plugin_path' => 'string NOT NULL', 'is_active' => 'tinyint(4) NOT NULL')); $table_sql[] = $migration->createTable('wy_posts', array('post_id' => 'pk', 'title' => 'string NOT NULL', 'cat_id' => 'integer NOT NULL', 'tag' => 'string NOT NULL', 'date_add' => 'datetime NOT NULL', 'author' => 'integer NOT NULL', 'content' => 'longtext NOT NULL', 'comment_open' => 'tinyint(4) NOT NULL', 'comment_count' => 'integer NOT NULL', 'permalink' => 'string NOT NULL', 'published' => 'tinyint(4) NOT NULL', 'date_modified' => 'datetime DEFAULT NULL')); $table_sql[] = $migration->createTable('wy_settings', array('id' => 'pk', 'key' => 'string NOT NULL', 'value' => 'string NULL', 'is_auto' => 'varchar(4) NULL')); $table_sql[] = $migration->createTable('wy_themes', array('themes_id' => 'pk', 'themes_name' => 'string NOT NULL', 'themes_path' => 'string NOT NULL', 'is_active' => 'tinyint(4) NOT NULL')); $table_sql[] = $migration->createTable('wy_usermetas', array('um_id' => 'pk', 'user_id' => 'integer NOT NULL', 'key_name' => 'string NOT NULL', 'key_value' => 'string NULL')); foreach ($table_sql as $sql) { WY_Db::execute($sql); } WY_Db::execute('INSERT INTO wy_users (`username`, `pass`, `email`, `url`, `date_registered`, `status`, `display_name`) VALUES (' . $this->quote(WY_Session::get('install.username')) . ', ' . $this->quote(sha1(WY_Session::get('install.password') . WY_Config::get('salt'))) . ', ' . $this->quote(WY_Session::get('install.email')) . ', ' . $this->quote(WY_Session::get('install.url')) . ', NOW(), "admin", ' . $this->quote(WY_Session::get('install.display_name')) . ')'); WY_Db::execute("INSERT INTO `wy_categories`(`title`, `date_add`, `published`, `permalink`) " . "VALUES " . "('Uncategories',NOW(),1,'uncategories')"); WY_Db::execute('INSERT INTO `wy_pages`' . '(`author`, `title`, `date_add`, `content`, `comment_open`, `published`, `use_plugin`, `is_parent`, `permalink`, `tag`) ' . 'VALUES ' . '(:author,:title,NOW(),:content,:comment_open,:published,:use_plugin,:is_parent,:permalink,:taglist)', array(':author' => (int) 1, ':title' => "First Page", ':content' => "<p style='text-align:justify'>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>\r\n <p style='text-align:justify'>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>\r\n ", ':comment_open' => (int) 0, ':published' => (int) 1, ':use_plugin' => (int) 0, ':is_parent' => (int) 0, ':permalink' => "first-page", ':taglist' => "First Page, Page")); WY_Db::execute('INSERT INTO `wy_posts`' . '(`cat_id`, `title`, `tag`, `date_add`, `author`, `content`, `comment_open`, `permalink`, `published`) ' . 'VALUES ' . '(:cat_id,:title,:tag,NOW(),:author,:content,:comment_open,:permalink,:published)', array(':cat_id' => 1, ':title' => "First Post", ':tag' => "Post, First Post", ':author' => (int) 1, ':content' => "<p style='text-align:justify'>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>\r\n <p style='text-align:justify'>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</p>\r\n ", ':comment_open' => (int) 1, ':permalink' => "first-post", ':published' => (int) 1)); WY_Response::redirect('install/result'); } $this->layout->content = WY_View::fetch('install/run'); $this->layout->pageTitle = 'Wayang - Initial Installation'; }
public function edit($id) { self::auth(); $page = WY_Db::row('SELECT * FROM wy_pages WHERE page_id = :id', array(':id' => (int) $id)); if (!$page) { $view = new WY_View('404'); $view->render(); exit; } $isParent = WY_Db::all('SELECT * FROM wy_pages WHERE is_parent = 0 AND page_id <> :id', array(':id' => (int) $id)); $plugins = WY_Db::all("SELECT * FROM `wy_plugins` WHERE `is_active` = 1 ORDER BY plugin_name ASC"); if (WY_Request::isPost()) { $title = $_POST['title']; if (isset($_POST['published'])) { $published = 1; } else { $published = 0; } if (isset($_POST['a_comment'])) { $comment = 1; } else { $comment = 0; } $isParent = $_POST['isParent']; $content = $_POST['content']; $tags = $_POST['tags']; $permalink = strtolower(str_replace(' ', '-', $title)); WY_Db::execute('UPDATE wy_pages SET title = :title, date_modified = NOW(), content = :content, published = :published, is_parent= :is_parent, permalink = :permalink, comment_open = :comment_open, tag = :taglist WHERE page_id = :id', array(':title' => $title, ':published' => $published, ':content' => $content, ':is_parent' => $isParent, ':comment_open' => $comment, ':permalink' => $permalink, ':taglist' => $tags, ':id' => (int) $id)); WY_Response::redirect('admin/pages/all'); } $this->layout->pageTitle = 'Wayang CMS - Pages Edit'; $this->layout->content = WY_View::fetch('admin/pages/edit', array('page' => $page, 'isParent' => $isParent, 'plugins' => $plugins)); }
public function login() { if (WY_Request::isPost()) { $username = $_POST['username']; $password = sha1($_POST['password'] . WY_Config::get('salt')); $this->log = WY_Auth::login($username, $password); if ($this->log) { WY_Response::redirect('admin'); } else { WY_Response::redirect('login'); } } }
public function edit($id) { self::auth(); $category = WY_Db::row('SELECT * FROM wy_categories WHERE cat_id = :id', array(':id' => (int) $id)); if (!$category) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $title = $_POST['title']; $published = $_POST['published']; $permalink = strtolower(str_replace(' ', '-', $title)); WY_Db::execute('UPDATE wy_categories SET title = :title, date_modified = NOW(), published = :published, permalink = :permalink WHERE cat_id = :id', array(':title' => $title, ':published' => $published, ':permalink' => $permalink, ':id' => (int) $id)); WY_Response::redirect('admin/categories/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit Category'; $this->layout->content = WY_View::fetch('admin/categories/edit', array('category' => $category)); }
public function edit($id) { self::auth(); $comment = WY_Db::row('SELECT * FROM wy_comments WHERE c_id = :id', array(':id' => (int) $id)); if (!$comment) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $content = $_POST['content']; WY_Db::execute('UPDATE `wy_comments` SET `name`=:name,`email`=:email,`url`=:url,`content`=:content WHERE `c_id` = :id', array(':name' => $name, ':email' => $email, ':url' => $url, ':content' => $content, ':id' => (int) $id)); WY_Response::redirect('admin/comments/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit Comment'; $this->layout->content = WY_View::fetch('admin/comments/edit', array('comment' => $comment)); }
public function add() { if (WY_Request::isPost()) { $name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $permalink = $_POST['p']; // $captcha = $_POST['captcha']; $content = $_POST['message']; if (isset($_POST['postid'])) { $post_id = $_POST['postid']; WY_Db::execute('INSERT INTO `wy_comments`(`name`, `email`, `url`, `date`, `content`, `post_id`, `ip`) ' . 'VALUES (:name,:email,:url,NOW(),:content,:post_id,"' . $_SERVER['REMOTE_ADDR'] . '")', array(':name' => $name, ':email' => $email, ':url' => $url, ':content' => htmlspecialchars($content), ':post_id' => $post_id)); WY_Response::redirect('post/' . $permalink); } else { $page_id = $_POST['pageid']; WY_Db::execute('INSERT INTO `wy_comments`(`name`, `email`, `url`, `date`, `content`, `page_id`, `ip`) VALUES (:name,:email,:url,NOW(),:content,:page_id,' . $_SERVER['REMOTE_ADDR'] . ')', array(':name' => $name, ':email' => $email, ':url' => $url, ':content' => htmlspecialchars($content), ':page_id' => $post_id)); WY_Response::redirect('page/' . $permalink); } } $this->layout->pageTitle = 'Wayang CMS - Add Category'; $this->layout->content = WY_View::fetch('admin/categories/new'); }
public function edit($id) { self::auth(); $post = WY_Db::row('SELECT * FROM wy_posts WHERE post_id = :id', array(':id' => (int) $id)); if (!$post) { $view = new WY_View('404'); $view->render(); exit; } $cat = WY_Db::all('SELECT * FROM wy_categories'); if (WY_Request::isPost()) { $title = $_POST['title']; if (isset($_POST['published'])) { $published = 1; } else { $published = 0; } if (isset($_POST['a_comment'])) { $comment = 1; } else { $comment = 0; } if ($_POST['permalink'] === "") { $permalink = strtolower(str_replace(' ', '-', $_POST['title'])); } else { $permalink = strtolower(str_replace(' ', '-', $_POST['permalink'])); } $content = $_POST['content']; $tags = $_POST['tags']; $cat_id = $_POST['category']; WY_Db::execute('UPDATE `wy_posts` SET' . '`cat_id` = :cat_id, `title` = :title, `tag` = :tag, `content` = :content, `comment_open` = :comment_open, `permalink` = :permalink, `published` = :published, `date_modified` = NOW() WHERE post_id = :id', array(':cat_id' => $cat_id, ':title' => $title, ':tag' => $tags, ':content' => $content, ':comment_open' => $comment, ':permalink' => $permalink, ':published' => $published, ':id' => (int) $id)); WY_Response::redirect('admin/posts/all'); } $this->layout->pageTitle = 'Wayang CMS - Pages Edit'; $this->layout->content = WY_View::fetch('admin/posts/edit', array('post' => $post, 'cat' => $cat)); }
echo $p->plugin_name; ?> </option> <?php } ?> <?php } ?> </select> </div> <div class="form-group"> <label>Page Content</label> <textarea id="content" name="content" class="form-control" rows="3"></textarea> <script type='text/javascript' src='<?php echo WY_Request::base_url(); ?> /assets/admin/ckeditor/config.editor.js'></script> <p class="help-block">Leave blank if use plugin or module.</p> </div> <div class="form-group"> <label>Allow Comment</label> <div class="checkbox"> <label> <input name="a_comment" type="checkbox" value="">Allow Comment on Page </label> </div> </div> <div class="form-group"> <label>Published</label> <div class="checkbox">
/** * redirect pengguna ke url tertentu * @param string $to url redirect * @param int $statusCode status header yang di tetapkan untuk redirect */ public function redirect($to, $statusCode = 302) { header('Location: ' . WY_Request::base_url() . '/' . $to, true, $statusCode); exit; }
private function save($file, $resize = FALSE, $x = NULL, $y = NULL, $compression = 70) { $this->getInfo($file); $this->path = WY_Request::base_url() . "/assets/uploads/"; if (!$resize) { if ($this->imageType == IMAGETYPE_JPEG) { if (imagejpeg($this->image, $this->path, $compression)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } elseif ($this->imageType == IMAGETYPE_GIF) { if (imagegif($this->image, $this->path)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } elseif ($this->imageType == IMAGETYPE_PNG) { if (imagepng($this->image, $this->path)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } } else { $this->resizeImage($percent); $this->imageThumbnail(); if ($this->imageType == IMAGETYPE_JPEG) { if (imagejpeg($this->image, $this->path, $compression)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } elseif ($this->imageType == IMAGETYPE_GIF) { if (imagegif($this->image, $this->path)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } elseif ($this->imageType == IMAGETYPE_PNG) { if (imagepng($this->image, $this->path)) { $this->message = "Image Saved!"; } else { $this->message = "Cannot Save Image!"; } } } return $this->message; }
public function edit($id) { self::auth(); $user = WY_Db::row('SELECT * FROM `wy_users` WHERE `user_id` = :id', array(':id' => (int) $id)); if (!$user) { $view = new WY_View('404'); $view->render(); exit; } if (WY_Request::isPost()) { $username = $_POST['username']; $email = $_POST['email']; $display = $_POST['display']; $url = $_POST['url']; $level = $_POST['level']; if (isset($_POST['password']) && $_POST['password'] === "") { $sql = "UPDATE `wy_users` SET `username`=:username,`email`=:email,`display_name`=:display,`url`=:url,`status`=:level WHERE `user_id`=:id"; WY_Db::execute($sql, array(':username' => $username, ':email' => $email, ':display' => $display, ':url' => $url, ':level' => $level, ':id' => (int) $id)); } else { $password = $_POST['password']; $sql = "UPDATE `wy_users` SET `username`=:username,`pass`=:password,`email`=:email,`display_name`=:display,`url`=:url,`status`=:level WHERE `user_id`=:id"; WY_Db::execute($sql, array(':username' => $username, ':password' => sha1($password . WY_Config::get('salt')), ':email' => $email, ':display' => $display, ':url' => $url, ':level' => $level, ':id' => (int) $id)); } WY_Response::redirect('admin/users/all'); } $this->layout->pageTitle = 'Wayang CMS - Edit User'; $this->layout->content = WY_View::fetch('admin/users/edit', array('user' => $user)); }