Example #1
0
 protected function heartbeat()
 {
     // Default values
     $sFrom = $_SESSION['messenger_username'];
     $sSent = '';
     $oQuery = $this->_oMessengerModel->select($sFrom);
     $sItems = '';
     foreach ($oQuery as $oData) {
         $sFrom = escape($oData->fromUser, true);
         $sSent = escape($oData->sent, true);
         $sMsg = $this->sanitize($oData->message);
         $sMsg = Emoticon::init($sMsg, false);
         if (!isset($_SESSION['messenger_openBoxes'][$sFrom]) && isset($_SESSION['messenger_history'][$sFrom])) {
             $sItems = $_SESSION['messenger_history'][$sFrom];
         }
         $sItems .= $this->setJsonContent(['user' => $sFrom, 'msg' => $sMsg]);
         if (!isset($_SESSION['messenger_history'][$sFrom])) {
             $_SESSION['messenger_history'][$sFrom] = '';
         }
         $_SESSION['messenger_history'][$sFrom] .= $this->setJsonContent(['user' => $sFrom, 'msg' => $sMsg]);
         unset($_SESSION['messenger_boxes'][$sFrom]);
         $_SESSION['messenger_openBoxes'][$sFrom] = $sSent;
     }
     if (!empty($_SESSION['messenger_openBoxes'])) {
         foreach ($_SESSION['messenger_openBoxes'] as $sBox => $iTime) {
             if (!isset($_SESSION['messenger_boxes'][$sBox])) {
                 $iNow = time() - strtotime($iTime);
                 $sTime = date('g:iA M dS', strtotime($iTime));
                 $sMsg = t('Sent at %0%', Framework\Date\Various::textTimeStamp($sTime));
                 if ($iNow > 180) {
                     $sItems .= $this->setJsonContent(['status' => '2', 'user' => $sBox, 'msg' => $sMsg]);
                     if (!isset($_SESSION['messenger_history'][$sBox])) {
                         $_SESSION['messenger_history'][$sBox] = '';
                     }
                     $_SESSION['messenger_history'][$sBox] .= $this->setJsonContent(['status' => '2', 'user' => $sBox, 'msg' => $sMsg]);
                     $_SESSION['messenger_boxes'][$sBox] = 1;
                 }
             }
         }
     }
     if (!$this->isOnline($sFrom)) {
         $sItems = t('You must have the ONLINE status in order to speak instantaneous.');
     } elseif (!$this->isOnline($sSent)) {
         $sItems = '<small><em>' . t('%0% is offline. Send a Private Message instead.', $sSent) . '</em></small>';
     } else {
         $this->_oMessengerModel->update($sFrom);
     }
     if ($sItems != '') {
         $sItems = substr($sItems, 0, -1);
     }
     Http::setContentType('application/json');
     echo '{"items": [' . $sItems . ']}';
     exit(0);
 }
