Beispiel #1
0
 public function __construct()
 {
     Import::pH7App(PH7_SYS . PH7_MOD . 'im.models.MessengerModel');
     $this->_oHttpRequest = new HttpRequest();
     $this->_oMessengerModel = new MessengerModel();
     switch ($this->_oHttpRequest->get('act')) {
         case 'heartbeat':
             $this->heartbeat();
             break;
         case 'send':
             $this->send();
             break;
         case 'close':
             $this->close();
             break;
         case 'startsession':
             $this->startSession();
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
     if (empty($_SESSION['messenger_history'])) {
         $_SESSION['messenger_history'] = [];
     }
     if (empty($_SESSION['messenger_openBoxes'])) {
         $_SESSION['messenger_openBoxes'] = [];
     }
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct();
     $this->_oWallModel = new WallModel();
     $this->_oAvatarDesign = new AvatarDesignCore();
     // Avatar Design Class
     switch ($this->httpRequest->post('type')) {
         case 'show':
             $this->show();
             break;
         case 'showCommentProfile':
             $this->showCommentProfile();
             break;
         case 'add':
             $this->add();
             break;
         case 'edit':
             $this->edit();
             break;
         case 'delete':
             $this->delete();
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
 }
 public function renderAjaxErrorResponse()
 {
     $errors = $this->parse($this->form->getErrors());
     if (!empty($errors)) {
         \PH7\Framework\Http\Http::setContentType('application/json');
         echo json_encode(array('errors' => $errors));
     }
 }
 /**
  * Support for AJAX validation, checking the values.
  *
  * @param string $sInputVal
  * @param string $sFieldId
  * @param string $sParam1
  * @param string $sParam2
  * @return void
  */
 public function form($sInputVal, $sFieldId, $sParam1, $sParam2)
 {
     $sInputVal = $this->_oStr->escape($sInputVal, true);
     // Determine the field to validate and perform validation.
     if (strstr($sFieldId, 'str_')) {
         // Check Text
         $this->txt($sInputVal, $sParam1, $sParam2);
     } elseif (strstr($sFieldId, 'name_')) {
         $this->name($sInputVal);
     } elseif (strstr($sFieldId, 'email')) {
         // Check email address.
         $this->email($sInputVal, $sParam1, $sParam2);
     } elseif (strstr($sFieldId, 'url')) {
         // Check the url address.
         $this->url($sInputVal);
     } elseif (strstr($sFieldId, 'phone')) {
         // Check the phone number
         $this->phone($sInputVal);
     } else {
         switch ($sFieldId) {
             // Check that the username is valid.
             case 'username':
                 $this->username($sInputVal, $sParam1);
                 break;
                 // Check Password.
             // Check Password.
             case 'password':
                 $this->password($sInputVal);
                 break;
                 // Check of the date of birth
             // Check of the date of birth
             case 'birth_date':
                 $this->birthDate($sInputVal);
                 break;
                 // Check the captcha.
             // Check the captcha.
             case 'ccaptcha':
                 $this->captcha($sInputVal);
                 break;
                 // Check acceptance of the terms of use.
             // Check acceptance of the terms of use.
             case 'terms-0':
                 $this->terms($sInputVal);
                 break;
                 // If we receive another invalid value, we display a message with a HTTP header.
             // If we receive another invalid value, we display a message with a HTTP header.
             default:
                 Framework\Http\Http::setHeadersByCode(400);
                 exit('Bad Request Error!');
         }
     }
     echo json_encode(array('status' => $this->_iStatus, 'msg' => $this->_sMsg, 'fieldId' => $sFieldId));
 }
 private function _init()
 {
     switch ((new Http())->post('type')) {
         case 'total_users':
             $this->_mOutput = $this->_oUserModel->total();
             break;
             // If we receive another invalid value, we display a message with a HTTP header.
         // If we receive another invalid value, we display a message with a HTTP header.
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
 }
 public function __construct()
 {
     if (!(new Framework\Security\CSRF\Token())->check('report')) {
         exit(jsonMsg(0, Form::errorTokenMsg()));
     }
     $this->_oHttpRequest = new Http();
     $this->_oReportModel = new ReportModel();
     switch ($this->_oHttpRequest->post('type')) {
         case 'delete':
             $this->delete();
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error');
     }
 }
 /**
  * Allows a redirection URL respecting the HTTP status code for search engines friendly.
  *
  * @static
  * @param string $sUrl Default NULL, so it's the current URL.
  * @param string $sMessage Default NULL, so no message.
  * @param string $sType Type of message: "success", "info", "warning" or "error". Default: "success".
  * @param integer $iRedirectCode Default NULL, so the redirect code will be "301".
  * @return void
  */
 public static function redirect($sUrl = null, $sMessage = null, $sType = 'success', $iRedirectCode = null)
 {
     if (!Http::getStatusCodes($iRedirectCode)) {
         $iRedirectCode = 301;
     }
     Http::setHeadersByCode(Http::getStatusCodes($iRedirectCode));
     $oHttpRequest = new HttpRequest();
     $sUrl = !empty($sUrl) ? $sUrl : $oHttpRequest->currentUrl();
     $sUrl = $oHttpRequest->pH7Url($sUrl);
     unset($oHttpRequest);
     if (!empty($sMessage)) {
         (new \PH7\Framework\Layout\Html\Design())->setFlashMsg($sMessage, $sType);
     }
     header('Location: ' . $sUrl);
     exit;
 }
 private function _init()
 {
     $oHttpRequest = new Http();
     $sParam = $oHttpRequest->post('param');
     $sType = $oHttpRequest->post('type');
     unset($oHttpRequest);
     switch ($sType) {
         case 'profile_link':
             $this->_mOutput = $this->_oUser->getProfileLink($sParam);
             break;
             // If we receive another invalid value, we display a message with a HTTP header.
         // If we receive another invalid value, we display a message with a HTTP header.
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
 }
 public function __construct()
 {
     if (!(new Framework\Security\CSRF\Token())->check('comment')) {
         exit(jsonMsg(0, Form::errorTokenMsg()));
     }
     /** Instance objects for the class * */
     $this->_oSession = new Session();
     $this->_oHttpRequest = new Http();
     $this->_oCommentModel = new CommentModel();
     switch ($this->_oHttpRequest->post('type')) {
         case 'delete':
             $this->delete();
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
 }
Beispiel #10
0
 public function __construct()
 {
     $this->_oHttpRequest = new Http();
     if ($this->_oHttpRequest->postExists('action') && $this->_oHttpRequest->postExists('table') && $this->_oHttpRequest->postExists('score') && $this->_oHttpRequest->postExists('id')) {
         if ($this->_oHttpRequest->post('action') == 'rating') {
             // Only for the Members
             if (!UserCore::auth()) {
                 $this->_iStatus = 0;
                 $this->_sTxt = t('Please <b>register</b> or <b>login</b> to vote.');
             } else {
                 $this->initialize();
             }
         }
     } else {
         Framework\Http\Http::setHeadersByCode(400);
         exit('Bad Request Error!');
     }
 }
 public function index()
 {
     // Add Stylesheet tooltip
     $this->design->addCss(PH7_LAYOUT . PH7_TPL . PH7_TPL_NAME . PH7_SH . PH7_CSS, 'tooltip.css');
     if ($this->httpRequest->getExists('country')) {
         // Get the country and city, limited to 50 characters and remove hyphens in too automatically insert the url.
         $this->registry->country = str_replace('-', ' ', substr($this->str->upperFirst($this->httpRequest->get('country')), 0, 50));
         $this->registry->city = $this->httpRequest->getExists('city') ? str_replace('-', ' ', substr($this->str->upperFirst($this->httpRequest->get('city')), 0, 50)) : '';
         // Set parameters Google Map
         $oMap = new Map();
         $oMap->setCenter($this->registry->country . ' ' . $this->registry->city);
         $oMap->setSize('800px', '690px');
         $oMap->setDivId('map');
         $oMap->setZoom(12);
         $oMap->addMarkerByAddress($this->registry->country . ' ' . $this->registry->city, t('Meet new people here!'));
         $oMap->generate();
         $this->view->map = $oMap->getMap();
         unset($oMap);
         $sCountryCode = $this->getCountryCode();
         // For User Model
         $this->view->userDesignModel = new UserDesignCoreModel();
         $this->view->country_code = $sCountryCode;
         $this->view->city = $this->registry->city;
         // Pagination
         $oPage = new Page();
         $iTotalUsers = (new UserCoreModel())->getGeoProfiles($sCountryCode, $this->registry->city, true, null, null, null);
         $this->view->total_pages = $oPage->getTotalPages($iTotalUsers, 20);
         $this->view->current_page = $oPage->getCurrentPage();
         $this->view->first_user = $oPage->getFirstItem();
         $this->view->nb_user_by_page = $oPage->getNbItemsByPage();
         // SEO Meta
         $this->view->page_title = t('Free online dating in %0% %1%, meet people, find friends. Single men & women in %2% %3%', $this->registry->country, $this->registry->city, $this->registry->country, $this->registry->city);
         $this->view->meta_description = t('Free online dating in %0% with single women & men. Personals, meet people & find friends in %1% on internet dating site. Find sweet love or sex dating and flirt in %2%, %3% with %site_name%', $this->registry->country, $this->registry->country, $this->registry->country, $this->registry->city);
         $this->view->meta_keywords = t('meeting woman, meeting man, %0%, %1%, meet people, networking, friends, communicate, meet online, online community, clubs, announces meeting, free dating, dating, %2% dating, communication, matrimonial meeting, sharing photos, flirt, finding friends, classifieds, personals, online, social networking', $this->registry->country, $this->registry->city, $this->registry->country);
         $this->view->h1_title = t('Meet new people in %0% %1%', '<span class="pH1">' . $this->registry->country . '</span>', '<span class="pH1">' . $this->registry->city . '</span>');
         $sMemberTxt = nt('%n% member', '%n% members', $iTotalUsers);
         $this->view->h3_title = t('%0% lives near %1% %2%', $sMemberTxt, $this->registry->country, $this->registry->city);
     } else {
         // Not found page
         Framework\Http\Http::setHeadersByCode(404);
         $this->view->error = t('Error, country is empty.');
     }
     $this->output();
 }
 public function index()
 {
     // Loading Gettext Language File ...
     (new Lang())->load('hello_world');
     $sUsr = $this->config->values['module.setting']['user'];
     $sPwd = $this->config->values['module.setting']['password'];
     if (Http::requireAuth($sUsr, $sPwd)) {
         // Meta Tags
         $this->view->page_title = t('HTTP Secure Page');
         $this->view->meta_description = t('Simple HTTP Secure Page');
         $this->view->meta_keywords = t('secure,CMS,PHP,framework,MVC,page,HTTP');
         /* H TITLE html tag H1 to H4 */
         $this->view->h1_title = t('HTTP Secure Page');
         // Assign variavle
         $this->view->user = $sUsr;
         // Output Template
         $this->output();
     }
 }
 public function __construct()
 {
     parent::__construct();
     // Available options
     if ($this->httpRequest->getExists('option')) {
         switch ($this->httpRequest->get('option')) {
             // Backup
             case 'backup':
                 $this->backup();
                 break;
                 // Restart Stat
             // Restart Stat
             case 'stat':
                 $this->stat();
                 break;
                 // Repair Tables
             // Repair Tables
             case 'repair':
                 $this->repair();
                 break;
                 // Delete Log
             // Delete Log
             case 'remove_log':
                 $this->removeLog();
                 break;
             default:
                 Framework\Http\Http::setHeadersByCode(400);
                 exit('Bad Request Error!');
         }
     }
     // Clean data
     $this->cleanData();
     // Remove temporary messages
     $this->removeTmpMsg();
     // Delete temporary Data
     $this->removeTmpData();
     // Optimization tables
     $this->optimize();
     echo '<br />' . t('Done!') . '<br />';
     echo t('The Jobs Cron is working to complete successfully!');
 }
 public function __construct()
 {
     parent::__construct();
     $oSubscriptionModel = new SubscriptionModel();
     $sEmail = $this->httpRequest->post('email');
     $sName = $this->httpRequest->post('name');
     $bIsSubscriber = (new ExistsCoreModel())->email($sEmail, 'Subscribers');
     switch ($this->httpRequest->post('direction')) {
         case 'subscrire':
             if (!$bIsSubscriber) {
                 $aData = ['name' => $sName, 'email' => $sEmail, 'current_date' => (new CDateTime())->get()->dateTime('Y-m-d H:i:s'), 'ip' => Ip::get(), 'hash_validation' => Various::genRnd(), 'active' => '0', 'affiliated_id' => (int) (new Cookie())->get(AffiliateCore::COOKIE_NAME)];
                 $sActivateLink = Uri::get('newsletter', 'home', 'activate') . PH7_SH . $aData['email'] . PH7_SH . $aData['hash_validation'];
                 $this->view->content = t('Hi %0%!', $aData['name']) . '<br />' . t("Welcome to %site_name%'s Subscription!") . '<br />' . t('Activation link: %0%.', '<a href="' . $sActivateLink . '">' . $sActivateLink . '</a>');
                 $this->view->footer = t('You are receiving this mail because we received an application for registration with the email "%0%" has been provided in the form of %site_name% (%site_url%).', $aData['email']) . '<br />' . t('If you think someone has used your email address without your knowledge to create an account on %site_name%, please contact us using our contact form available on our website.');
                 $sMessageHtml = $this->view->parseMail(PH7_PATH_SYS . 'global/' . PH7_VIEWS . PH7_TPL_NAME . '/mail/sys/mod/newsletter/registration.tpl', $sEmail);
                 $aInfo = ['subject' => t('Confirm you email address!'), 'to' => $sEmail];
                 if ((new Mail())->send($aInfo, $sMessageHtml)) {
                     \PFBC\Form::setSuccess('form_subscription', t('Please activate your subscription by clicking the activation link you received by email. If you can not find the email, please look in your SPAM FOLDER and mark as not spam.'));
                     $oSubscriptionModel->add($aData);
                 } else {
                     \PFBC\Form::setError('form_subscription', Form::errorSendingEmail());
                 }
             } else {
                 \PFBC\Form::setError('form_subscription', t('Oops! You are already subscribed to our newsletter.'));
             }
             break;
         case 'unsubscribe':
             if ($bIsSubscriber) {
                 $oSubscriptionModel->unsubscribe($sEmail);
                 \PFBC\Form::setSuccess('form_subscription', t('Your subscription was successfully canceled.'));
             } else {
                 \PFBC\Form::setError('form_subscription', t('We have not found any subscriber with the email address.'));
             }
             break;
         default:
             Framework\Http\Http::setHeadersByCode(400);
             exit('Bad Request Error!');
     }
     unset($oSubscriptionModel);
 }
 /**
  * Set a custom Not Found Error Message with HTTP 404 Code Status.
  *
  * @access protected
  * @param boolean $b404Status For the Ajax blocks and others, we can not put HTTP error code 404, so the attribute must be set to "false". Default: TRUE
  * @return void
  */
 protected function notFound($b404Status = true)
 {
     if ($b404Status) {
         Framework\Http\Http::setHeadersByCode(404);
     }
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     $this->view->error = t('Sorry, we weren\'t able to find the page you requested.<br />
             May we suggest <a href="%0%">exploring some tags</a> or <a href="%1%">make a new search</a>.', Uri::get('note', 'main', 'index'), Uri::get('note', 'main', 'search'));
 }
 /**
  * Set a Not Found Error Message with HTTP 404 Code Status.
  *
  * @return void
  */
 private function _notFound()
 {
     Http::setHeadersByCode(404);
     $this->view->page_title = t('Comment Not Found');
     $this->view->error = t('No comments yet, <a class="bold" href="%0%">add one</a>!', Uri::get('comment', 'comment', 'add', $this->sTable . ',' . $this->str->escape($this->httpRequest->get('id'))));
 }
Beispiel #17
0
 /**
  * Routing for files compressing.
  *
  * @return void
  */
 protected function makeCompress()
 {
     $oCompress = new \PH7\Framework\Compress\Compress();
     switch ($this->_sType) {
         case 'html':
             $this->_sContents = $oCompress->parseHtml($this->_sContents);
             break;
         case 'css':
             $this->_sContents = $oCompress->parseCss($this->_sContents);
             break;
         case 'javascript':
             $this->_sContents = $oCompress->parseJs($this->_sContents);
             break;
         default:
             Http::setHeadersByCode(503);
             exit('Invalid type file!');
     }
     unset($oCompress);
 }
Beispiel #18
0
 /**
  * Set error 500 page.
  *
  * @access public
  * @static
  * @return void
  */
 public static function error500()
 {
     // Set 500 HTTP status code
     Http::setHeadersByCode(500);
     // Prevent caching in the browser
     (new Browser())->noCache();
     // Inclusion of the HTML Internal Server Error page
     include PH7_PATH_SYS . 'global/views/' . PH7_DEFAULT_THEME . '/error/500.html.php';
     // Stop script
     exit;
 }
 /**
  * Set a Not Found Error Message with HTTP 404 Code Status.
  *
  * @return void
  */
 private function _notFound()
 {
     Framework\Http\Http::setHeadersByCode(404);
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     $this->view->error = $this->sTitle . '<br />' . t('Please return to the <a href="%0%">main game page</a> or <a href="%1%">the previous page</a>.', Framework\Mvc\Router\Uri::get('game', 'main', 'index'), 'javascript:history.back();');
 }
Beispiel #20
0
 /**
  * Get favicon from a URL.
  *
  * @param string $sUrl
  * @return void The HTML favicon image.
  */
 public function favicon($sUrl)
 {
     $sImg = \PH7\Framework\Navigation\Browser::favicon($sUrl);
     $sName = \PH7\Framework\Http\Http::getHostName($sUrl);
     $this->imgTag($sImg, $sName, array('width' => 16, 'height' => 16));
 }
 /**
  * Get favicon from a URL.
  *
  * @static
  * @param string $sUrl
  * @return string The favicon image.
  */
 public static function favicon($sUrl)
 {
     $sApiUrl = 'http://www.google.com/s2/favicons?domain=';
     $sDomainName = \PH7\Framework\Http\Http::getHostName($sUrl);
     return $sApiUrl . $sDomainName;
 }
Beispiel #22
0
 /**
  * Generate license code using license key.
  *
  * @access private
  * @param string $sLicenseKey The host name or the URL of domain. Default NULL
  * @return string The license key.
  */
 private function _generate($sLicenseKey = null)
 {
     if (empty($sLicenseKey)) {
         $sLicenseKey = $this->_sHostName;
     }
     $sLicenseKey = trim($sLicenseKey);
     $iUrlProtLength = strlen(PH7_URL_PROT);
     if (substr($sLicenseKey, 0, $iUrlProtLength) === PH7_URL_PROT) {
         $sLicenseKey = substr($sLicenseKey, $iUrlProtLength);
     }
     if (substr($sLicenseKey, 0, 4) === 'www.') {
         $sLicenseKey = substr($sLicenseKey, 4);
     }
     $oHttp = new Http();
     if ($oHttp->detectSubdomain($sLicenseKey)) {
         $sLicenseKey = str_replace($oHttp->getSubdomain($sLicenseKey) . PH7_DOT, '', $sLicenseKey);
     }
     unset($oHttp);
     $iLicenseKeyLength = strlen($sLicenseKey);
     if (substr($sLicenseKey, $iLicenseKeyLength - 1, 1) === PH7_SH) {
         $sLicenseKey = substr($sLicenseKey, 0, $iLicenseKeyLength - 1);
     }
     return $this->_bDynamicHostIp ? $sLicenseKey : $this->_sHostIp . $sLicenseKey;
 }
 /**
  * Set a Not Found Error Message with HTTP 404 Code Status.
  *
  * @param boolean $b404Status For the Ajax blocks profile, we can not put HTTP error code 404, so the attribute must be set to "false". Default: TRUE
  * @return void
  */
 private function _notFound($b404Status = true)
 {
     if ($b404Status === true) {
         Framework\Http\Http::setHeadersByCode(404);
     }
     $sErrMsg = $b404Status === true ? '<br />' . t('Please return to <a href="%1%">the previous page</a> or <a href="%1%">add a new video</a> in this album.', 'javascript:history.back();', Uri::get('video', 'main', 'addvideo', $this->httpRequest->get('album_id'))) : '';
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     $this->view->error = $this->sTitle . $sErrMsg;
 }
 public function index()
 {
     switch ($this->httpRequest->get('code', 'int')) {
         case 400:
             Http::setHeadersByCode(400);
             $this->sTitle = t('Bad Request');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The request cannot be fulfilled due to bad syntax.');
             break;
         case 401:
             Http::setHeadersByCode(401);
             $this->sTitle = t('Unauthorized');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('Your IP address or the username/password you entered were not correct. Your request was denied as you have no permission to access the data.');
             break;
         case 402:
             Http::setHeadersByCode(402);
             $this->sTitle = t('Payment Required');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The data is not accessible at the time. The owner of the space has not yet payed their service provider.');
             break;
         case 403:
             Http::setHeadersByCode(403);
             $this->sTitle = t('Forbidden');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('Your IP address or the username/password you entered were not correct. Your request was denied as you have no permission to access the data.<br />OR<br />The server was unable to serve the data that was requested.');
             break;
         case 405:
             Http::setHeadersByCode(405);
             $this->sTitle = t('Method Not Allowed');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('A request was made of a resource using a request method not supported by that resource;[2] for example, using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.');
             break;
         case 500:
             Http::setHeadersByCode(500);
             $this->sTitle = t('Internal Server Error');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The server encountered an error. This is most often caused by a scripting problem, a failed database access attempt, or other similar reasons.<br />Please come back later!');
             break;
         case 501:
             Http::setHeadersByCode(501);
             $this->sTitle = t('Not Implemented');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The method you are using to access the document can not be performed by the server.<br />Possible methods include:') . '<br />' . 'CONNECT<br />
            DELETE<br />
            DELETE<br />
            GET<br />
            HEAD<br />
            OPTIONS<br />
            POST<br />
            PUT<br />
            TRACE';
             break;
         case 502:
             Http::setHeadersByCode(502);
             $this->sTitle = t('Bad Gateway');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The server was acting as a gateway or proxy and received an invalid response from the upstream server.');
             break;
         case 504:
             Http::setHeadersByCode(504);
             $this->sTitle = t('Gateway Timeout');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t("Most likely the client has lost connectivity (disconnected from the internet) or the client's host is having technical difficulties.<br /> This could also meanthat a server that allows access to the requested server is down, having bandwidth/load issues, or otherwise unavailable.");
             break;
         case 505:
             Http::setHeadersByCode(505);
             $this->sTitle = t('HTTP Version Not Supported');
             $this->view->page_title = $this->sTitle;
             $this->view->h1_title = $this->sTitle;
             $this->view->error_desc = t('The server does not support the HTTP protocol version used in the request.');
             break;
         default:
             // 404 Status Code
             $this->displayPageNotFound();
     }
     $this->output();
 }
Beispiel #25
0
 protected function send()
 {
     $sFrom = $_SESSION['messenger_username'];
     $sTo = $this->_oHttpRequest->post('to');
     $sMsg = $this->_oHttpRequest->post('message');
     $_SESSION['messenger_openBoxes'][$this->_oHttpRequest->post('to')] = date('Y-m-d H:i:s', time());
     $sMsgTransform = $this->sanitize($sMsg);
     $sMsgTransform = Emoticon::init($sMsgTransform, false);
     if (!isset($_SESSION['messenger_history'][$this->_oHttpRequest->post('to')])) {
         $_SESSION['messenger_history'][$this->_oHttpRequest->post('to')] = '';
     }
     if (!$this->isOnline($sFrom)) {
         $sMsgTransform = t('You must have the ONLINE status in order to chat with other members.');
     } elseif (!$this->isOnline($sTo)) {
         $sMsgTransform = '<small><em>' . t('%0% is offline. Send a Private Message instead.', $sTo) . '</em></small>';
     } else {
         $this->_oMessengerModel->insert($sFrom, $sTo, $sMsg, (new \PH7\Framework\Date\CDateTime())->get()->dateTime('Y-m-d H:i:s'));
     }
     $_SESSION['messenger_history'][$this->_oHttpRequest->post('to')] .= $this->setJsonContent(['status' => '1', 'user' => $sTo, 'msg' => $sMsgTransform]);
     unset($_SESSION['messenger_boxes'][$this->_oHttpRequest->post('to')]);
     Http::setContentType('application/json');
     echo $this->setJsonContent(['user' => $sFrom, 'msg' => $sMsgTransform], false);
     exit(0);
 }
 /**
  * Show a Not Found page.
  *
  * @return void
  */
 private function _notFound()
 {
     Framework\Http\Http::setHeadersByCode(404);
     /**
      * @internal We can include HTML tags in the title since the template will erase them before display.
      */
     $this->sTitle = t('Whoops! The "%0%" profile is not found.', substr($this->sUsername, 0, PH7_MAX_USERNAME_LENGTH), true);
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     $this->view->error = '<strong><em>' . t('Suggestions:') . '</em></strong><br />
     <a href="' . $this->registry->site_url . '">' . t('Return home') . '</a><br />
     <a href="javascript:history.back();">' . t('Go back to the previous page') . '</a><br />';
 }
 /**
  * Set an Access Denied page.
  *
  * @final
  * @param boolean $b403Status Set the Forbidden status. For the Ajax blocks and others, we cannot put the HTTP 403 error code, so the attribute must be set to FALSE. Default TRUE
  * @return void Quits the page with the exit() function
  */
 public final function displayPageDenied($b403Status = true)
 {
     if ($b403Status) {
         Http::setHeadersByCode(403);
     }
     $sTitle = t('Access Denied!');
     $this->view->page_title = $sTitle;
     $this->view->h1_title = $sTitle;
     $this->view->error_desc = t('Oops! You are not authorized to access this page!');
     $this->view->pOH_not_found = 1;
     $this->output();
     exit;
 }
 /**
  * @access protected
  * @param string $sUrl
  * @return string
  */
 protected function clear($sUrl)
 {
     $oHttp = new Http();
     if ($oHttp->detectSubdomain($sUrl)) {
         // Removes the subdomain with its dot (e.g. mysub.domain.com becomes domain.com).
         $sUrl = str_replace($oHttp->getSubdomain($sUrl) . PH7_DOT, '', $sUrl);
     }
     unset($oHttp);
     return preg_replace('#(^https?://|www\\.|\\.[a-z]{2,4}/?(.+)?$)#i', '', $sUrl);
 }
 /**
  * Set a Not Found Error Message with HTTP 404 Code Status.
  *
  * @param boolean $b404Status For the Ajax blocks profile, we can not put HTTP error code 404, so the attribute must be set to "false". Default: TRUE
  * @return void
  */
 private function _notFound($b404Status = true)
 {
     if ($b404Status === true) {
         Framework\Http\Http::setHeadersByCode(404);
     }
     $sErrMsg = $b404Status === true ? '<br />' . t('Please return to the <a href="%0%">main forum page</a> or <a href="%1%">the previous page</a>.', Uri::get('forum', 'forum', 'index'), 'javascript:history.back();') : '';
     $this->view->page_title = $this->sTitle;
     $this->view->h2_title = $this->sTitle;
     $this->view->error = $this->sTitle . $sErrMsg;
 }
 /**
  * @access private
  * @return void
  */
 private function cronRouter()
 {
     if (strcmp($this->oHttpRequest->get('secret_word'), DbConfig::getSetting('cronSecurityHash')) === 0) {
         if (is_file(PH7_PATH_SYS . 'core/assets/cron/' . $this->oUri->fragment(2) . PH7_DS . $this->oUri->fragment(3) . 'CoreCron.php')) {
             require PH7_PATH_SYS . 'core/assets/cron/' . $this->oUri->fragment(2) . PH7_DS . $this->oUri->fragment(3) . 'CoreCron.php';
         } else {
             $this->notFound('Error while loading the Cron Jobs file<br />File: ' . PH7_PATH_SYS . 'core' . PH7_DS . 'assets' . PH7_DS . 'cron' . PH7_DS . $this->oUri->fragment(2) . PH7_DS . $this->oUri->fragment(3) . 'CoreCron.php does not exist', 1);
         }
     } else {
         \PH7\Framework\Http\Http::setHeadersByCode(403);
         exit('Secret word is invalid for the cron hash!');
     }
 }