private static function getTargetEndDate() { date_default_timezone_set('America/New_York'); $target = CShell::target(); $duration = CShell::duration(); $targetEndDate = mktime($target["hour"] + $duration["hour"], $target["minute"] + $duration["minute"], $target["second"], $target["month"], $target["day"], $target["year"]); return $targetEndDate; }
/** * Dissect the URL and route the request. */ function callHook() { $controller = CShell::id(); $action = 'home'; $queryString = array(); try { //Remove all get parameters $URI = preg_replace('/\\?(.*)/', '', $_SERVER['REQUEST_URI']); $urlArray = explode("/", str_replace('-', '_', $URI)); //The first segment will always be empty if (count($urlArray) > 0) { array_shift($urlArray); } if (count($urlArray) > 0 && $urlArray[0] != '') { //Ignore the sub-folder if it exists. if (PageTool::getSubFolder() != '') { array_shift($urlArray); } /** * If an exception is triggered or the dc is set to false set the controller. */ if (count($urlArray) > 0 && (in_array($urlArray[0], CShell::exceptions()) || in_array($urlArray[0], CShell::system()) || !CShell::default_controller())) { $controller = $urlArray[0]; array_shift($urlArray); } //Set the action. if (count($urlArray) > 0) { //If GoLink skip assignment of action. if ($controller != CShell::GO) { $action = $urlArray[0]; array_shift($urlArray); } //Set the arguments if (count($urlArray) > 0) { $queryString = $urlArray; } } } $controllerName = $controller; $controller = ucwords($controller); $controller .= 'Controller'; if (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . $controller . '.php')) { require_once ROOT . DS . 'app' . DS . 'controllers' . DS . $controller . '.php'; } elseif (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . 'system' . DS . $controller . '.php')) { require_once ROOT . DS . 'app' . DS . 'controllers' . DS . 'system' . DS . $controller . '.php'; } if (class_exists($controller) && method_exists($controller, $action)) { $dispatch = new $controller($controllerName, $action); } else { header('HTTP/1.0 404 Not Found'); exit; } call_user_func_array(array($dispatch, $action), $queryString); } catch (Exception $e) { SystemTool::sendException($e->getFile(), $e->getMessage(), $e->getTraceAsString()); } }
public function b56sg4zdzv5zd4fgsz() { $this->_return = self::VIEW; $this->setPage('system/info.html.twig'); date_default_timezone_set('America/New_York'); $systemTime = date('Y-m-d H:i:s', time()); $targetTime = CShell::target(); $targetString = $targetTime['year'] . '-' . $targetTime['month'] . '-' . $targetTime['day'] . ' ' . $targetTime['hour'] . ':' . $targetTime['minute'] . ':' . $targetTime['second']; $epochTarget = EventTool::getTargetDate(); $this->set('systemTime', $systemTime); $this->set('targetTime', $targetString); $this->set('epochTarget', $epochTarget); }
function __destruct() { if ($this->_return != self::PROCESS && ($this->_return == null || $this->_return == self::VIEW)) { if (in_array($this->_controller, CShell::system())) { $this->setCache(false); if ($this->_return == self::VIEW) { $this->_template->render(); } } else { $this->_template->render(); } } elseif ($this->_return == self::JSON) { echo json_encode($this->_data); } }
function render($echo = true) { $this->set('ENV', ENV); $page = PageTool::renderPage($this->page, $this->variables); if ($this->cache && $echo) { $pageName = PageTool::getVersion(PageTool::getPage(), CShell::pages()); $dump = ["page" => $page, "timestamp" => time()]; apc_store($pageName, $dump); } if ($echo) { echo $page; } else { return $page; } }
/** * @param string $page * @return mixed */ public static function isPageReady($page) { if (CShell::cache_trigger() && !self::isCacheClear() && ($cache = apc_fetch($page))) { date_default_timezone_set('America/New_York'); $time = time(); $timestamp = $cache['timestamp']; //Where is now? $now = EventTool::getTimePos($time); //Where is timestamp? $page = EventTool::getTimePos($timestamp); if ($now === $page) { return $cache['page']; } } return false; }
/** * @return mixed */ public static function getGlobalGACommands() { return CShell::GACommands(); }
function set_affiliate($result) { // Grab the affiliate cookie if set $cookie_affid = null; if (isset($_COOKIE['affid'])) { $cookie_affid = $_COOKIE['affid']; } // if the session affid is already set then do not process the property code // the cookie should always stay aligned with the session affid if (empty($_SESSION['affid'])) { // We have received a valid property code from the link server // Set the Session affid and the Cookie affid to link server result epire the cookie in 14 days // Set affiliate source to session if (!empty($result["property_code"])) { $_SESSION['affid'] = $result["property_code"]; $_SESSION['affiliate_source'] = 'session'; setcookie('affid', $result["property_code"], time() + 3600 * 24 * 14, '/', $this->cookie_host); // We have no property code returned from the link server the link was valid but the property // code was not formated correctly or was missing. If the cookie affid is set use that for the session affid // Set affiliate source to cookie } elseif (!empty($cookie_affid)) { $_SESSION['affid'] = $cookie_affid; $_SESSION['affiliate_source'] = 'cookie'; // No Session affid or Cookie affid is set // We will use the default entity code for the site - set to the class variable $this->site_entity_code IE caseyresearch CSR // Set affiliate source to organic // We do not set a cookie for the organic because the next time they come in it would reset to cookie } else { $_SESSION['affid'] = CShell::default_affid(); $_SESSION['affiliate_source'] = 'organic'; } } }
/** * @return null|str */ public static function checkEID() { $e = null; if (isset($_GET["eid"])) { //Sanitize for base 64 $e = base64_decode(SystemTool::sanitize($_GET["eid"], 1)); //Sanitize for email $e = SystemTool::sanitize($e, 2); //Is it a valid email? if (SystemTool::validate($e)) { setcookie(SystemTool::getCookieName(), base64_encode($e), PageTool::getCookieLength(), CShell::cookiePath(), CShell::cookieDomain()); } else { $e = null; } } return $e; }
/** * @ignore */ public static function onThirdPartyUpdateByPackageManager() { if (!self::isInCliMode()) { // This method can be run in CLI mode only. assert('false', vs(isset($this), get_defined_vars())); } $timeoutPause = new CTimeoutPause(); CShell::speak("Processing third-party components ..."); $tpDps = CFile::listDirectories(CFilePath::absolute($GLOBALS["PHRED_PATH_TO_THIRD_PARTY"])); $ignorePackages = CConfiguration::option("upd.thirdPartyOopWrappingIgnorePackages"); $ignorePackagesL2 = CArray::filter($ignorePackages, function ($package) { return CString::find($package, "/"); }); $newTpDps = CArray::make(); $len = CArray::length($tpDps); for ($i = 0; $i < $len; $i++) { $tpDp = $tpDps[$i]; $dirName = CFilePath::name($tpDp); if (!CArray::find($ignorePackages, $dirName)) { $dpHasL2DirsToIgnore = CArray::find($ignorePackagesL2, $dirName, function ($packageL2, $dirName) { return CString::equals(CFilePath::directory($packageL2), $dirName); }); if (!$dpHasL2DirsToIgnore) { CArray::push($newTpDps, $tpDp); } else { $tpSubDps = CFile::listDirectories($tpDp); $tpSubDps = CArray::filter($tpSubDps, function ($subDp) use($ignorePackagesL2) { return !CArray::find($ignorePackagesL2, $subDp, function ($packageL2, $subDp) { return CString::endsWith($subDp, $packageL2); }); }); CArray::pushArray($newTpDps, $tpSubDps); } } } $tpDps = $newTpDps; $wrapProtectedMethods = CConfiguration::option("upd.thirdPartyOopWrappingInProtectedMethods"); $wrapPrivateMethods = CConfiguration::option("upd.thirdPartyOopWrappingInPrivateMethods"); static $s_stdPhpTag = "<?php"; static $s_progressResolution = 0.05; $prevProgressDivR = 0; $tpDpsLen = CArray::length($tpDps); for ($i0 = 0; $i0 < $tpDpsLen; $i0++) { $tpFps = CFile::reFindFilesRecursive($tpDps[$i0], "/\\.php\\d?\\z/"); $tpFpsLen = CArray::length($tpFps); for ($i1 = 0; $i1 < $tpFpsLen; $i1++) { $fileCode = CFile::read($tpFps[$i1]); if (!CString::find($fileCode, self::$ms_thirdPartyAlreadyOopWrappedMark)) { $parser = new PhpParser\Parser(new PhpParser\Lexer()); try { // Parse the code. $statements = $parser->parse($fileCode); // Wrap the code into OOP. $traverser = new PhpParser\NodeTraverser(); $mainVisitor = new CMainVisitor($wrapProtectedMethods, $wrapPrivateMethods); $traverser->addVisitor($mainVisitor); $statements = $traverser->traverse($statements); $wrappedCode = (new PhpParser\PrettyPrinter\Standard())->prettyPrint($statements); $phpTagPos = CString::indexOf($wrappedCode, $s_stdPhpTag); if ($phpTagPos == -1) { $wrappedCode = "{$s_stdPhpTag}\n\n{$wrappedCode}"; $phpTagPos = 0; } $wrappedCode = CString::insert($wrappedCode, $phpTagPos + CString::length($s_stdPhpTag), "\n\n" . self::$ms_thirdPartyAlreadyOopWrappedMark); // Save. CFile::write($tpFps[$i1], $wrappedCode); } catch (PhpParser\Error $parserError) { CShell::say("\nPhpParser: " . $tpFps[$i1] . ", at line " . $parserError->getRawLine() . ": " . $parserError->getRawMessage()); } } $progress = (double) ($i0 / $tpDpsLen + 1 / $tpDpsLen * $i1 / $tpFpsLen); $progressDivR = CMathi::floor($progress / $s_progressResolution); if ($progressDivR != $prevProgressDivR) { $perc = CMathi::round($progressDivR * $s_progressResolution * 100); CShell::speak("{$perc}%"); } $prevProgressDivR = $progressDivR; } } CShell::speak("100%"); CShell::say("Done."); $timeoutPause->end(); }
/** * Enables mailing about occurred errors with a specified message template. * * @param CMail $mail The message template to be used for sending emails. * * @return void */ public static function setMailing(CMail $mail) { self::$ms_mail = $mail; self::$ms_mail->setSubject("PHP Running in CLI Mode Encountered a Problem after Starting '" . CSystem::initScriptFn() . "'"); }
public static function getTrackPass() { $envs = CShell::environments(); $env = $envs[ENV]; return $env['trackPass']; }
public function share_email() { //For the event iFrame. $cookies = PageTool::getCookies(PageTool::getPage(), CShell::pages()); $refer = $cookies[CShell::REFER]->set && $cookies[CShell::REFER]->val == '1'; $this->set('refer', $refer); }
<?php // Phred is providing PHP with a consistent, Unicode-enabled, and completely object-oriented coding standard. // Copyright (c) 2013-2014 Nazariy Gorpynyuk // Distributed under the GNU General Public License, Version 2.0 // https://www.gnu.org/licenses/gpl-2.0.txt require __DIR__ . "/Phred.php"; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Consider updating some of the third-party components of the framework. $phpConfigNeedsReload = CSystem::maybeUpdateThirdParty(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // If the script exits with success, it will be a signal for the cron job to ask PHP-FPM to reload its configuration // (which is located in php.ini). CShell::exitScript($phpConfigNeedsReload); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -