Ejemplo n.º 1
0
 private function phpauth()
 {
     $dbh = MY\Database\SQL::getInstance()->connect();
     $config = new PHPAuth\Config($dbh, 'options');
     $auth = new PHPAuth\Auth($dbh, $config);
     return $auth;
 }
Ejemplo n.º 2
0
 public static function getAllDates($type)
 {
     $sql = "SELECT DISTINCT DATE_FORMAT(date, '%Y-%m') AS `val_date`, DATE_FORMAT(date, '%M %Y') AS `date` FROM `posts`\r\n                WHERE `type` = '" . $type . "'\r\n                ORDER BY `date` DESC";
     $query = Database\SQL::getInstance()->results($sql);
     if (!is_array($query)) {
         $query = [];
     }
     return $query;
 }
Ejemplo n.º 3
0
 private static function prepare($parent)
 {
     $sql = "SELECT a.id `id`, a.parent `parent`, a.name `name`, a.url `url`, b.count `count` FROM menus a\r\n                LEFT OUTER JOIN (\r\n                  SELECT `parent`, COUNT(*) `count` FROM `menus` GROUP BY `parent`\r\n                ) b ON a.id = b.parent\r\n                INNER JOIN `menu_themes` c ON a.theme = c.id\r\n                WHERE a.parent = '" . $parent . "' AND c.name = '" . strtolower(trim(Options::get('themes'))) . "'\r\n                ORDER BY a.position ASC";
     $query = Database\SQL::getInstance()->results($sql);
     if (!$query) {
         return [];
     }
     return $query;
 }
Ejemplo n.º 4
0
 public static function update($k, $v = '')
 {
     $db = Database\SQL::getInstance();
     $query = '';
     if (!is_array($k)) {
         $query = $db->query("UPDATE `options` SET `value`='" . $v . "' WHERE `name` = '" . $k . "' LIMIT 1");
     } else {
         foreach ($k as $key => $val) {
             $query = $db->query("UPDATE `options` SET `value`='" . $val . "' WHERE `name` = '" . $key . "' LIMIT 1");
         }
     }
     return $query;
 }
Ejemplo n.º 5
0
 public static function dropDownList($value = '[]')
 {
     # if tag is empty fill with array
     if (!($tag_id = json_decode($value))) {
         $tag_id = [];
     }
     $sql = "SELECT `id`, `name` FROM `tags`";
     $results = Database\SQL::getInstance()->results($sql);
     $html = '';
     if ($results) {
         foreach ($results as $row) {
             $html .= '<option value="' . $row->id . '" ' . (in_array($row->id, $tag_id) ? 'selected' : null) . '>' . $row->name . '</option>';
         }
     }
     return $html;
 }
Ejemplo n.º 6
0
 public function __construct()
 {
     $this->pageSlug = (new Uri())->path(1);
     $this->db = Database\SQL::getInstance();
     //Ensure that slug page exists
     $sql = "SELECT COUNT(`id`) FROM `posts` WHERE `slug` = :slug";
     $check = $this->db->prepare($sql);
     $check->execute(['slug' => $this->pageSlug]);
     if ($check->fetchColumn() == 0) {
         throw new \Exception('Slug Not Found');
     }
     $this->requestURI = str_replace('index.php/', '', substr($_SERVER['REQUEST_URI'], 1));
     $this->pageUrl = (new Uri())->baseUri . 'index.php/' . $this->requestURI;
     $this->path = PUBLIC_PATH . $this->counterPath;
     // Ensure that counters dir exists
     if (!file_exists($this->path)) {
         mkdir($this->path);
     }
     $this->log_file = $this->path . $this->lf_name;
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     $this->db = Database\SQL::getInstance();
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     call_user_func_array('parent::__construct', func_get_args());
     $this->db = Database\SQL::getInstance();
 }
Ejemplo n.º 9
0
 public static function getTableRow($parent)
 {
     $sql = "SELECT a.id `id`, a.title `title`, a.author `author`, a.date `date`, a.status `status`,\r\n        a.parent `parent`, b.count `count` FROM `posts` a\r\n        LEFT OUTER JOIN (SELECT `parent`, COUNT(*) `count` FROM posts GROUP BY `parent`) b ON a.id = b.parent\r\n        WHERE a.parent = '" . $parent . "' AND a.type = 'page'\r\n        ORDER BY `created_at` DESC ";
     //echo $sql;//exit;
     return Database\SQL::getInstance()->results($sql);
 }
Ejemplo n.º 10
0
 public static function getTableRow($parent)
 {
     $sql = "SELECT a.id `id`, a.name `name`, a.description `description`, a.slug `slug`, a.parent `parent`, a.status `status`, b.count `count` FROM `categories` a\r\n        LEFT OUTER JOIN (\r\n          SELECT `parent`, COUNT(*) `count` FROM `categories` GROUP BY `parent`\r\n        ) b ON a.id = b.parent\r\n        WHERE a.parent = '" . $parent . "'\r\n        ORDER BY `created_at` DESC";
     return Database\SQL::getInstance()->results($sql);
 }