示例#1
0
 public function index()
 {
     $this->menu();
     $this->sidebar();
     $posts = WY_Db::all('select * from wy_posts WHERE published=1 order by date_add');
     $this->layout->content = WY_View::fetch('themes/default/index', array('posts' => $posts));
     $this->layout->pageTitle = 'Wayang - Home';
 }
示例#2
0
 public function index($permalink)
 {
     $this->menu();
     $this->sidebar();
     $cats = WY_Db::row("select * from wy_categories WHERE permalink=:permalink", array("permalink" => $permalink));
     $posts = WY_Db::all("select * from wy_posts WHERE published=1 AND cat_id=:cat_id order by date_add", array("cat_id" => $cats->cat_id));
     $this->layout->content = WY_View::fetch('themes/default/label', array('posts' => $posts, 'cats' => $cats));
     $this->layout->pageTitle = 'Wayang - Search ';
 }
示例#3
0
 public function index($permalink)
 {
     $this->menu();
     $this->sidebar();
     $post = WY_Db::row("select * from wy_posts where permalink = :permalink", array(':permalink' => $permalink));
     $comment = WY_Db::all("SELECT name,date_format(date,'%b %d %Y %h:%i %p') as date,content from wy_comments WHERE post_id =:id", array(':id' => $post->post_id));
     $this->layout->content = WY_View::fetch('themes/default/post', array('post' => $post, 'comment' => $comment));
     $this->layout->pageTitle = 'Wayang - ' . $post->title;
 }
示例#4
0
 public function index()
 {
     self::auth();
     $pages = WY_Db::row("SELECT COUNT(*) as num FROM wy_pages");
     $posts = WY_Db::row("SELECT COUNT(*) as num FROM wy_posts");
     $comments = WY_Db::row("SELECT COUNT(*) as num FROM wy_comments");
     $users = WY_Db::row("SELECT COUNT(*) as num FROM wy_users");
     $this->layout->pageTitle = 'Wayang CMS - Dashboard';
     $this->layout->content = WY_View::fetch('admin/home/statistic', array("pages" => $pages, "posts" => $posts, "comments" => $comments, "users" => $users));
 }
示例#5
0
 public function index($permalink)
 {
     $this->menu();
     $this->sidebar();
     $page = WY_Db::row("select * from wy_pages where permalink = :permalink", array(':permalink' => $permalink));
     if ($page->use_plugin == 0) {
         $this->layout->content = WY_View::fetch('themes/default/page', array('page' => $page));
         $this->layout->pageTitle = 'Wayang - ' . $page->title;
     } else {
         $plug = WY_Db::row("select * from wy_plugins where plugin_id = :id", array(':id' => $page->use_plugin));
         $this->layout->content = WY_View::fetch('plugins/' . $plug->plugin_path . '/index', array('page' => $page, 'plugin' => $plug));
         $this->layout->pageTitle = 'Wayang - ' . $plug->plugin_name;
     }
 }
示例#6
0
 /**
  * Melakukan proses login pada sistem
  * @param string $username username yang mau di-check
  * @param string $password password yang mau di-check
  * @return boolean true bila login sukses, false jika login gagal
  */
 public static function login($username, $password)
 {
     $user = WY_Db::row("select * from wy_users where username = :username and pass = :password", array(':username' => $username, ':password' => $password));
     if ($user) {
         // login sukses
         WY_Session::set('authenticated', true);
         WY_Session::set('user_id', $user->user_id);
         WY_Session::set('user_name', $user->username);
         WY_Session::set('display', $user->display_name);
         return true;
     } else {
         // login gagal
         WY_Session::set_flash('error', 'Invalid username or password');
         return false;
     }
 }
 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 delete($id)
 {
     self::auth();
     WY_Db::execute('DELETE FROM wy_categories WHERE cat_id = :id', array(':id' => (int) $id));
     WY_Response::redirect('admin/categories/all');
 }
 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 &quot;de Finibus Bonorum et Malorum&quot; (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, &quot;Lorem ipsum dolor sit amet..&quot;, 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 &quot;de Finibus Bonorum et Malorum&quot; 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 &quot;de Finibus Bonorum et Malorum&quot; (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, &quot;Lorem ipsum dolor sit amet..&quot;, 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 &quot;de Finibus Bonorum et Malorum&quot; 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';
 }
示例#10
0
 public function delete($id)
 {
     self::auth();
     WY_Db::execute('DELETE FROM wy_pages WHERE page_id = :id', array(':id' => (int) $id));
     WY_Db::execute('DELETE FROM wy_comments WHERE page_id = :id', array(':id' => (int) $id));
     WY_Response::redirect('admin/pages/all');
 }
示例#11
0
 /**
  * Memutuskan koneksi ke database
  * 
  */
 public static function disconnect()
 {
     self::$conn = null;
 }