Exemplo n.º 1
0
 /**
  * Inisialisasi konfigurasi inti sistem
  * 
  */
 public function initConfiguration()
 {
     if (!WY_Config::load('wy_config/config.php')) {
         $this->runInstaller();
         exit;
     }
     date_default_timezone_set(WY_Config::get('timezone') ? WY_Config::get('timezone') : 'Asia/Jakarta');
 }
Exemplo n.º 2
0
 /**
  * Memuat file konfigurasi berdasarkan path yang diberikan
  * @param string $config_path lokasi ke file konfigurasi
  */
 public static function load($config_path)
 {
     if (file_exists($config_path)) {
         self::$config_items = (include $config_path);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 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');
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Melakukan koneksi ke database menggunakan driver PDO
  * @access private
  * @return mixed mengembalikan instance dari kelas PDO jika berhasil, null jika gagal
  */
 private static function connect()
 {
     if (!isset(self::$conn)) {
         $conf = WY_Config::get('db');
         $dsn = "mysql:host=" . $conf['host'] . ";port=" . $conf['port'] . ";dbname=" . $conf['dbname'];
         try {
             self::$conn = new PDO($dsn, $conf['username'], $conf['password']);
             self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             self::$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
         } catch (PDOException $e) {
             self::disconnect();
             echo $e->getMessage();
         }
     }
     return self::$conn;
 }
Exemplo n.º 5
0
 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';
 }
Exemplo n.º 6
0
 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));
 }