/**
  * Adding an Advertisement Click.
  *
  * @param integer $iAdsId
  * @return void
  */
 public static function setClick($iAdsId)
 {
     $rStmt = Db::getInstance()->prepare('UPDATE' . Db::prefix('Ads') . 'SET clicks = clicks+1 WHERE adsId = :id LIMIT 1');
     $rStmt->bindValue(':id', $iAdsId, \PDO::PARAM_INT);
     $rStmt->execute();
     Db::free($rStmt);
 }
Example #2
0
 public static function getMetaMain($sLangId)
 {
     $oCache = (new Cache())->start(self::CACHE_GROUP, 'metaMain' . $sLangId, self::CACHE_TIME);
     // @return value of meta tags the database
     if (!($oData = $oCache->get())) {
         $sSql = 'SELECT * FROM' . Engine\Db::prefix('MetaMain') . 'WHERE langId = :langId';
         // Get meta data with the current language if it exists in the "MetaMain" table ...
         $rStmt = Engine\Db::getInstance()->prepare($sSql);
         $rStmt->bindParam(':langId', $sLangId, \PDO::PARAM_STR);
         $rStmt->execute();
         $oData = $rStmt->fetch(\PDO::FETCH_OBJ);
         // If the current language doesn't exist in the "MetaMain" table, we create a new table for the new language with default value
         if (empty($oData)) {
             $aData = ['langId' => $sLangId, 'pageTitle' => 'Home', 'metaDescription' => 'The Dating Software for creating online dating service or online social community.', 'metaKeywords' => 'script,CMS,PHP,dating script,dating software,social networking software,social networking script,social network script,free,open source,match clone,friend finder clone,adult friend finder clone', 'slogan' => 'pH7CMS is the leading Dating CMS specializes in online open source dating software!', 'metaRobots' => 'index, follow, all', 'metaAuthor' => 'Pierre-Henry Soria', 'metaCopyright' => 'Copyright Pierre-Henry Soria. All Rights Reserved.', 'metaRating' => 'general', 'metaDistribution' => 'global', 'metaCategory' => 'dating'];
             Engine\Record::getInstance()->insert('MetaMain', $aData);
             // Create the new meta data language
             $oData = (object) $aData;
             unset($aData);
         }
         Engine\Db::free($rStmt);
         $oCache->put($oData);
     }
     unset($oCache);
     return $oData;
 }
 /**
  * Gets Viewed Profile.
  *
  * @param string $sGender Constant (self::ALL, self::COUPLE, self::MALE, self::FEMALE). Default: self::ALL
  * @param boolean $bCount Put TRUE for count birthdays or FALSE for the result of birthdays. Default: TRUE
  * @param string $sOrderBy Default: SearchCoreModel::LAST_ACTIVITY
  * @param string $sSort Default: SearchCoreModel::DESC
  * @param integer $iOffset Default: NULL
  * @param integer $iLimit Default: NULL
  * @return mixed (object | integer) object for the birthdays list returned or integer for the total number birthdays returned.
  */
 public function get($sGender = self::ALL, $bCount = false, $sOrderBy = SearchCoreModel::LAST_ACTIVITY, $sSort = SearchCoreModel::DESC, $iOffset = null, $iLimit = null)
 {
     $bIsLimit = null !== $iOffset && null !== $iLimit;
     $bIsSex = $sGender !== self::ALL;
     $bCount = (bool) $bCount;
     $iOffset = (int) $iOffset;
     $iLimit = (int) $iLimit;
     $sSqlLimit = !$bCount && $bIsLimit ? 'LIMIT :offset, :limit' : '';
     $sSqlSelect = !$bCount ? '*' : 'COUNT(profileId) AS totalBirths';
     $sSqlWhere = $bIsSex ? ' AND (sex = :sex) ' : '';
     $sSqlOrder = SearchCoreModel::order($sOrderBy, $sSort);
     $rStmt = Db::getInstance()->prepare('SELECT ' . $sSqlSelect . ' FROM' . Db::prefix('Members') . 'WHERE (username <> \'' . PH7_GHOST_USERNAME . '\') AND (groupId=\'2\') AND (birthDate LIKE :date)' . $sSqlWhere . $sSqlOrder . $sSqlLimit);
     $rStmt->bindValue(':date', '%' . (new CDateTime())->get()->date('-m-d'), \PDO::PARAM_STR);
     if ($bIsSex) {
         $rStmt->bindValue(':sex', $sGender, \PDO::PARAM_STR);
     }
     if (!$bCount && $bIsLimit) {
         $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
         $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     }
     $rStmt->execute();
     if (!$bCount) {
         $oRow = $rStmt->fetchAll(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         return $oRow;
     } else {
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         return (int) $oRow->totalBirths;
     }
 }
 public static function getMetaMain($sLangId)
 {
     $oCache = (new Cache())->start(self::CACHE_GROUP, 'metaMain' . $sLangId, self::CACHE_TIME);
     // @return value of meta tags the database
     if (!($oData = $oCache->get())) {
         $sSql = 'SELECT * FROM' . Engine\Db::prefix('MetaMain') . 'WHERE langId = :langId';
         // Get meta data with the current language if it exists in the "MetaMain" table ...
         $rStmt = Engine\Db::getInstance()->prepare($sSql);
         $rStmt->bindParam(':langId', $sLangId, \PDO::PARAM_STR);
         $rStmt->execute();
         $oData = $rStmt->fetch(\PDO::FETCH_OBJ);
         // If the current language doesn't exist in the "MetaMain" table, we create a new table for the new language with default value
         if (empty($oData)) {
             $aData = ['langId' => $sLangId, 'pageTitle' => 'Home', 'metaDescription' => 'The Dating Software for creating online dating service or online social community.', 'metaKeywords' => 'script,CMS,PHP,dating script,dating software,social networking software,social networking script,social network script,free,open source,match clone,friend finder clone,adult friend finder clone', 'slogan' => 'Free Online Dating Community Site with Chat Rooms', 'promoText' => 'You\'re on the best place for meeting new people nearby! Chat, Flirt, Socialize and have Fun!<br />Create any Dating Sites like that with the <a href="http://software.hizup.com">PHP Dating Script</a>. It is Professional, Free, Open Source, ...', 'metaRobots' => 'index, follow, all', 'metaAuthor' => 'Pierre-Henry Soria', 'metaCopyright' => 'Copyright Pierre-Henry Soria. All Rights Reserved.', 'metaRating' => 'general', 'metaDistribution' => 'global', 'metaCategory' => 'dating'];
             Engine\Record::getInstance()->insert('MetaMain', $aData);
             // Create the new meta data language
             $oData = (object) $aData;
             unset($aData);
         }
         Engine\Db::free($rStmt);
         $oCache->put($oData);
     }
     unset($oCache);
     return $oData;
 }
 public function searchUser($mWhat, $sWhere, $iGroupId, $iBanned, $bCount, $sOrderBy, $sSort, $iOffset, $iLimit)
 {
     $bCount = (bool) $bCount;
     $iOffset = (int) $iOffset;
     $iLimit = (int) $iLimit;
     $sSqlLimit = !$bCount ? ' LIMIT :offset, :limit' : '';
     $sSqlSelect = !$bCount ? 'm.*, g.name AS membershipName' : 'COUNT(m.profileId) AS totalUsers';
     $sSqlQuery = !empty($iBanned) ? '(ban = 1) AND ' : '';
     $sSqlQuery .= $sWhere === 'all' ? '(m.username LIKE :what OR m.email LIKE :what OR m.firstName LIKE :what OR m.lastName LIKE :what OR m.ip LIKE :what)' : '(m.' . $sWhere . ' LIKE :what)';
     $sSqlOrder = SearchCoreModel::order($sOrderBy, $sSort);
     $rStmt = Db::getInstance()->prepare('SELECT ' . $sSqlSelect . ' FROM' . Db::prefix('Members') . 'AS m INNER JOIN ' . Db::prefix('Memberships') . 'AS g ON m.groupId = g.groupId LEFT JOIN' . Db::prefix('MembersInfo') . 'AS i ON m.profileId = i.profileId WHERE (username <> \'' . PH7_GHOST_USERNAME . '\') AND (m.groupId = :groupId) AND ' . $sSqlQuery . $sSqlOrder . $sSqlLimit);
     $rStmt->bindValue(':what', '%' . $mWhat . '%', \PDO::PARAM_STR);
     $rStmt->bindParam(':groupId', $iGroupId, \PDO::PARAM_INT);
     if (!$bCount) {
         $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
         $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     }
     $rStmt->execute();
     if (!$bCount) {
         $oRow = $rStmt->fetchAll(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         return $oRow;
     } else {
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         return (int) $oRow->totalUsers;
     }
 }
 /**
  * @param string $sFile SQL file name.
  * @param string $sPath Path to SQL file.
  * @param array $aParams Default NULL
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function exec($sFile, $sPath, array $aParams = null)
 {
     $rStmt = Db::getInstance()->prepare($this->getQuery($sFile, $sPath));
     $bRet = $rStmt->execute($aParams);
     Db::free($rStmt);
     return $bRet;
 }
 public function totalReports()
 {
     $rStmt = Db::getInstance()->prepare('SELECT COUNT(reportId) AS totalRpts FROM' . Db::prefix('Report'));
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return (int) $oRow->totalRpts;
 }
 public function totalNotes()
 {
     $rStmt = Db::getInstance()->prepare('SELECT COUNT(noteId) AS totalNotes FROM' . Db::prefix('Notes') . 'WHERE approved = \'0\'');
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return (int) $oRow->totalNotes;
 }
 public static function countUnreadMsg($iProfileId)
 {
     $rStmt = Db::getInstance()->prepare('SELECT COUNT(status) AS unread FROM' . Db::prefix('Messages') . 'WHERE recipient = :recipient AND status = \'1\' AND NOT FIND_IN_SET(\'recipient\', toDelete)');
     $rStmt->bindValue(':recipient', $iProfileId, \PDO::PARAM_INT);
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return (int) $oRow->unread;
 }
Example #10
0
 /**
  * Count total friends.
  *
  * @param integer $iProfileId
  * @return integer
  */
 public static function totalFriends($iProfileId)
 {
     $rStmt = Db::getInstance()->prepare('SELECT COUNT(friendId) AS totalFriends FROM' . Db::prefix('MembersFriends') . 'WHERE (profileId = :profileId OR friendId= :profileId)');
     $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return (int) $oRow->totalFriends;
 }
Example #11
0
 /**
  * Adding an Advertisement Click.
  *
  * @param integer $iAdsId
  * @return void
  */
 public static function setClick($iAdsId)
 {
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('AdsClicks') . 'SET adsId = :adsId, url = :url, ip = :ip, dateTime = :dateTime');
     $rStmt->bindValue(':adsId', $iAdsId, \PDO::PARAM_INT);
     $rStmt->bindValue(':ip', \PH7\Framework\Ip\Ip::get(), \PDO::PARAM_STR);
     $rStmt->bindValue(':dateTime', (new \PH7\Framework\Date\CDateTime())->get()->dateTime('Y-m-d H:i:s'), \PDO::PARAM_STR);
     $rStmt->execute();
     Db::free($rStmt);
 }
Example #12
0
 /**
  * This method was created to avoid retrieving the column "views" with the general Model of the module,
  * since it uses the cache and therefore cannot retrieve the number of real-time views.
  *
  * @param integer $iId
  * @param string $sTable
  * @return integer Number of views.
  */
 public static function getView($iId, $sTable)
 {
     $sWhere = Various::convertTableToId($sTable);
     $rStmt = Db::getInstance()->prepare('SELECT views FROM' . Db::prefix($sTable) . 'WHERE ' . $sWhere . ' = :id LIMIT 1');
     $rStmt->bindValue(':id', $iId, \PDO::PARAM_INT);
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return (int) @$oRow->views;
 }
 public function getForumsPosts($sOrder, $iOffset, $iLimit)
 {
     $iOffset = (int) $iOffset;
     $iLimit = (int) $iLimit;
     $rStmt = Db::getInstance()->prepare('SELECT f.name, t.title, t.message, t.createdDate, t.updatedDate, t.forumId, t.topicId, m.username FROM' . Db::prefix('Forums') . 'AS f INNER JOIN' . Db::prefix('ForumsTopics') . 'AS t ON f.forumId = t.forumId LEFT JOIN' . Db::prefix('Members') . ' AS m ON t.profileId = m.profileId WHERE t.approved=1 ORDER BY ' . $sOrder . ' DESC LIMIT :offset, :limit');
     $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
     $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     $rStmt->execute();
     $oData = $rStmt->fetchAll(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return $oData;
 }
 public function select($sKey)
 {
     $this->cache->start(self::CACHE_GROUP, 'select' . $sKey, 3600 * 168);
     if (!($oData = $this->cache->get())) {
         $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('Likes') . 'WHERE keyId =:key LIMIT 1');
         $rStmt->bindValue(':key', $sKey, \PDO::PARAM_STR);
         $rStmt->execute();
         $oData = $rStmt->fetchAll(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $this->cache->put($oData);
     }
     return $oData;
 }
 /**
  * Get information about the language.
  *
  * @param boolean $bOnlyActive Only active lang. Default: TRUE
  * @return object Language data.
  */
 public function getInfos($bOnlyActive = true)
 {
     $oCache = (new Cache())->start(self::CACHE_GROUP, 'list' . $bOnlyActive, 172800);
     if (!($oData = $oCache->get())) {
         $sSqlWhere = $bOnlyActive ? 'WHERE active=\'1\'' : '';
         $rStmt = Db::getInstance()->prepare('SELECT * FROM ' . DB::prefix('LanguagesInfo') . $sSqlWhere . ' ORDER BY name ASC');
         $rStmt->execute();
         $oData = $rStmt->fetchAll(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $oCache->put($oData);
     }
     unset($oCache);
     return $oData;
 }
Example #16
0
 /**
  * Output Stream Views.
  *
  * @final
  * @param string $sFile Specify another display file instead of the default layout file. Default NULL
  * @return void
  */
 public final function output($sFile = null)
 {
     /**
      * Destroy all object instances of PDO and close the connection to the database before the display and the start of the template and free memory
      */
     M\Engine\Db::free();
     /**
      * Output our template and encoding.
      */
     $sFile = !empty($sFile) ? $sFile : $this->view->getMainPage();
     // header('Content-type: text/html; charset=' . PH7_ENCODING);
     $this->view->display($sFile, PH7_PATH_TPL . PH7_TPL_NAME . PH7_DS);
     $this->view->clean();
     // Clean Template Data
 }
Example #17
0
 /**
  * Get random picture.
  *
  * @param integer $iProfileId Default NULL
  * If the user is connected, you need the ID of the user in this parameter to not display the avatar of the user since the user can not vote for himself.
  *
  * @param integer $iApproved Default 1
  * @param integer $iOffset Default 0
  * @param integer $iLimit Default 1
  * @return object DATA ot the user (profileId, username, firstName, sex, avatar).
  */
 public function getPicture($iProfileId = null, $iApproved = 1, $iOffset = 0, $iLimit = 1)
 {
     $sSql = !empty($iProfileId) ? ' AND (profileId <> :profileId) ' : ' ';
     $rStmt = Db::getInstance()->prepare('SELECT profileId, username, firstName, sex, avatar FROM' . Db::prefix('Members') . 'WHERE (username <> \'' . PH7_GHOST_USERNAME . '\')' . $sSql . 'AND (avatar IS NOT NULL) AND (approvedAvatar = :approved) ORDER BY RAND() LIMIT :offset, :limit');
     if (!empty($iProfileId)) {
         $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
     }
     $rStmt->bindValue(':approved', $iApproved, \PDO::PARAM_INT);
     $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
     $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     $rStmt->execute();
     $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return $oRow;
 }
Example #18
0
 /**
  * Get Total Advertisements.
  *
  * @param string $sTable Default 'Ads'
  * @return integer
  */
 public function total($sTable = 'Ads')
 {
     $this->cache->start(self::CACHE_GROUP, 'total' . $sTable, 604800);
     if (!($iData = $this->cache->get())) {
         AdsCore::checkTable($sTable);
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(adsId) AS totalAds FROM' . Db::prefix($sTable));
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->totalAds;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }
 /**
  * Get the Affiliated Id of a User.
  *
  * @param integer $iProfileId
  * @param string $sTable 'Members', 'Affiliates' or 'Subscribers'. Default 'Members'
  * @return integer The Affiliated ID
  */
 public function getAffiliatedId($iProfileId, $sTable = 'Members')
 {
     $this->cache->start(static::CACHE_GROUP, 'affiliatedId' . $iProfileId . $sTable, static::CACHE_TIME);
     if (!($iData = $this->cache->get())) {
         Various::checkModelTable($sTable);
         $iProfileId = (int) $iProfileId;
         $rStmt = Db::getInstance()->prepare('SELECT affiliatedId FROM' . Db::prefix($sTable) . 'WHERE profileId = :profileId LIMIT 1');
         $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->affiliatedId;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }
Example #20
0
 public function idExists($iId, $sTable)
 {
     $this->cache->start(static::CACHE_GROUP, 'idExists' . $iId . $sTable, static::CACHE_TIME);
     if (!($bData = $this->cache->get())) {
         $iId = (int) $iId;
         $sTable = CommentCore::checkTable($sTable);
         $sNewTable = Comment::getTable($sTable);
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(' . lcfirst($sTable) . 'Id) FROM' . Db::prefix($sNewTable) . 'WHERE ' . lcfirst($sTable) . 'Id = :id LIMIT 1');
         $rStmt->bindValue(':id', $iId, \PDO::PARAM_INT);
         $rStmt->execute();
         $bData = $rStmt->fetchColumn() == 1;
         Db::free($rStmt);
         $this->cache->put($bData);
     }
     return $bData;
 }
 /**
  * Gets the total posts.
  *
  * @param integer $iDay Default 0
  * @return integer
  */
 public function totalPosts($iDay = 0)
 {
     $this->cache->start(self::CACHE_GROUP, 'totalPosts', static::CACHE_TIME);
     if (!($iData = $this->cache->get())) {
         $iDay = (int) $iDay;
         $sSqlDay = $iDay > 0 ? ' WHERE (createdDate + INTERVAL ' . $iDay . ' DAY) > NOW()' : '';
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(postId) AS totalPosts FROM' . Db::prefix('Blogs') . $sSqlDay);
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->totalPosts;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }
 public function get($sTitle = null, $iGameId = null, $iOffset, $iLimit, $sOrder = SearchCoreModel::NAME)
 {
     $iOffset = (int) $iOffset;
     $iLimit = (int) $iLimit;
     $sOrderBy = SearchCoreModel::order($sOrder, SearchCoreModel::DESC);
     $sSqlGameId = !empty($iGameId) ? ' WHERE title LIKE :title AND gameId =:gameId ' : '';
     $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('Games') . $sSqlGameId . $sOrderBy . 'LIMIT :offset, :limit');
     isset($sTitle, $iGameId) ? $rStmt->bindValue(':title', $sTitle . '%', \PDO::PARAM_STR) : '';
     isset($sTitle, $iGameId) ? $rStmt->bindValue(':gameId', $iGameId, \PDO::PARAM_INT) : '';
     $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
     $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     $rStmt->execute();
     $oData = !empty($iGameId) ? $rStmt->fetch(\PDO::FETCH_OBJ) : $rStmt->fetchAll(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return $oData;
 }
Example #23
0
 public function total($iRecipientId, $sTable)
 {
     $this->cache->start(static::CACHE_GROUP, 'total' . $iRecipientId . $sTable, static::CACHE_TIME);
     if (!($iData = $this->cache->get())) {
         $sTable = CommentCore::checkTable($sTable);
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(commentId) AS totalComments FROM' . Db::prefix('Comments' . $sTable) . ' WHERE recipient = :recipient');
         $rStmt->bindParam(':recipient', $iRecipientId);
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->totalComments;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }
 public function getScore($iId, $sTable)
 {
     $this->cache->start(self::CACHE_GROUP, 'getScore' . $iId . $sTable, static::CACHE_TIME);
     $sTable = Various::checkTable($sTable);
     $sWhere = Various::convertTableToId($sTable);
     if (!($fData = $this->cache->get())) {
         $rStmt = Db::getInstance()->prepare('SELECT score FROM' . Db::prefix($sTable) . 'WHERE ' . $sWhere . ' = :id LIMIT 1');
         $rStmt->bindValue(':id', $iId, \PDO::PARAM_INT);
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $fData = (double) @$oRow->score;
         unset($oRow);
         $this->cache->put($fData);
     }
     return $fData;
 }
Example #25
0
 public function get($iProfileId, $iWallId = null, $iOffset, $iLimit)
 {
     $iOffset = (int) $iOffset;
     $iLimit = (int) $iLimit;
     $sSqlWallId = !empty($iWallId) ? ' AND wallId=:wallId ' : '';
     $rStmt = Db::getInstance()->prepare('SELECT * FROM' . Db::prefix('MembersWall') . ' AS w LEFT JOIN' . Db::prefix('Members') . 'AS m ON w.profileId = m.profileId WHERE :profileId=:profileId ' . $sSqlWallId . ' ORDER BY dateTime DESC LIMIT :offset, :limit');
     $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
     if (!empty($iWallId)) {
         $rStmt->bindValue(':wallId', $iWallId, \PDO::PARAM_INT);
     }
     $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
     $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
     $rStmt->execute();
     $oRow = $rStmt->fetchAll(\PDO::FETCH_OBJ);
     Db::free($rStmt);
     return $oRow;
 }
 /**
  * Write to the logfile.
  *
  * @param object $oExcept \Exception object.
  * @return void
  */
 public function except(\Exception $oExcept)
 {
     // Time: Set the log date/time.
     // IP: The IP address of the client.
     // UserAgent: The User Agent of the Browser Web.
     // UrlPag: The URL page where the exception is thrown.
     // Query: The request for such a page.
     // Message: constains the error message.
     // Level: contains the log level.
     // File: constains the file name.
     // Line: constains the line number.
     $sAgent = null !== ($mAgent = $this->browser->getUserAgent()) ? $mAgent : 'NO USER AGENT';
     $sQuery = null !== ($mQuery = (new Http())->getQueryString()) ? $mQuery : 'NO QUERY STRING';
     $aLog = ['Time' => $this->dateTime->get()->dateTime(), 'IP' => Ip::get(), 'UserAgent' => $sAgent, 'UrlPag' => $this->httpRequest->currentUrl(), 'Query' => $sQuery, 'Message' => $oExcept->getMessage(), 'Level' => $oExcept->getCode(), 'File' => $oExcept->getFile(), 'Line' => $oExcept->getLine()];
     // Encode the line
     $sContents = json_encode($aLog) . File::EOL . File::EOL . File::EOL;
     switch ($this->config->values['logging']['log_handler']) {
         case 'file':
             $sFullFile = $this->sDir . static::EXCEPT_DIR . $this->sFileName . '.json';
             $sFullGzipFile = $this->sDir . static::EXCEPT_DIR . static::GZIP_DIR . $this->sFileName . '.gz';
             // If the log file is larger than 5 Mo then it compresses it into gzip
             if (file_exists($sFullFile) && filesize($sFullFile) >= 5 * 1024 * 1024) {
                 $rHandler = @gzopen($sFullGzipFile, 'a') or exit('Unable to write to log file gzip.');
                 gzwrite($rHandler, $sContents);
                 gzclose($rHandler);
             } else {
                 $rHandler = @fopen($sFullFile, 'a') or exit('Unable to write to log file.');
                 fwrite($rHandler, $sContents);
                 fclose($rHandler);
             }
             break;
         case 'database':
             $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('LogError') . 'SET logError = :line');
             $rStmt->execute(array(':line' => $sContents));
             Db::free($rStmt);
             break;
         case 'email':
             $aInfo = ['to' => $this->config->values['logging']['bug_report_email'], 'subject' => t('Errors Reporting of the pH7 Framework')];
             (new \PH7\Framework\Mail\Mail())->send($aInfo, $sContents, false);
             break;
         default:
             exit('Invalid Log Option.');
     }
 }
 /**
  * Output Stream Views.
  *
  * @final
  * @param string $sFile Specify another display file instead of the default layout file. Default NULL
  * @return void
  */
 public final function output($sFile = null)
 {
     /**
      * Remove database information for the tpl files in order to prevent any attack attempt.
      **/
     \PH7\Framework\Mvc\Router\FrontController::getInstance()->_removeDatabaseInfo();
     /**
      * Destroy all object instances of PDO and close the connection to the database before the display and the start of the template and free memory
      */
     M\Engine\Db::free();
     /**
      * Output our template and encoding.
      */
     $sFile = !empty($sFile) ? $sFile : $this->view->getMainPage();
     // header('Content-type: text/html; charset=' . PH7_ENCODING);
     $this->view->display($sFile, PH7_PATH_TPL . PH7_TPL_NAME . PH7_DS);
     $this->view->clean();
     // Clean Template Data
 }
 /**
  * Get all modules status (enabled & disabled).
  *
  * @param string $sFolderName  Name of the module folder. Default: NULL
  * @return object
  */
 public function get($sFolderName = null)
 {
     $this->cache->start(static::CACHE_GROUP, 'list' . $sFolderName, static::CACHE_TIME);
     if (!($oData = $this->cache->get())) {
         $bIsFolderName = !empty($sFolderName);
         $sSelect = $bIsFolderName ? 'enabled' : '*';
         $sSqlWhere = $bIsFolderName ? 'WHERE folderName = :modName LIMIT 1' : '';
         $rStmt = Db::getInstance()->prepare('SELECT ' . $sSelect . ' FROM ' . DB::prefix('SysModsEnabled') . $sSqlWhere);
         if ($bIsFolderName) {
             $rStmt->bindValue(':modName', $sFolderName, \PDO::PARAM_STR);
         }
         $rStmt->execute();
         $sFetchMethod = $bIsFolderName ? 'fetch' : 'fetchAll';
         $oData = $rStmt->{$sFetchMethod}(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $this->cache->put($oData);
     }
     return $oData;
 }
 public function album($iProfileId = null, $iAlbumId = null, $iApproved = 1, $iOffset, $iLimit, $sOrder = self::CREATED)
 {
     $this->cache->start(self::CACHE_GROUP, 'album' . $iProfileId . $iAlbumId . $iApproved . $iOffset . $iLimit . $sOrder, static::CACHE_TIME);
     if (!($oData = $this->cache->get())) {
         $iOffset = (int) $iOffset;
         $iLimit = (int) $iLimit;
         $sSqlProfileId = !empty($iProfileId) ? ' a.profileId = :profileId AND ' : '';
         $sSqlAlbum = !empty($iAlbumId) ? ' a.albumId=:albumId AND ' : '';
         $rStmt = Db::getInstance()->prepare('SELECT a.*, m.username, m.firstName, m.sex FROM' . Db::prefix('AlbumsPictures') . 'AS a INNER JOIN' . Db::prefix('Members') . 'AS m ON a.profileId = m.profileId WHERE' . $sSqlProfileId . $sSqlAlbum . ' a.approved=:approved ORDER BY ' . $sOrder . ' DESC LIMIT :offset, :limit');
         !empty($iProfileId) ? $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT) : '';
         !empty($iAlbumId) ? $rStmt->bindValue(':albumId', $iAlbumId, \PDO::PARAM_INT) : '';
         $rStmt->bindValue(':approved', $iApproved, \PDO::PARAM_INT);
         $rStmt->bindParam(':offset', $iOffset, \PDO::PARAM_INT);
         $rStmt->bindParam(':limit', $iLimit, \PDO::PARAM_INT);
         $rStmt->execute();
         $oData = isset($iProfileId, $iAlbumId) ? $rStmt->fetch(\PDO::FETCH_OBJ) : $rStmt->fetchAll(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $this->cache->put($oData);
     }
     return $oData;
 }
Example #30
0
 /**
  * Gets total note posts.
  *
  * @param integer $iApproved (0 = Unmoderated | 1 = Approved | NULL = unmoderated and approved) Default 1
  * @param integer $iDay Default 0
  * @return integer
  */
 public function totalPosts($iApproved = 1, $iDay = 0)
 {
     $this->cache->start(self::CACHE_GROUP, 'totalPosts', static::CACHE_TIME);
     if (!($iData = $this->cache->get())) {
         $iDay = (int) $iDay;
         $sSqlWhere = isset($iApproved) ? 'WHERE' : '';
         $sSqlAnd = isset($iApproved) && $iDay > 0 ? ' AND' : ($iDay > 0 ? 'WHERE' : '');
         $sSqlApproved = isset($iApproved) ? ' approved = :approved' : '';
         $sSqlDay = $iDay > 0 ? ' (createdDate + INTERVAL ' . $iDay . ' DAY) > NOW()' : '';
         $rStmt = Db::getInstance()->prepare('SELECT COUNT(postId) AS totalPosts FROM' . Db::prefix('Notes') . $sSqlWhere . $sSqlApproved . $sSqlAnd . $sSqlDay);
         if (isset($iApproved)) {
             $rStmt->bindValue(':approved', $iApproved, \PDO::PARAM_INT);
         }
         $rStmt->execute();
         $oRow = $rStmt->fetch(\PDO::FETCH_OBJ);
         Db::free($rStmt);
         $iData = (int) $oRow->totalPosts;
         unset($oRow);
         $this->cache->put($iData);
     }
     return $iData;
 }