public function __construct()
 {
     parent::__construct();
     $oBlog = new Blog();
     $oBlogModel = new BlogModel();
     if (!$oBlog->checkPostId($this->httpRequest->post('post_id'))) {
         \PFBC\Form::setError('form_blog', t('The ID of the article is invalid or incorrect.'));
     } else {
         $aData = ['post_id' => $this->httpRequest->post('post_id'), 'lang_id' => $this->httpRequest->post('lang_id'), 'title' => $this->httpRequest->post('title'), 'content' => $this->httpRequest->post('content', Http::ONLY_XSS_CLEAN), 'slogan' => $this->httpRequest->post('$slogan'), 'tags' => $this->httpRequest->post('tags'), 'page_title' => $this->httpRequest->post('page_title'), 'meta_description' => $this->httpRequest->post('meta_description'), 'meta_keywords' => $this->httpRequest->post('meta_keywords'), 'meta_robots' => $this->httpRequest->post('meta_robots'), 'meta_author' => $this->httpRequest->post('meta_author'), 'meta_copyright' => $this->httpRequest->post('meta_copyright'), 'enable_comment' => $this->httpRequest->post('enable_comment'), 'created_date' => $this->dateTime->get()->dateTime('Y-m-d H:i:s')];
         if (!$oBlogModel->addPost($aData)) {
             $this->sMsg = t('An error occurred while adding the article.');
         } else {
             /*** Set the categorie(s) ***/
             /**
              * WARNING: Be careful, you should use the \PH7\Framework\Mvc\Request\Http::ONLY_XSS_CLEAN constant, otherwise the Http::post() method
              * removes the special tags and damages the SQL queries for entry into the database.
              */
             $iBlogId = Db::getInstance()->lastInsertId();
             foreach ($this->httpRequest->post('category_id', Http::ONLY_XSS_CLEAN) as $iCategoryId) {
                 $oBlogModel->addCategory($iCategoryId, $iBlogId);
             }
             /*** Set the thumbnail if there's one ***/
             $oPost = $oBlogModel->readPost($aData['post_id']);
             $oBlog->setThumb($oPost, $this->file);
             /* Clean BlogModel Cache */
             (new Framework\Cache\Cache())->start(BlogModel::CACHE_GROUP, null, null)->clear();
             $this->sMsg = t('Post created successfully!');
         }
         Header::redirect(Uri::get('blog', 'main', 'read', $this->httpRequest->post('post_id')), $this->sMsg);
     }
 }