Example #2
0
 /**
  * Generates HTML contents Video.
  *
  * @param object $oData
  * @param string $sMedia Type of the media ('preview' or 'movie'). Default value is 'movie'.
  * @param integer $iWidth Default 600
  * @param integer $iHeight Default 400
  * @return void
  */
 public static function generate($oData, $sMedia = 'movie', $iWidth = 600, $iHeight = 400)
 {
     $sDurationTag = '<div class="video_duration">' . Various::secToTime($oData->duration) . '</div>';
     if ((new VideoCore())->isApi($oData->file)) {
         $oVideo = (new Api())->getMeta($oData->file, $sMedia, $iWidth, $iHeight);
         if ($sMedia == 'preview') {
             echo $sDurationTag, '<a href="', $oData->file, '" title="', $oData->title, '" data-popup="frame-video"><img src="', $oVideo, '" alt="', $oData->title, '" title="', $oData->title, '" /></a>';
         } else {
             echo $oVideo;
         }
     } else {
         $sDir = 'video/file/' . $oData->username . PH7_SH . $oData->albumId . PH7_SH;
         $sVidPath1 = $sDir . $oData->file . '.webm';
         $sVidPath2 = $sDir . $oData->file . '.mp4';
         // If the video is not found on the server, we show a video that shows an appropriate message.
         if (!(is_file(PH7_PATH_PUBLIC_DATA_SYS_MOD . $sVidPath1) && is_file(PH7_PATH_PUBLIC_DATA_SYS_MOD . $sVidPath2))) {
             $sVidPath1 = PH7_URL_DATA_SYS_MOD . 'video/not_found.webm';
             $sVidPath2 = PH7_URL_DATA_SYS_MOD . 'video/not_found.mp4';
         }
         if (is_file(PH7_PATH_PUBLIC_DATA_SYS_MOD . $sDir . $oData->thumb)) {
             $oFile = new File();
             $sThumbName = $oFile->getFileWithoutExt($oData->thumb);
             $sThumbExt = $oFile->getFileExt($oData->thumb);
             unset($oFile);
             $aThumb = ['', '-1', '-2', '-3', '-4'];
             shuffle($aThumb);
             $sThumbUrl = PH7_URL_DATA_SYS_MOD . $sDir . $sThumbName . $aThumb[0] . PH7_DOT . $sThumbExt;
         } else {
             $sThumbUrl = PH7_URL_TPL . PH7_TPL_NAME . PH7_SH . PH7_IMG . 'icon/none.jpg';
         }
         $sParam = $sMedia == 'movie' && DbConfig::getSetting('autoplayVideo') ? 'autoplay="autoplay"' : '';
         $sVideoTag = '
         <video poster="' . $sThumbUrl . '" width="' . $iWidth . '" height="' . $iHeight . '" controls="controls" ' . $sParam . '>
             <source src="' . PH7_URL_DATA_SYS_MOD . $sVidPath1 . '" type="video/webm" />
             <source src="' . PH7_URL_DATA_SYS_MOD . $sVidPath2 . '" type="video/mp4" />
             ' . t('Your browser is obsolete. Please use a browser that supports HTML5.') . '
         </video>
         <div class="center">
             <button class="bold" onclick="Video.playPause()">' . t('Play/Pause') . '</button>
             <button onclick="Video.bigSize()">' . t('Big') . '</button>
             <button onclick="Video.normalSize()">' . t('Normal') . '</button>
             <button onclick="Video.smallSize()">' . t('Small') . '</button>
         </div>';
         if ($sMedia == 'preview') {
             echo $sDurationTag, '<a href="#watch', $oData->videoId, '" title="', $oData->title, '" data-popup="video"><img src="', $sThumbUrl, '" alt="', $oData->title, '" title="', $oData->title, '" /></a>
             <div class="hidden"><div id="watch', $oData->videoId, '">', $sVideoTag, '</div></div>';
         } else {
             echo $sVideoTag;
         }
     }
 }
 /**
  * Check if the JS validationbox has to be added and redirect if the site hasn't been validated yet for a while.
  *
  * @param object \PH7\Framework\Session\Session $oSess
  * @return boolean
  */
 public static function needInject(Framework\Session\Session $oSess)
 {
     $oVSModel = new ValidateSiteCoreModel();
     $iSinceSiteCreated = VDate::getTime(StatisticCoreModel::getSiteSinceDate());
     // After over 2 months, the site is still not validated, maybe the validation box doesn't really work, so we redirected to the page form
     if (!$oVSModel->is() && VDate::setTime('-2 months') > $iSinceSiteCreated && !$oSess->exists(self::SESS_IS_VISITED)) {
         Header::redirect(Uri::get('validate-site', 'main', 'validationbox'));
     }
     if (!$oVSModel->is() && VDate::setTime('-2 days') > $iSinceSiteCreated) {
         // OK for adding the validation colorbox
         return true;
     }
     return false;
 }
 /**
  * Gets video duration.
  *
  * @return integer Seconds.
  */
 public function getDuration()
 {
     $sTime = exec($this->sFfmpegPath . ' -i ' . $this->aFile['tmp_name'] . ' 2>&1 | grep "Duration" | cut -d \' \' -f 4 | sed s/,//');
     return Various::timeToSec($sTime);
 }
 /**
  * Check and load the files if necessary.
  *
  * @param string $sFileNamePath A pH7Framework filename path.
  * @return void
  */
 private function _loadFile($sFileNamePath)
 {
     $oFile = new File();
     $sFullPath = PH7_PATH_FRAMEWORK . $sFileNamePath;
     $bIsExpiredFile = VDate::setTime('-2 months') > $oFile->getModifTime($sFullPath);
     $bFileExists = $oFile->existFile($sFullPath);
     $bIsTooSmallFile = $oFile->size($sFullPath) < 1000;
     if (!$bFileExists || $bIsTooSmallFile || $bIsExpiredFile) {
         if ($bFileExists) {
             // Delete the file if it already exists
             $oFile->deleteFile($sFullPath);
         }
         $this->_downloadFile($sFileNamePath, $oFile);
     }
     unset($oFile);
 }
 public function index()
 {
     $oUserModel = new UserModel();
     // Add the style sheet for the Tabs Menu
     $this->design->addCss(PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_CSS, 'tabs.css');
     // Add the JavaScript file for the Ajax Friend
     $this->design->addJs(PH7_LAYOUT . PH7_SYS . PH7_MOD . $this->registry->module . PH7_SH . PH7_TPL . PH7_TPL_MOD_NAME . PH7_SH . PH7_JS, 'friend.js');
     // Set the Profile username
     $this->sUsername = $this->httpRequest->get('username', 'string');
     // Set the Profile ID and Visitor ID
     $this->iProfileId = $oUserModel->getId(null, $this->sUsername);
     $this->iVisitorId = (int) $this->session->get('member_id');
     // Read the Profile information
     $oUser = $oUserModel->readProfile($this->iProfileId);
     if (!empty($oUser->username) && $this->str->equalsIgnoreCase($this->sUsername, $oUser->username)) {
         // The administrators can view all profiles and profile visits are not saved.
         if (!AdminCore::auth()) {
             $this->_initPrivacy($oUserModel, $this->iProfileId, $this->iVisitorId);
         }
         // Gets the Profile background
         $this->view->img_background = $oUserModel->getBackground($this->iProfileId, 1);
         $oFields = $oUserModel->getInfoFields($this->iProfileId);
         unset($oUserModel);
         $sFirstName = !empty($oUser->firstName) ? $this->str->escape($this->str->upperFirst($oUser->firstName), true) : '';
         $sLastName = !empty($oUser->lastName) ? $this->str->escape($this->str->upperFirst($oUser->lastName), true) : '';
         $sMiddleName = !empty($oFields->middleName) ? $this->str->escape($this->str->upperFirst($oFields->middleName), true) : '';
         $sCountry = !empty($oFields->country) ? $oFields->country : '';
         $sCity = !empty($oFields->city) ? $this->str->escape($this->str->upperFirst($oFields->city), true) : '';
         $sState = !empty($oFields->state) ? $this->str->escape($this->str->upperFirst($oFields->state), true) : '';
         $sDescription = !empty($oFields->description) ? Emoticon::init(Ban::filterWord($oFields->description)) : '';
         // Age
         $this->view->birth_date = $this->dateTime->get($oUser->birthDate)->date();
         $aAge = explode('-', $oUser->birthDate);
         $iAge = (new Framework\Math\Measure\Year($aAge[0], $aAge[1], $aAge[2]))->get();
         // Links of the Menubar
         $iNbFriend = FriendModel::totalFriends($this->iProfileId);
         $sNbFriend = $iNbFriend > 0 ? ' (' . $iNbFriend . ')' : '';
         $sFriendTxt = $iNbFriend <= 1 ? $iNbFriend == 1 ? t('Friend:') : t('No Friends') : t('Friends:');
         if ($this->sUserAuth) {
             $iNbMutFriend = (new FriendModel())->get($this->iVisitorId, $this->iProfileId, null, true, null, null, null, null);
             $sNbMutFriend = $iNbMutFriend > 0 ? ' (' . $iNbMutFriend . ')' : '';
             $sMutFriendTxt = $iNbMutFriend <= 1 ? $iNbMutFriend == 1 ? t('Mutual Friend:') : t('No Mutual Friends') : t('Mutuals Friends:');
         }
         $sMailLink = $this->sUserAuth ? Uri::get('mail', 'main', 'compose', $this->sUsername) : Uri::get('user', 'signup', 'step1', '?' . Url::httpBuildQuery(array('msg' => t('You need to free register for send a message to %0%.', $sFirstName), 'ref' => 'profile', 'a' => 'mail', 'u' => $this->sUsername, 'f_n' => $sFirstName, 's' => $oUser->sex)), false);
         $sMessengerLink = $this->sUserAuth ? 'javascript:void(0)" onclick="Messenger.chatWith(\'' . $this->sUsername . '\')' : Uri::get('user', 'signup', 'step1', '?' . Url::httpBuildQuery(array('msg' => t('You need to free register for talk to %0%.', $sFirstName), 'ref' => 'profile', 'a' => 'messenger', 'u' => $this->sUsername, 'f_n' => $sFirstName, 's' => $oUser->sex)), false);
         $sBefriendLink = $this->sUserAuth ? 'javascript:void(0)" onclick="friend(\'add\',' . $this->iProfileId . ',\'' . (new Framework\Security\CSRF\Token())->generate('friend') . '\')' : Uri::get('user', 'signup', 'step1', '?' . Url::httpBuildQuery(array('msg' => t('Free Sign up for %site_name% to become friend with %0%.', $sFirstName), 'ref' => 'profile', 'a' => 'befriend&', 'u' => $this->sUsername, 'f_n' => $sFirstName, 's' => $oUser->sex)), false);
         $this->view->page_title = t('Meet %0%, A beautiful %1% looking some %2% - %3% years - %4% - %5% %6%', $sFirstName, t($oUser->sex), t($oUser->matchSex), $iAge, t($sCountry), $sCity, $sState);
         $this->view->meta_description = t('Meet %0% %1% | %2% - %3%', $sFirstName, $sLastName, $this->sUsername, substr($sDescription, 0, 100));
         $this->view->h1_title = t('Meet <span class="pH1">%0%</span> on <span class="pH0">%site_name%</span>', $sFirstName);
         $this->view->h2_title = t('A <span class="pH1">%0%</span> of <span class="pH3">%1% years</span>, from <span class="pH2">%2%, %3% %4%</span>', t($oUser->sex), $iAge, t($sCountry), $sCity, $sState);
         $this->view->avatarDesign = new AvatarDesignCore();
         // Avatar Design Class
         // Member Menubar
         $this->view->friend_link = $sFriendTxt . $sNbFriend;
         if ($this->sUserAuth) {
             $this->view->mutual_friend_link = $sMutFriendTxt . $sNbMutFriend;
         }
         $this->view->mail_link = $sMailLink;
         $this->view->messenger_link = $sMessengerLink;
         $this->view->befriend_link = $sBefriendLink;
         // Set parameters Google Map
         $oMap = new Map();
         $oMap->setCenter($sCity . ' ' . $sState . ' ' . t($sCountry));
         $oMap->setSize('600px', '300px');
         $oMap->setDivId('profileMap');
         $oMap->setZoom(12);
         $oMap->addMarkerByAddress($sCity . ' ' . $sState . ' ' . t($sCountry), t('Meet %0% near here!', $this->sUsername));
         $oMap->generate();
         $this->view->map = $oMap->getMap();
         unset($oMap);
         $this->view->id = $this->iProfileId;
         $this->view->username = $this->sUsername;
         $this->view->first_name = $sFirstName;
         $this->view->last_name = $sLastName;
         $this->view->middle_name = $sMiddleName;
         $this->view->sex = $oUser->sex;
         $this->view->match_sex = $oUser->matchSex;
         $this->view->match_sex_search = str_replace(array('[code]', ','), '&amp;sex%5B%5D=', '[code]' . $oUser->matchSex);
         $this->view->age = $iAge;
         $this->view->country = t($sCountry);
         $this->view->country_code = $sCountry;
         $this->view->city = $sCity;
         $this->view->state = $sState;
         $this->view->description = nl2br($sDescription);
         $this->view->join_date = VDate::textTimeStamp($oUser->joinDate);
         $this->view->last_activity = VDate::textTimeStamp($oUser->lastActivity);
         $this->view->fields = $oFields;
         $this->view->is_logged = $this->sUserAuth;
         $this->view->is_himself_profile = $this->str->equals($this->iVisitorId, $this->iProfileId);
         // Stat Profile
         Statistic::setView($this->iProfileId, 'Members');
     } else {
         $this->_notFound();
     }
     $this->output();
 }
Example #7
0
 /**
  * Check and load the files if necessary.
  *
  * @return void
  */
 private function _loadFile()
 {
     $oFile = new File();
     $sFileNamePath = PH7_PATH_FRAMEWORK . 'Core/License.class.php';
     $bIsExpiredFile = $oFile->modificationTime($sFileNamePath) + VDate::setTime('+1 month') < VDate::getTime();
     if (!$oFile->existsFile($sFileNamePath) || $bIsExpiredFile) {
         if ($bIsExpiredFile) {
             $oFile->deleteFile($sFileNamePath);
         }
         $this->_downloadFile($sFileNamePath, $oFile);
     }
     unset($oFile);
 }