Ejemplo n.º 1
5
 public static function byId($id)
 {
     $db = Database::get();
     try {
         return $db->selectRow("SELECT * FROM user WHERE user_id = :id ", array('id' => $id));
     } catch (Exception $e) {
         return null;
     }
 }
Ejemplo n.º 2
5
 public function __construct()
 {
     //connect to PDO here.
     $this->db = Database::get();
 }
Ejemplo n.º 3
4
 public static function id($title)
 {
     $db = Database::get();
     try {
         $record = $db->selectRow("SELECT * FROM status WHERE status_title = '{$title}' ");
         return $record->status_id;
     } catch (Exception $e) {
         return 0;
     }
 }
Ejemplo n.º 4
3
 public static function row($column, $value)
 {
     $db = Database::get();
     try {
         return $db->selectRow("SELECT * FROM album \r\n\t\t\t\t\t\t\t\t\t LEFT JOIN user ON user.user_id = album.album_user_id\r\n\t\t\t\t \t\t\t\t\t LEFT JOIN category ON category.category_id = album.album_category_id\r\n\t\t\t\t \t\t\t\t\t WHERE {$column} = :val ", array('val' => $value));
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 5
2
 public function itemCount($id)
 {
     $db = Database::get();
     try {
         return count($db->select("SELECT * FROM playlist WHERE playlist_album_id = :id", array('id' => $id)));
     } catch (Exception $e) {
         return 0;
     }
 }
Ejemplo n.º 6
2
 public static function row($column, $value, $count = 0)
 {
     $db = Database::get();
     try {
         if ($count == 0) {
             return $db->selectRow("SELECT * FROM media \r\n\t\t\t\t\t\t\t\t\t LEFT JOIN user ON user.user_id = media.media_user_id\r\n\t\t\t\t\t\t\t\t \t LEFT JOIN category ON category.category_id=media.media_category_id\r\n\t\t\t\t \t\t\t\t\t LEFT JOIN status ON status.status_id = media.media_status_id\r\n\t\t\t\t \t\t\t\t\t WHERE {$column} = :val ", array('val' => $value));
         } else {
             return $db->select("SELECT * FROM device \r\n\t\t\t\t\t\t\t\t\tLEFT JOIN user ON user.user_id = media.media_user_id\r\n\t\t\t\t \t\t\t\t\tLEFT JOIN status ON status.status_id = media.media_status_id\r\n\t\t\t\t \t\t\t\t\tLEFT JOIN category ON category.category_id=media.media_category_id\r\n\t\t\t\t \t\t\t\t\tWHERE {$column} = :val ", array('val' => $value));
         }
     } catch (Exception $e) {
         return false;
     }
 }
 public static function getCUD($where_id)
 {
     self::$db = Database::get();
     $user_data = self::$db->select("\n\t\t\t\tSELECT \n\t\t\t\t\tu.userID, \n\t\t\t\t\tu.username, \n\t\t\t\t\tu.firstName, \n\t\t\t\t\tu.gender, \n\t\t\t\t\tu.userImage,\n\t\t\t\t\tu.email,\n\t\t\t\t\tu.LastLogin, \n\t\t\t\t\tu.SignUp,\n\t\t\t\t\tue.userID,\n\t\t\t\t\tue.website,\n\t\t\t\t\tue.aboutme\n\t\t\t\tFROM \n\t\t\t\t\t" . PREFIX . "users u\n\t\t\t\tLEFT JOIN\n\t\t\t\t\t" . PREFIX . "users_extprofile ue\n\t\t\t\t\tON u.userID = ue.userID\n\t\t\t\tWHERE \n\t\t\t\t\tu.userID = :userID\n\t\t\t\t", array(':userID' => $where_id));
     return $user_data;
 }
Ejemplo n.º 8
2
 static function init()
 {
     self::$db = \Helpers\Database::get();
 }
Ejemplo n.º 9
1
 public function profile($id)
 {
     $db = Database::get();
     try {
         return $db->selectRow("SELECT * FROM user \r\n\t\t\t\t\t\t\t\t  LEFT JOIN role ON role.role_id=user.user_role_id\r\n\t\t\t\t\t\t\t\t  WHERE user_id = :id ", array('id' => $id));
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 10
1
 public static function id($column, $value)
 {
     $db = Database::get();
     try {
         $rec = $db->selectRow("SELECT * FROM category WHERE {$column} = :val ", array('val' => $value));
         return $rec->category_id;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 11
1
 public function __construct()
 {
     new \Helpers\Auth\Setup();
     // loads Setup
     $this->lang = (include 'Lang.php');
     //language file messages
     $this->db = Database::get();
     $this->expireAttempt();
     //expire attempts
 }
Ejemplo n.º 12
1
 /**
  * getTotalSweets
  *
  * gets sweet count for all sweets releated to sweet_id
  *
  * @param int $sweet_id (ID of post where sweets are)
  * @param string $sweet_location (Section of site where sweets are)
  * @param string $sweet_sec_location (Related location where sweets are)
  *
  * @return string returns sweet data
  */
 public static function getTotalSweets($sweet_id = null, $sweet_location = null, $sweet_sec_location = null)
 {
     self::$db = Database::get();
     $sweet_count = self::$db->select("\n        SELECT\n          *\n        FROM\n          " . PREFIX . "sweets\n        WHERE\n          sweet_id = :sweet_id\n            AND (sweet_location = :sweet_location OR sweet_location = :sweet_sec_location)\n        ", array(':sweet_id' => $sweet_id, ':sweet_location' => $sweet_location, ':sweet_sec_location' => $sweet_sec_location));
     $sweet_total = count($sweet_count);
     $sweet_display = " <div class='btn btn-success btn-xs'>" . SWEET_TITLE_DISPLAY . " <span class='badge'>{$sweet_total}</span></div> ";
     return $sweet_display;
 }
Ejemplo n.º 13
1
 function __construct()
 {
     $this->db = \Helpers\Database::get();
 }
Ejemplo n.º 14
0
 public static function detail($id)
 {
     $db = Database::get();
     try {
         return $db->selectRow("SELECT * FROM enquiry \r\n\t\t\t\t\t\t\t\t\t  LEFT JOIN status ON status.status_id=enquiry.enquiry_status_id\r\n\t\t\t\t\t\t\t\t\t  WHERE enquiry_id = :id", array('id' => $id));
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 15
0
 public static function id($title)
 {
     $db = Database::get();
     try {
         $rec = $db->selectRow("SELECT * FROM `role` WHERE role_title = :val", array('val' => $title));
         return $rec->role_id;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 16
0
 public static function getUser(string $user_name, string $pw)
 {
     $db = Database::get();
     $result = $db->select("select * from `user` WHERE user_name = :un", array(':un' => $user_name));
     if (count($result) != 1) {
         return null;
     } else {
         return $result[0];
     }
 }
Ejemplo n.º 17
0
 public static function getCUGroups($where_id)
 {
     self::$db = Database::get();
     $user_groups = self::$db->select("\n        SELECT\n          ug.userID, ug.groupID, g.groupID, g.groupName, g.groupDescription, g.groupFontColor, g.groupFontWeight\n        FROM\n          " . PREFIX . "users_groups ug\n        LEFT JOIN\n          " . PREFIX . "groups g\n          ON g.groupID = ug.groupID\n        WHERE\n          ug.userID = :userID\n        ", array(':userID' => $where_id));
     return $user_groups;
 }
Ejemplo n.º 18
0
 public function __construct()
 {
     $this->db = Database::get();
 }
Ejemplo n.º 19
-1
 /**
  * getForumImagesTopicReply
  *
  * get topic images
  *
  * @param int $topic_id
  * @param int $topic_reply_id
  *
  * @return string returns image url
  */
 public static function getForumImagesTopicReply($topic_id = null, $topic_reply_id = null)
 {
     // Get images for Forum Topic Reply
     self::$db = Database::get();
     $data = self::$db->select("\n      SELECT imageLocation\n      FROM " . PREFIX . "forum_images\n      WHERE forumTopicID = :topic_id\n      AND forumTopicReplyID = :topic_reply_id\n    ", array(':topic_id' => $topic_id, ':topic_reply_id' => $topic_reply_id));
     return $data[0]->imageLocation;
 }
Ejemplo n.º 20
-1
 /**
  * views
  *
  * gets view count
  * updates view count if enabled
  *
  * @param boolean $addView (true/false)
  * @param string $view_location (Section of site where view is)
  * @param int $view_id (ID of post where view is)
  * @param int $view_owner_userid (ID of user viewing)
  *
  * @return string returns views count
  */
 public static function views($addView = null, $view_id = null, $view_location = null, $view_owner_userid = "0")
 {
     // Get data from server
     // Get current user's IP address
     $view_user_ip = $_SERVER['REMOTE_ADDR'];
     // Get full URL address for current page
     $view_uri = $_SERVER['REQUEST_URI'];
     $view_server = $_SERVER['SERVER_NAME'];
     // Check to see if user is a guest... then set their id to 0
     if ($view_owner_userid == null) {
         $view_owner_userid = "0";
     }
     // Check to see if current user has already viewed page
     self::$db = Database::get();
     $already_view_data = self::$db->select("\n        SELECT\n          *\n        FROM\n          " . PREFIX . "views\n        WHERE\n          view_id = :view_id\n            AND view_location = :view_location\n            AND view_owner_userid = :view_owner_userid\n        ", array(':view_id' => $view_id, ':view_location' => $view_location, ':view_owner_userid' => $view_owner_userid));
     $already_view_count = count($already_view_data);
     // Check to see if current user has already viewed this page
     if ($already_view_count < 1) {
         // Check to see if this is a page that we want to add view to
         if ($addView == "true") {
             // Insert New View Into Database
             self::$db = Database::get();
             $view_add_data = self::$db->insert(PREFIX . 'views', array('view_id' => $view_id, 'view_sec_id' => $view_sec_id, 'view_location' => $view_location, 'view_user_ip' => $view_user_ip, 'view_server' => $view_server, 'view_uri' => $view_uri, 'view_owner_userid' => $view_owner_userid));
         }
         // End addView Check
     }
     // End already viewed check
     // Output View Count for display on page
     // Get view count from db
     self::$db = Database::get();
     $view_data = self::$db->select("\n        SELECT\n          *\n        FROM\n          " . PREFIX . "views\n        WHERE\n          view_id = :view_id\n            AND view_location = :view_location\n        ", array(':view_id' => $view_id, ':view_location' => $view_location));
     return count($view_data);
 }
Ejemplo n.º 21
-1
 public static function getTotalPosts($where_id)
 {
     self::$db = Database::get();
     $data = self::$db->select("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t" . PREFIX . "forum_posts\n\t\t\t\tWHERE\n\t\t\t    forum_user_id = :userID\n\t\t\t\t", array(':userID' => $where_id));
     $data2 = self::$db->select("\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t" . PREFIX . "forum_posts_replys\n\t\t\t\tWHERE\n\t\t\t    fpr_user_id = :userID\n\t\t\t\t", array(':userID' => $where_id));
     $total = count($data) + count($data2);
     return $total;
 }
Ejemplo n.º 22
-1
 /**
  * Get Current User's Groups Data For Display
  */
 public function getUserGroups($where_id)
 {
     self::$db = Database::get();
     $user_groups = self::$db->select("\n        SELECT\n          ug.userID, ug.groupID, g.groupID, g.groupName, g.groupDescription, g.groupFontColor, g.groupFontWeight\n        FROM\n          " . PREFIX . "users_groups ug\n        LEFT JOIN\n          " . PREFIX . "groups g\n          ON g.groupID = ug.groupID\n        WHERE\n          ug.userID = :userID\n        ", array(':userID' => $where_id));
     if (isset($user_groups)) {
         foreach ($user_groups as $row) {
             $usergroup[] = " <font color='{$row->groupFontColor}' weight='{$row->groupFontWeight}'>{$row->groupName}</font> ";
         }
     }
     return $usergroup;
 }
 function __construct()
 {
     parent::__construct();
     $this->db = Database::get();
 }
Ejemplo n.º 24
-1
 public static function get($string)
 {
     //current year
     $string = str_replace('[year]', date('Y'), $string);
     //name of website
     $string = str_replace('[sitetitle]', SITETITLE, $string);
     //site email address
     $string = str_replace('[siteemail]', SITEEMAIL, $string);
     //facebook like box
     $string = preg_replace_callback("(\\[facebooklikebox(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         //if key exits use it
         $username = isset($params['username']) ? $params['username'] : '';
         $width = isset($params['width']) ? $params['width'] : '300px';
         $height = isset($params['height']) ? $params['height'] : '258px';
         $colorscheme = isset($params['colorscheme']) ? $params['colorscheme'] : 'light';
         $showfaces = isset($params['showfaces']) ? $params['showfaces'] : 'true';
         $header = isset($params['header']) ? $params['header'] : 'true';
         $stream = isset($params['stream']) ? $params['stream'] : 'false';
         $showborder = isset($params['showborder']) ? $params['showborder'] : 'false';
         $scrolling = isset($params['scrolling']) ? $params['scrolling'] : 'no';
         $likebox = "<iframe src='//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2F{$username}&amp;\n            width={$width}&amp;\n            height={$height}&amp;\n            colorscheme={$colorscheme}&amp;\n            show_faces={$showfaces}&amp;\n            header={$header}&amp;\n            stream={$stream}&amp;\n            show_border={$showborder}&amp;\n            appId=262411407271009'\n            scrolling='{$scrolling}'\n            frameborder='0'\n            style='border:none; overflow:hidden; width:{$width}; height:{$height};'\n            allowTransparency='true'></iframe>";
         return $likebox;
     }, $string);
     //feedburner subscribe form
     $string = preg_replace_callback("(\\[feedburner(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         $username = isset($params['username']) ? $params['username'] : '';
         $form = "<form action='https://feedburner.google.com/fb/a/mailverify' method='post' target='popupwindow' onsubmit='window.open('http://feedburner.google.com/fb/a/mailverify?uri={$username}', 'popupwindow', 'scrollbars=yes,width=550,height=520');return true' class='navbar-form'>\n            <input type='hidden' value='{$username}' name='uri'>\n            <input type='hidden' name='loc' value='en_US'>\n              <p><input type='text' class='form-control' placeholder='Enter Email Address' name='email' id='srch-term'></p>\n              <p><input class='btn btn-success' type='submit' value='Subscribe by Email'></p>\n            </form>";
         return $form;
     }, $string);
     //google plus box
     $string = preg_replace_callback("(\\[googleplusbox(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         $username = isset($params['username']) ? $params['username'] : '';
         return "<script src='https://apis.google.com/js/platform.js' async defer></script>\n                    <g:page href='https://plus.google.com/+{$username}'></g:page>";
     }, $string);
     //google adbox
     $string = preg_replace_callback("(\\[googleadbox])is", function ($matches) {
         ob_start();
         ?>
         <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
         <!-- dcsidebar -->
         <ins class="adsbygoogle"
              style="display:block"
              data-ad-client="ca-pub-0401085377924210"
              data-ad-slot="3065264368"
              data-ad-format="auto"></ins>
         <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
         </script>
         <?php 
         $ad = ob_get_clean();
         return $ad;
     }, $string);
     //twitter follow button
     $string = preg_replace_callback("(\\[twitterfollowbutton(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         if (!isset($params['count'])) {
             $params['count'] = null;
         }
         if (!isset($params['size'])) {
             $params['size'] = null;
         }
         //if key exits use it
         $username = isset($params['username']) ? $params['username'] : '';
         $count = $params['count'] == 'no' ? "data-show-count='false'" : '';
         $size = $params['size'] == 'large' ? "data-size='large'" : '';
         return "<a href='https://twitter.com/{$username}' class='twitter-follow-button' {$count} {$size}>Follow @{$username}</a>\n        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>";
     }, $string);
     //twitter share button
     $string = preg_replace_callback("(\\[twittersharebutton(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         if (!isset($params['count'])) {
             $params['count'] = null;
         }
         if (!isset($params['size'])) {
             $params['size'] = null;
         }
         //if key exits use it
         $count = $params['count'] == 'no' ? "data-count='none'" : '';
         $size = $params['size'] == 'large' ? "data-size='large'" : '';
         $via = isset($params['via']) ? "data-via='{$params['via']}'" : '';
         $hash = isset($params['hash']) ? "data-hashtags='{$params['hash']}'" : '';
         return "<a href='https://twitter.com/share' class='twitter-share-button' {$count} {$size} {$via} {$hash}>Tweet</a>\n        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>";
     }, $string);
     //youtube embeds
     $string = preg_replace_callback("(\\[youtube (.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         //if key exits use it
         $video = isset($params['video']) ? $params['video'] : '';
         $video = str_replace("https://www.youtube.com/watch?v=", "", $video);
         $width = isset($params['width']) ? $params['width'] : '640';
         $height = isset($params['height']) ? $params['height'] : '360';
         return "<iframe width='{$width}' height='{$height}' src='//www.youtube.com/embed/{$video}' frameborder='0' allowfullscreen></iframe>";
     }, $string);
     //youtube subscribe
     $string = preg_replace_callback("(\\[youtubesub(.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         if (!isset($params['count'])) {
             $params['count'] = null;
         }
         if (!isset($params['size'])) {
             $params['size'] = null;
         }
         $username = isset($params['username']) ? $params['username'] : '';
         $layout = $params['layout'] == 'full' ? 'full' : 'default';
         $count = $params['count'] == 'no' ? 'hidden' : 'default';
         return "<script src='https://apis.google.com/js/platform.js'></script>\n                <div class='g-ytsubscribe' data-channel='{$username}' data-layout='{$layout}' data-count='{$count}'></div>";
     }, $string);
     //vimeo embeds
     $string = preg_replace_callback("(\\[vimeo (.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         //if key exits use it
         $video = isset($params['video']) ? $params['video'] : '';
         $video = str_replace("https://vimeo.com/", "", $video);
         $width = isset($params['width']) ? $params['width'] : '640';
         $height = isset($params['height']) ? $params['height'] : '360';
         return "<iframe width='{$width}' height='{$height}' src='https://player.vimeo.com/video/{$video}' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
     }, $string);
     //pages get children
     $string = preg_replace_callback("(\\[pages (.*?)])is", function ($matches) {
         $params = tags::clean($matches);
         $items = null;
         //if key exits use it
         $parent = isset($params['parent']) ? $params['parent'] : '';
         $class = isset($params['class']) ? $params['class'] : '';
         $id = isset($params['id']) ? $params['id'] : '';
         $subclass = isset($params['subclass']) ? $params['subclass'] : '';
         $subid = isset($params['subid']) ? $params['subid'] : '';
         $db = Database::get();
         $q = $db->select("SELECT pageID,pageParent,pageMenuTitle,pageSlug FROM " . PREFIX . "pages WHERE pageParent=:parent AND pageStandAlone='0' ORDER BY pageOrder", array(':parent' => $parent));
         //if page is more then 0 then show drop down menu
         if (count($q) > 0) {
             $items = "<ul class='{$class}' id='{$id}'>\n";
             foreach ($q as $row) {
                 //if slug is external use it
                 if (preg_match("/http/i", $row->pageSlug)) {
                     $rowSlug = $row->pageSlug;
                 } else {
                     //otherwise add in the DIR
                     $rowSlug = DIR . $row->pageSlug;
                 }
                 $items .= "<li><a href='{$rowSlug}'>{$row->pageMenuTitle}</a>";
                 $q2 = $db->select("SELECT pageMenuTitle,pageSlug FROM " . PREFIX . "pages WHERE pageParent=:parent AND pageStandAlone='0' ORDER BY pageOrder", array(':parent' => $row->pageID));
                 if (count($q2) > 0) {
                     $items .= "<ul class='{$subclass}' id='{$subid}'>\n";
                     foreach ($q2 as $row2) {
                         //if slug is external use it
                         if (preg_match("/http/i", $row2->pageSlug)) {
                             $row2Slug = $row2->pageSlug;
                         } else {
                             //otherwise add in the DIR
                             $row2Slug = DIR . $row2->pageSlug;
                         }
                         $items .= "<li><a href='{$row2Slug}'>{$row2->pageMenuTitle}</a></li>";
                     }
                     $items .= "</ul>";
                 }
                 $items .= "</li>";
             }
             $items .= "</ul>";
         }
         return $items;
     }, $string);
     return $string;
 }
