/** * Assign variables and generate the license key. */ public function __construct($sLicenseKey = null) { // Variables assignment $this->_oLicenseModel = new LicenseModel(); $this->_sHostName = Server::getName(); $this->_sHostIp = Server::getIp(); $this->_sBasicLicKey = Security::hash($this->_generate(), 80); // Generate license key $this->generate($sLicenseKey); }
/** * Get IP address. * * @static * @return string IP address. */ public static function get() { $sIp = ''; // Default IP address value. $aVars = [Server::HTTP_CLIENT_IP, Server::HTTP_X_FORWARDED_FOR, Server::REMOTE_ADDR]; foreach ($aVars as $sVar) { if (null !== Server::getVar($sVar)) { $sIp = Server::getVar($sVar); break; } } unset($aVars); return preg_match('/^[a-z0-9:.]{7,}$/', $sIp) ? $sIp : '0.0.0.0'; }
/** * Get IP address. * * @static * @return string IP address. If the IP format is invalid, returns '0.0.0.0' */ public static function get() { $sIp = ''; // Default IP address value. $aVars = [Server::HTTP_CLIENT_IP, Server::HTTP_X_FORWARDED_FOR, Server::REMOTE_ADDR]; foreach ($aVars as $sVar) { if (null !== Server::getVar($sVar)) { $sIp = Server::getVar($sVar); break; } } unset($aVars); if (static::isPrivate($sIp)) { $sIp = ($sIp = @file_get_contents('http://addons.hizup.com/ip/')) ? trim($sIp) : '127.0.0.1'; } return preg_match('/^[a-z0-9:.]{7,}$/', $sIp) ? $sIp : '127.0.0.1'; }
/** * Get IP address. * * @static * @return string IP address. If the IP format is invalid, returns '0.0.0.0' */ public static function get() { $sIp = ''; // Default IP address value. $aVars = [Server::HTTP_CLIENT_IP, Server::HTTP_X_FORWARDED_FOR, Server::REMOTE_ADDR]; foreach ($aVars as $sVar) { if (null !== Server::getVar($sVar)) { $sIp = Server::getVar($sVar); break; } } unset($aVars); if (static::isPrivate($sIp)) { $sIp = '127.0.0.1'; } // Avoid invalid local IP for GeoIp return preg_match('/^[a-z0-9:.]{7,}$/', $sIp) ? $sIp : '127.0.0.1'; }
/** * Check Internet connection. * * @final * @return integer Returns '1' if it is not connected to the Internet and stops the script with the exit() function. */ private final function _checkInternetConnection() { if (!Server::checkInternetConnection()) { Page::message(t('Your server must be connected to the Internet to work properly.')); } }
/** * @static * @return string The HTTP server protocol. */ public static function getProtocol() { return Server::getVar(Server::SERVER_PROTOCOL); }
// For All environment Import::file(PH7_PATH_APP . 'configs/environment/all.env'); // Specific to the current environment Import::file(PH7_PATH_APP . 'configs/environment/' . Config::getInstance()->values['application']['environment'] . '.env'); // Loading Class ~/protected/app/includes/classes/* Import::pH7App('includes.classes.Loader.Autoloader'); App\Includes\Classes\Loader\Autoloader::getInstance()->init(); // Loading Debug class Import::pH7FwkClass('Error.Debug'); // Loading String Class Import::pH7FwkClass('Str.Str'); /* Structure/General.class.php functions are not currently used */ // Import::pH7FwkClass('Structure.General'); /*** End Loading Files ***/ //** Temporary code. In the near future, pH7CMS will be usable without mod_rewrite if (!Server::isRewriteMod()) { $sMsg = '<p class="warning"><a href="' . Framework\Core\Kernel::SOFTWARE_WEBSITE . '">pH7CMS</a> requires Apache "mod_rewrite".</p> <p>Please install it so that pH7CMS can works.<br /> Click <a href="http://ph7cms.com/doc/en/how-to-install-rewrite-module" target="_blank">here</a> if you want to get more information on how to install the rewrite module.<br /><br /> After doing this, please <a href="' . PH7_URL_ROOT . '">retry</a>.</p>'; echo html_body("Apache's mod_rewrite is required", $sMsg); exit; } //*/ // Enable client browser cache (new Browser())->cache(); // Starting zlib-compressed output /* This "zlib output compression" compressthe pages. This allows you to save your bandwidth and faster download of your pages. WARNING: this function consumes CPU resources on your server. So you can if you want to remove this function.
/** * Make sure that folder names have a trailing. * * @param string $sDir The directory. * @param bool $bStart for check extension directory start. Default FALSE * @param bool $bEnd for check extension end. Default TRUE * @return string $sDir Directory */ public function checkExtDir($sDir, $bStart = false, $bEnd = true) { $bIsWindows = \PH7\Framework\Server\Server::isWindows(); if (!$bIsWindows && $bStart === true && substr($sDir, 0, 1) !== PH7_DS) { $sDir = PH7_DS . $sDir; } if ($bEnd === true && substr($sDir, -1) !== PH7_DS) { $sDir .= PH7_DS; } return $sDir; }
/** * @return string The current URL. */ public function currentUrl() { return PH7_URL_PROT . \PH7\Framework\Server\Server::getName() . $this->_sRequestUri; }
/** * @return boolean */ public function isAjaxRequest() { return array_key_exists(Server::HTTP_X_REQUESTED_WITH, Server::getVar()); }