/** * @param \Zend_Controller_Request_Abstract $request */ public function routeStartup(\Zend_Controller_Request_Abstract $request) { $maintenance = false; $file = \Pimcore\Tool\Admin::getMaintenanceModeFile(); if (is_file($file)) { $conf = (include $file); if (isset($conf["sessionId"])) { if ($conf["sessionId"] != $_COOKIE["pimcore_admin_sid"]) { $maintenance = true; } } else { @unlink($file); } } // do not activate the maintenance for the server itself // this is to avoid problems with monitoring agents $serverIps = ["127.0.0.1"]; if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) { header("HTTP/1.1 503 Service Temporarily Unavailable", 503); $file = PIMCORE_PATH . "/static/html/maintenance.html"; $customFile = PIMCORE_CUSTOM_CONFIGURATION_DIRECTORY . "/maintenance.html"; if (file_exists($customFile)) { $file = $customFile; } echo file_get_contents($file); exit; } }
/** * @param \Zend_Controller_Request_Abstract $request */ public function routeStartup(\Zend_Controller_Request_Abstract $request) { $maintenance = false; $file = \Pimcore\Tool\Admin::getMaintenanceModeFile(); if (is_file($file)) { $conf = new \Zend_Config_Xml($file); if ($conf->sessionId) { if ($conf->sessionId != $_COOKIE["pimcore_admin_sid"]) { $maintenance = true; } } else { @unlink($file); } } // do not activate the maintenance for the server itself // this is to avoid problems with monitoring agents $serverIps = array("127.0.0.1"); if ($maintenance && !in_array(\Pimcore\Tool::getClientIp(), $serverIps)) { header("HTTP/1.1 503 Service Temporarily Unavailable", 503); echo file_get_contents(PIMCORE_PATH . "/static/html/maintenance.html"); exit; } }
/** * Get current Users Country * * @return Country|null * @throws \Exception */ public static function getCountry() { $session = self::getSession(); $country = null; if ($session->countryId) { $country = Country::getById($session->countryId); if ($country instanceof Country) { return $country; } } if (self::getSession()->user instanceof User) { $user = self::getSession()->user; if (count($user->getAddresses()) > 0) { $country = $user->getAddresses()->get(0); } } if (!$country instanceof Country) { if (file_exists(CORESHOP_CONFIGURATION_PATH . "/GeoIP/GeoIP.dat")) { $gi = geoip_open(CORESHOP_CONFIGURATION_PATH . "/GeoIP/GeoIP.dat", GEOIP_MEMORY_CACHE); $country = geoip_country_code_by_addr($gi, \Pimcore\Tool::getClientIp()); geoip_close($gi); $country = Country::getByIsoCode($country); } else { $enabled = Country::getActiveCountries(); if (count($enabled) > 0) { return $enabled[0]; } else { throw new \Exception("no enabled countries found"); } } } if (!$country instanceof Country) { //Using Default Country: AT //TODO: Default Country configurable thru settings $country = Country::getById(7); //throw new \Exception("Country with code $country not found"); } $session->countryId = $country->getId(); return $country; }
/** * @param $object * @param $title */ public function addNoteOnObject($object, $title) { $note = new Model\Element\Note(); $note->setElement($object); $note->setDate(time()); $note->setType("newsletter"); $note->setTitle($title); $note->setUser(0); $note->setData(["ip" => ["type" => "text", "data" => Tool::getClientIp()]]); $note->save(); }
public function getSystemAction() { $this->checkPermission("system_settings"); $values = Config::getSystemConfig(); if (($handle = fopen(PIMCORE_PATH . "/config/timezones.csv", "r")) !== FALSE) { while (($rowData = fgetcsv($handle, 10000, ",", '"')) !== false) { $timezones[] = $rowData[0]; } fclose($handle); } $locales = Tool::getSupportedLocales(); $languageOptions = array(); foreach ($locales as $short => $translation) { if (!empty($short)) { $languageOptions[] = array("language" => $short, "display" => $translation . " ({$short})"); $validLanguages[] = $short; } } $valueArray = $values->toArray(); $valueArray['general']['validLanguage'] = explode(",", $valueArray['general']['validLanguages']); //for "wrong" legacy values if (is_array($valueArray['general']['validLanguage'])) { foreach ($valueArray['general']['validLanguage'] as $existingValue) { if (!in_array($existingValue, $validLanguages)) { $languageOptions[] = array("language" => $existingValue, "display" => $existingValue); } } } //cache exclude patterns - add as array if (!empty($valueArray['cache']['excludePatterns'])) { $patterns = explode(",", $valueArray['cache']['excludePatterns']); if (is_array($patterns)) { foreach ($patterns as $pattern) { $valueArray['cache']['excludePatternsArray'][] = array("value" => $pattern); } } } //remove password from values sent to frontend $valueArray['database']["params"]['password'] = "******"; //admin users as array $adminUsers = array(); $userList = new Model\User\Listing(); $userList->setCondition("admin = 1 and email is not null and email != ''"); $users = $userList->load(); if (is_array($users)) { foreach ($users as $user) { $adminUsers[] = array("id" => $user->getId(), "username" => $user->getName()); } } $adminUsers[] = array("id" => "", "username" => "-"); $response = array("values" => $valueArray, "adminUsers" => $adminUsers, "config" => array("timezones" => $timezones, "languages" => $languageOptions, "client_ip" => Tool::getClientIp(), "google_private_key_exists" => file_exists(\Pimcore\Google\Api::getPrivateKeyPath()), "google_private_key_path" => \Pimcore\Google\Api::getPrivateKeyPath())); $this->_helper->json($response); }
/** * @static * @return bool */ public static function inDebugMode() { if (defined("PIMCORE_DEBUG")) { return PIMCORE_DEBUG; } $conf = Config::getSystemConfig(); $debug = (bool) $conf->general->debug; // enable debug mode only for one IP if ($conf->general->debug_ip && $conf->general->debug) { $debug = false; $debugIpAddresses = explode_and_trim(',', $conf->general->debug_ip); if (in_array(Tool::getClientIp(), $debugIpAddresses)) { $debug = true; } } return $debug; }