Ejemplo n.º 25
-1
 /**
  * Table builder constructor.
  * Database class initialization, don't create too many instances of table builder,
  * because it will create many database instances which will decrease performance.
  * By default this class would create a `id` field INT(11) NOT null AUTO_INCREMENT PRIMARY KEY, unless
  * you'll set second parameter false.
  *
  * @param PDO|null $db - PDO instance (it can be a \helper\database instance)
  * @param boolean  $id - A flag to add or not to add `id` field automatically
  */
 public function __construct(PDO $db = null, $id = true)
 {
     // If database is not given, create new database instance.
     // database is in the same namespace, we don't need to specify namespace
     $this->db = !$db ? Database::get() : $db;
     if ($id === true) {
         $this->addField('id', 'INT(11)', false, self::AUTO_INCREMENT);
         $this->setPK('id');
     }
 }
Ejemplo n.º 26
-1
 public static function cmsRoute()
 {
     $db = Database::get();
     $uri = parse_url($_SERVER['QUERY_STRING'], PHP_URL_PATH);
     $uri = trim($uri, ' /');
     $parts = explode('/', $uri);
     if ($parts[0]) {
         $controller = $parts[0];
     }
     if ($parts[1]) {
         $action = $parts[1];
     }
     if ($parts[2]) {
         $param = $parts[2];
     }
     $db->selectRow("SELECT * FROM page WHERE page_alias ='{$controller}'");
     return $db->count;
 }
Ejemplo n.º 27
-2
 public static function getId($title, $group = '')
 {
     $db = Database::get();
     if (isset($group) && $group != '') {
         $append = "AND category_slug = '" . $group . "'";
     }
     try {
         $record = $db->selectRow("SELECT * FROM category WHERE category_title = '{$title}' {$append}");
         return $record->category_id;
     } catch (Exception $e) {
         return 0;
     }
 }
Ejemplo n.º 28
-2
 public function __construct()
 {
     parent::__construct();
     $this->abills = Database::get(array('type' => 'mysql', 'host' => '127.0.0.1', 'name' => 'abills', 'user' => DB_USER, 'pass' => DB_PASS));
 }