Example #2
0
 public function __construct()
 {
     parent::__construct();
     /**
      * This can cause minor errors (eg if a user sent a file that is not a video).
      * So we hide the errors if we are not in development mode.
      */
     if (!isDebug()) {
         error_reporting(0);
     }
     // Resizing and saving the video album thumbnail
     $oPicture = new Image($_FILES['album']['tmp_name']);
     if (!$oPicture->validate()) {
         \PFBC\Form::setError('form_video_album', Form::wrongImgFileTypeMsg());
     } else {
         $iApproved = DbConfig::getSetting('videoManualApproval') == 0 ? '1' : '0';
         $sFileName = Various::genRnd($oPicture->getFileName(), 1) . '-thumb.' . $oPicture->getExt();
         (new VideoModel())->addAlbum($this->session->get('member_id'), $this->httpRequest->post('name'), $this->httpRequest->post('description'), $sFileName, $this->dateTime->get()->dateTime('Y-m-d H:i:s'), $iApproved);
         $iLastAlbumId = (int) Db::getInstance()->lastInsertId();
         $oPicture->square(200);
         /* Set watermark text on thumbnail */
         $sWatermarkText = DbConfig::getSetting('watermarkTextImage');
         $iSizeWatermarkText = DbConfig::getSetting('sizeWatermarkTextImage');
         $oPicture->watermarkText($sWatermarkText, $iSizeWatermarkText);
         $sPath = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'video/file/' . $this->session->get('member_username') . PH7_DS . $iLastAlbumId . PH7_DS;
         $this->file->createDir($sPath);
         $oPicture->save($sPath . $sFileName);
         /* Clean VideoModel Cache */
         (new Framework\Cache\Cache())->start(VideoModel::CACHE_GROUP, null, null)->clear();
         HeaderUrl::redirect(Uri::get('video', 'main', 'addvideo', $iLastAlbumId));
     }
 }
 /**
  * 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);
 }
 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;
 }
Example #5
0
 public function __construct()
 {
     parent::__construct();
     // Thumbnail
     $oImg = new Image($_FILES['thumb']['tmp_name']);
     if (!$oImg->validate()) {
         \PFBC\Form::setError('form_game', Form::wrongImgFileTypeMsg());
         return;
         // Stop execution of the method.
     }
     $sThumbFile = Various::genRnd($oImg->getFileName(), 30) . $oImg->getExt();
     $sThumbDir = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'game/img/thumb/';
     $oImg->square(60);
     $oImg->save($sThumbDir . $sThumbFile);
     unset($oImg);
     // Game
     $sGameFile = Various::genRnd($_FILES['file']['name'], 30) . PH7_DOT . $this->file->getFileExt($_FILES['file']['name']);
     $sGameDir = PH7_PATH_PUBLIC_DATA_SYS_MOD . 'game/file/';
     // If the folders is not created (games not installed), yet we will create.
     $this->file->createDir(array($sThumbDir, $sGameDir));
     if (!@move_uploaded_file($_FILES['file']['tmp_name'], $sGameDir . $sGameFile)) {
         \PFBC\Form::setError('form_game', t('Impossible to upload the game. If you are the administrator, please check if the folder of games data has the write permission (CHMOD 755).'));
     } else {
         $aData = ['category_id' => $this->httpRequest->post('category_id', 'int'), 'name' => $this->httpRequest->post('name'), 'title' => $this->httpRequest->post('title'), 'description' => $this->httpRequest->post('description'), 'keywords' => $this->httpRequest->post('keywords'), 'thumb' => $sThumbFile, 'file' => $sGameFile];
         (new GameModel())->add($aData);
         /* Clean GameModel Cache */
         (new Framework\Cache\Cache())->start(GameModel::CACHE_GROUP, null, null)->clear();
         HeaderUrl::redirect(Uri::get('game', 'main', 'game', $aData['title'] . ',' . Db::getInstance()->lastInsertId()), t('The game was added successfully!'));
     }
 }
 /**
  * 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 function insert($sKey, $fLastIp)
 {
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('Likes') . 'SET keyId =:key ,votes=1 , lastVote = NOW(), lastIp =:lastIp');
     $rStmt->bindValue(':key', $sKey, \PDO::PARAM_STR);
     $rStmt->bindValue(':lastIp', $fLastIp, \PDO::PARAM_INT);
     return $rStmt->execute();
 }
Example #8
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;
 }
Example #9
0
 /**
  * Delete a comment.
  *
  * @param integer $iRecipientId The Comment Recipient ID.
  * @param string $sTable The Comment Table.
  * @return boolean Returns TRUE on success, FALSE on failure.
  */
 public static function deleteRecipient($iRecipientId, $sTable)
 {
     $sTable = CommentCore::checkTable($sTable);
     $iRecipientId = (int) $iRecipientId;
     $rStmt = Db::getInstance()->prepare('DELETE FROM' . Db::prefix('Comments' . $sTable) . 'WHERE recipient = :recipient');
     $rStmt->bindValue(':recipient', $iRecipientId, \PDO::PARAM_INT);
     return $rStmt->execute();
 }
 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;
 }
 /**
  * Delete Affiliate.
  *
  * @param integer $iProfileId
  * @param string $sUsername
  * @return void
  */
 public function delete($iProfileId, $sUsername)
 {
     $iProfileId = (int) $iProfileId;
     $oDb = Db::getInstance();
     $oDb->exec('DELETE FROM' . Db::prefix('AffiliatesInfo') . 'WHERE profileId = ' . $iProfileId . ' LIMIT 1');
     $oDb->exec('DELETE FROM' . Db::prefix('Affiliates') . 'WHERE profileId = ' . $iProfileId . ' LIMIT 1');
     unset($oDb);
 }
 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;
 }
Example #13
0
 /**
  * Add a new message.
  *
  * @param string $sFrom Username
  * @param string $sTo Username 2
  * @param string $sMessage Message content
  * @param string $sDate In date format: 0000-00-00 00:00:00
  * @return boolean Returns TRUE on success or FALSE on failure
  */
 public function insert($sFrom, $sTo, $sMessage, $sDate)
 {
     $rStmt = Db::getInstance()->prepare('INSERT INTO' . Db::prefix('Messenger') . '(fromUser, toUser, message, sent) VALUES (:from, :to, :message, :date)');
     $rStmt->bindValue(':from', $sFrom, \PDO::PARAM_STR);
     $rStmt->bindValue(':to', $sTo, \PDO::PARAM_STR);
     $rStmt->bindValue(':message', $sMessage, \PDO::PARAM_STR);
     $rStmt->bindValue(':date', $sDate, \PDO::PARAM_STR);
     return $rStmt->execute();
 }
 /**
  * Generic method to check if the field exists and with the check \PH7\Framework\Mvc\Model\Engine\Util\Various::checkModelTable() method.
  *
  * @access protected
  * @param string $sColumn
  * @param string $sValue
  * @param string $sTable
  * @param string $sType PDO PARAM TYPE (\PDO::PARAM_*). Default is \PDO::PARAM_STR
  * @param string $sParam Optional WHERE parameter SQL.
  * @return boolean Returns TRUE if it exists, FALSE otherwise.
  */
 protected function _is($sColumn, $sValue, $sTable, $sType = null, $sParam = null)
 {
     Various::checkModelTable($sTable);
     $sType = empty($sType) ? \PDO::PARAM_STR : $sType;
     $rExists = Db::getInstance()->prepare('SELECT COUNT(' . $sColumn . ') FROM' . Db::prefix($sTable) . 'WHERE ' . $sColumn . ' = :column ' . $sParam . ' LIMIT 1');
     $rExists->bindValue(':column', $sValue, $sType);
     $rExists->execute();
     return $rExists->fetchColumn() == 1;
 }
 public function updateScore($fScore, $iId, $sTable)
 {
     $sTable = Various::checkTable($sTable);
     $sWhere = Various::convertTableToId($sTable);
     $rStmt = Db::getInstance()->prepare('UPDATE' . Db::prefix($sTable) . 'SET score = :score WHERE ' . $sWhere . ' = :id');
     $rStmt->bindValue(':score', $fScore);
     $rStmt->bindValue(':id', $iId);
     return $rStmt->execute();
 }
 public function deletePhoto($iProfileId, $iAlbumId, $iPictureId = null)
 {
     $sSqlPictureId = !empty($iPictureId) ? ' AND pictureId=:pictureId ' : '';
     $rStmt = Db::getInstance()->prepare('DELETE FROM' . Db::prefix('Pictures') . 'WHERE profileId=:profileId AND albumId=:albumId' . $sSqlPictureId);
     $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
     $rStmt->bindValue(':albumId', $iAlbumId, \PDO::PARAM_INT);
     !empty($iPictureId) ? $rStmt->bindValue(':pictureId', $iPictureId, \PDO::PARAM_INT) : '';
     return $rStmt->execute();
 }
Example #17
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 #18
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);
 }
 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;
 }
 public function ban($iProfileId, $iBan, $sTable = 'Members')
 {
     Various::checkModelTable($sTable);
     $iProfileId = (int) $iProfileId;
     $iBan = (int) $iBan;
     $rStmt = Db::getInstance()->prepare('UPDATE' . Db::prefix($sTable) . 'SET ban = :ban WHERE profileId = :profileId');
     $rStmt->bindValue(':profileId', $iProfileId, \PDO::PARAM_INT);
     $rStmt->bindValue(':ban', $iBan, \PDO::PARAM_INT);
     return $rStmt->execute();
 }
Example #21
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;
 }
 /**
  * Executes SQL queries.
  *
  * @param string $sSqlFile File SQL.
  * @return mixed (boolean | array) Returns TRUE if there are no errors, otherwise returns an ARRAY of error information.
  */
 public static function execQueryFile($sSqlFile)
 {
     if (!is_file($sSqlFile)) {
         return false;
     }
     $sSqlContent = file_get_contents($sSqlFile);
     $sSqlContent = str_replace(PH7_TABLE_PREFIX, Db::prefix(), $sSqlContent);
     $rStmt = Db::getInstance()->exec($sSqlContent);
     unset($sSqlContent);
     return $rStmt === false ? $rStmt->errorInfo() : true;
 }
 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;
 }
 /**
  * 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 #25
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 #26
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;
 }
Example #27
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 #28
0
 /**
  * Detect duplicate contents.
  *
  * @param string $sCheckContent Message content to check.
  * @param string $sFindColumn
  * @param string $sColumnId
  * @param integer $iFindId
  * @param string $sTable
  * @param string $sAdditionalSql Additional SQL code. Default NULL
  * @return boolean Returns TRUE if similar content was found in the table, FALSE otherwise.
  */
 public static function detectDuplicate($sCheckContent, $sFindColumn, $sColumnId, $iFindId, $sTable, $sAdditionalSql = null)
 {
     $bReturn = false;
     // Default value
     $sSql = !empty($sAdditionalSql) ? ' ' . $sAdditionalSql : '';
     $rStmt = Db::getInstance()->prepare('SELECT ' . $sFindColumn . ' AS content FROM ' . Db::prefix($sTable) . 'WHERE ' . $sColumnId . ' = :id' . $sSql);
     $rStmt->bindValue(':id', $iFindId, \PDO::PARAM_INT);
     $rStmt->execute();
     while ($oRow = $rStmt->fetch(\PDO::FETCH_OBJ)) {
         if ($bReturn = SecMsg::detectDuplicate($sCheckContent, $oRow->content)) {
             break;
         }
     }
     // TRUE = Duplicate content detected, FALSE otherwise.
     return $bReturn;
 }
 /**
  * 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;
 }