Exemple #1
0
 public static function compile($path, $source = null)
 {
     $conf = Pimcore_Config::getSystemConfig();
     $compiledContent = "";
     // check if the file is already compiled in the cache
     $cacheKey = "less_file_" . md5_file($path);
     if ($contents = Pimcore_Model_Cache::load($cacheKey)) {
         return $contents;
     }
     // use the original less compiler if configured
     if ($conf->outputfilters->lesscpath) {
         $output = array();
         exec($conf->outputfilters->lesscpath . " " . $path, $output);
         $compiledContent = implode($output);
         // add a comment to the css so that we know it's compiled by lessc
         if (!empty($compiledContent)) {
             $compiledContent = "\n\n/**** compiled with lessc (node.js) ****/\n\n" . $compiledContent;
         }
     }
     // use php implementation of lessc if it doesn't work
     if (empty($compiledContent)) {
         $less = new lessc();
         $less->importDir = dirname($path);
         $compiledContent = $less->parse(file_get_contents($path));
         // add a comment to the css so that we know it's compiled by lessphp
         $compiledContent = "\n\n/**** compiled with lessphp ****/\n\n" . $compiledContent;
     }
     if ($source) {
         // correct references inside the css
         $compiledContent = self::correctReferences($source, $compiledContent);
     }
     // put the compiled contents into the cache
     Pimcore_Model_Cache::save($compiledContent, $cacheKey, array("less"));
     return $compiledContent;
 }
 /**
  * @see Document_Tag_Interface::frontend
  * @return string
  */
 public function frontend()
 {
     if (!$this->options["controller"] && !$this->options["action"]) {
         $this->options["controller"] = Pimcore_Config::getSystemConfig()->documents->default_controller;
         $this->options["action"] = Pimcore_Config::getSystemConfig()->documents->default_action;
     }
     $document = null;
     if ($this->o instanceof Document) {
         $document = $this->o;
     }
     if (method_exists($this->o, "isPublished")) {
         if (!$this->o->isPublished()) {
             return "";
         }
     }
     if ($this->o instanceof Element_Interface) {
         $blockparams = array("action", "controller", "module", "template");
         $params = array("template" => $this->options["template"], "object" => $this->o, "element" => $this->o, "document" => $document, "id" => $this->id, "type" => $this->type, "subtype" => $this->subtype, "disableBlockClearing" => true);
         foreach ($this->options as $key => $value) {
             if (!array_key_exists($key, $params) && !in_array($key, $blockparams)) {
                 $params[$key] = $value;
             }
         }
         if ($this->getView() != null) {
             return $this->getView()->action($this->options["action"], $this->options["controller"], $this->options["module"], $params);
         }
     }
 }
Exemple #3
0
 public function indexAction()
 {
     // check maintenance
     $maintenance_enabled = false;
     $manager = Schedule_Manager_Factory::getManager("maintenance.pid");
     $lastExecution = $manager->getLastExecution();
     if ($lastExecution) {
         if (time() - $lastExecution < 610) {
             // maintenance script should run at least every 10 minutes + a little tolerance
             $maintenance_enabled = true;
         }
     }
     $this->view->maintenance_enabled = Zend_Json::encode($maintenance_enabled);
     // configuration
     $this->view->config = Pimcore_Config::getSystemConfig();
     //mail settings
     $mailIncomplete = false;
     if ($this->view->config->email) {
         $emailSettings = $this->view->config->email->toArray();
         if ($emailSettings['method'] == "sendmail" and !empty($emailSettings['sender']['email'])) {
             $mailIncomplete = true;
         }
         if ($emailSettings['method'] == "smtp" and !empty($emailSettings['sender']['email']) and !empty($emailSettings['smtp']['host'])) {
             $mailIncomplete = true;
         }
     }
     $this->view->mail_settings_incomplete = Zend_Json::encode($mailIncomplete);
     // report configuration
     $this->view->report_config = Pimcore_Config::getReportConfig();
     // customviews config
     $cvConfig = Pimcore_Tool::getCustomViewConfig();
     $cvData = array();
     if ($cvConfig) {
         foreach ($cvConfig as $node) {
             $tmpData = $node;
             $rootNode = Object_Abstract::getByPath($tmpData["rootfolder"]);
             if ($rootNode) {
                 $tmpData["rootId"] = $rootNode->getId();
                 $tmpData["allowedClasses"] = explode(",", $tmpData["classes"]);
                 $tmpData["showroot"] = (bool) $tmpData["showroot"];
                 $cvData[] = $tmpData;
             }
         }
     }
     $this->view->customview_config = $cvData;
     // upload limit
     $max_upload = filesize2bytes(ini_get("upload_max_filesize") . "B");
     $max_post = filesize2bytes(ini_get("post_max_size") . "B");
     $memory_limit = filesize2bytes(ini_get("memory_limit") . "B");
     $upload_mb = min($max_upload, $max_post, $memory_limit);
     $this->view->upload_max_filesize = $upload_mb;
     // live connect
     $liveconnectToken = Pimcore_Liveconnect::getToken();
     $this->view->liveconnectToken = $liveconnectToken;
     // adding css minify filter because of IE issues with CkEditor and more than 31 stylesheets
     if (!PIMCORE_DEVMODE) {
         $front = Zend_Controller_Front::getInstance();
         $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800);
     }
 }
Exemple #4
0
 /**
  * @static
  * @return Zend_Db_Adapter_Abstract
  */
 public static function getConnection()
 {
     $charset = "UTF8";
     // explicit set charset for connection (to the adapter)
     $config = Pimcore_Config::getSystemConfig()->toArray();
     $config["database"]["params"]["charset"] = $charset;
     $db = Zend_Db::factory($config["database"]["adapter"], $config["database"]["params"]);
     $db->query("SET NAMES " . $charset);
     // try to set innodb as default storage-engine
     try {
         $db->query("SET storage_engine=InnoDB;");
     } catch (Exception $e) {
         Logger::warn($e);
     }
     // enable the db-profiler if the devmode is on and there is no custom profiler set (eg. in system.xml)
     if (PIMCORE_DEVMODE && !$db->getProfiler()->getEnabled()) {
         $profiler = new Pimcore_Db_Profiler('All DB Queries');
         $profiler->setEnabled(true);
         $db->setProfiler($profiler);
     }
     // put the connection into a wrapper to handle connection timeouts, ...
     $db = new Pimcore_Resource_Wrapper($db);
     Logger::debug("Successfully established connection to MySQL-Server");
     return $db;
 }
Exemple #5
0
 public function init()
 {
     parent::init();
     // set language
     try {
         $locale = Zend_Registry::get("Zend_Locale");
         $this->setLanguage($locale->getLanguage());
     } catch (Exception $e) {
         if ($this->_getParam("language")) {
             $this->setLanguage($this->_getParam("language"));
         } else {
             $config = Pimcore_Config::getSystemConfig();
             $this->setLanguage($config->general->language);
         }
     }
     try {
         Zend_Registry::get("pimcore_admin_initialized");
         $this->setUser(Zend_Registry::get("pimcore_admin_user"));
     } catch (Exception $e) {
         // general definitions
         Document::setHideUnpublished(false);
         Object_Abstract::setHideUnpublished(false);
         Object_Abstract::setGetInheritedValues(false);
         Pimcore::setAdminMode();
         // init translations
         self::initTranslations($this);
         // init zend action helpers
         Zend_Controller_Action_HelperBroker::addPrefix('Pimcore_Controller_Action_Helper');
         // authenticate user, first try to authenticate with session information
         $user = Pimcore_Tool_Authentication::authenticateSession();
         if ($user instanceof User) {
             $this->setUser($user);
             if ($this->getUser()->getLanguage()) {
                 $this->setLanguage($this->getUser()->getLanguage());
             }
         } else {
             // try to authenticate with digest, but this is only allowed for WebDAV
             if ($this->_getParam("module") == "admin" && $this->_getParam("controller") == "asset" && $this->_getParam("action") == "webdav") {
                 $user = Pimcore_Tool_Authentication::authenticateDigest();
                 if ($user instanceof User) {
                     $this->setUser($user);
                     return;
                 }
             }
         }
         // send a auth header for the client (is covered by the ajax object in javascript)
         if (!$this->getUser() instanceof User) {
             $this->getResponse()->setHeader("X-Pimcore-Auth", "required");
         }
         // redirect to the login-page if the user isn't authenticated
         if (!$this->getUser() instanceof User && !($this->_getParam("module") == "admin" && $this->_getParam("controller") == "login")) {
             $this->_redirect("/admin/login");
             $this->getResponse()->sendResponse();
             exit;
         }
         Zend_Registry::set("pimcore_admin_user", $this->getUser());
         Zend_Registry::set("pimcore_admin_initialized", true);
     }
 }
Exemple #6
0
 public static function getSiteConfig($site = null)
 {
     $siteKey = self::getSiteKey($site);
     if (Pimcore_Config::getReportConfig()->webmastertools->sites->{$siteKey}->profile) {
         return Pimcore_Config::getReportConfig()->webmastertools->sites->{$siteKey};
     }
     return false;
 }
 public static function getSiteConfig($site = null)
 {
     $siteKey = Pimcore_Tool_Frontend::getSiteKey($site);
     if (Pimcore_Config::getReportConfig()->analytics->sites->{$siteKey}) {
         return Pimcore_Config::getReportConfig()->analytics->sites->{$siteKey};
     }
     return false;
 }
 public static function getSiteConfig($site = null)
 {
     $siteKey = Pimcore_Tool_Frontend::getSiteKey($site);
     if (Pimcore_Config::getReportConfig()->webmastertools->sites->{$siteKey}->verification) {
         return Pimcore_Config::getReportConfig()->webmastertools->sites->{$siteKey};
     }
     return false;
 }
Exemple #9
0
 public static function getYoutubeCredentials()
 {
     $googleCredentials = Pimcore_Config::getSystemConfig()->services->google;
     $youtubeConf = Pimcore_Config::getSystemConfig()->services->youtube;
     if (!self::validateYoutubeConf($googleCredentials, $youtubeConf)) {
         return;
     }
     return array("username" => $googleCredentials->username, "password" => $googleCredentials->password, "apiKey" => $youtubeConf->apikey);
 }
Exemple #10
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $this->conf = Pimcore_Config::getSystemConfig();
     if (!$this->conf->outputfilters) {
         return $this->disable();
     }
     if (!$this->conf->outputfilters->less) {
         return $this->disable();
     }
 }
Exemple #11
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $conf = Pimcore_Config::getSystemConfig();
     if (!$conf->outputfilters) {
         return $this->disable();
     }
     if (!$conf->outputfilters->cdn || !$conf->outputfilters->cdnhostnames || !$conf->outputfilters->cdnpatterns) {
         return $this->disable();
     }
     $this->conf = $conf;
 }
Exemple #12
0
 protected function getWebmastertoolsCredentials()
 {
     $conf = $this->getConfig()->webmastertools;
     if ($conf->username && $conf->password) {
         return array("username" => $conf->username, "password" => $conf->password);
     }
     $conf = Pimcore_Config::getSystemConfig()->services->google;
     if ($conf->username && $conf->password) {
         return array("username" => $conf->username, "password" => $conf->password);
     }
     return false;
 }
 /**
  *
  */
 public function mail()
 {
     $conf = Pimcore_Config::getSystemConfig();
     if (!empty($conf->general->logrecipient)) {
         Logger::debug(get_class($this) . ": detected log recipient:" . $conf->general->logrecipient);
         $user = User::getById($conf->general->logrecipient);
         Logger::debug(get_class($this) . ": detected log recipient:" . $user->getEmail());
         if ($user instanceof User && $user->isAdmin()) {
             $email = $user->getEmail();
             Logger::debug(get_class($this) . ": user is valid");
             if (!empty($email)) {
                 if (is_dir(PIMCORE_LOG_MAIL_TEMP)) {
                     Logger::debug(get_class($this) . ": detected mail log dir");
                     Logger::debug(get_class($this) . ": opening dir " . PIMCORE_LOG_MAIL_TEMP);
                     if ($handle = opendir(PIMCORE_LOG_MAIL_TEMP)) {
                         Logger::debug(get_class($this) . ": reading dir " . PIMCORE_LOG_MAIL_TEMP);
                         while (false !== ($file = readdir($handle))) {
                             Logger::debug(get_class($this) . ": detected file " . $file);
                             if (is_file(PIMCORE_LOG_MAIL_TEMP . "/" . $file) and is_writable(PIMCORE_LOG_MAIL_TEMP . "/" . $file)) {
                                 $now = time();
                                 $threshold = 1 * 60 * 15;
                                 $fileModified = filemtime(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
                                 Logger::debug(get_class($this) . ": file is writeable and was last modified: " . $fileModified);
                                 if ($fileModified !== FALSE and $fileModified < $now - $threshold) {
                                     $mail = Pimcore_Tool::getMail(array($email), "pimcore log notification - " . $file);
                                     $mail->setIgnoreDebugMode(true);
                                     $mail->setBodyText(file_get_contents(PIMCORE_LOG_MAIL_TEMP . "/" . $file));
                                     $mail->send();
                                     @unlink(PIMCORE_LOG_MAIL_TEMP . "/" . $file);
                                     Logger::debug(get_class($this) . ": sent mail and deleted temp log file " . $file);
                                 } else {
                                     if ($fileModified > $now - $threshold) {
                                         Logger::debug(get_class($this) . ": leaving temp log file alone because file [ {$file} ] was written to within the last 15 minutes");
                                     }
                                 }
                             }
                         }
                     }
                 }
             } else {
                 Logger::err(get_class($this) . ": Cannot send mail to configured log user [" . $user->getName() . "] because email is empty");
             }
         } else {
             Logger::err(get_class($this) . ": Cannot send mail to configured log user. User is either null or not an admin");
         }
     } else {
         Logger::debug(get_class($this) . ": No log recipient configured");
     }
 }
Exemple #14
0
 /**
  *
  */
 public function update()
 {
     parent::update();
     $config = Pimcore_Config::getSystemConfig();
     if ($this->_oldPath && $config->documents->createredirectwhenmoved) {
         // create redirect for old path
         $redirect = new Redirect();
         $redirect->setTarget($this->getId());
         $redirect->setSource("@" . $this->_oldPath . "/?@");
         $redirect->setStatusCode(301);
         $redirect->setExpiry(time() + 86400 * 60);
         // this entry is removed automatically after 60 days
         $redirect->save();
     }
 }
Exemple #15
0
 public static function getSiteConfig($site = null)
 {
     // check for site
     if (!$site) {
         try {
             $site = Zend_Registry::get("pimcore_site");
         } catch (Exception $e) {
             $site = null;
         }
     }
     $siteKey = self::getSiteKey($site);
     if (Pimcore_Config::getReportConfig()->analytics->sites->{$siteKey}->profile) {
         return Pimcore_Config::getReportConfig()->analytics->sites->{$siteKey};
     }
     return false;
 }
Exemple #16
0
 /**
  * @static
  * @return string
  */
 public static function getPhpCli()
 {
     if (Pimcore_Config::getSystemConfig()->general->php_cli) {
         if (is_executable(Pimcore_Config::getSystemConfig()->general->php_cli)) {
             return (string) Pimcore_Config::getSystemConfig()->general->php_cli;
         } else {
             Logger::critical("PHP-CLI binary: " . Pimcore_Config::getSystemConfig()->general->php_cli . " is not executable");
         }
     }
     $paths = array("/usr/bin/php", "/usr/local/bin/php", "/usr/local/zend/bin/php", "/bin/php");
     foreach ($paths as $path) {
         if (is_executable($path)) {
             return $path;
         }
     }
     throw new Exception("No php executable found, please configure the correct path in the system settings");
 }
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $conf = Pimcore_Config::getReportConfig();
     if ($conf->webmastertools->sites) {
         $sites = $conf->webmastertools->sites->toArray();
         if (is_array($sites)) {
             foreach ($sites as $site) {
                 if ($site["verification"]) {
                     if ($request->getRequestUri() == "/" . $site["verification"]) {
                         echo "google-site-verification: " . $site["verification"];
                         exit;
                     }
                 }
             }
         }
     }
 }
Exemple #18
0
 /**
  * @static
  * @return string
  */
 public static function getFfmpegCli()
 {
     if (Pimcore_Config::getSystemConfig()->assets->ffmpeg) {
         if (is_executable(Pimcore_Config::getSystemConfig()->assets->ffmpeg)) {
             return Pimcore_Config::getSystemConfig()->assets->ffmpeg;
         } else {
             Logger::critical("FFMPEG binary: " . Pimcore_Config::getSystemConfig()->assets->ffmpeg . " is not executable");
         }
     }
     $paths = array("/usr/bin/ffmpeg", "/usr/local/bin/ffmpeg", "/bin/ffmpeg");
     foreach ($paths as $path) {
         if (is_executable($path)) {
             return $path;
         }
     }
     throw new Exception("No ffmpeg executable found, please configure the correct path in the system settings");
 }
 protected function _handleError(Zend_Controller_Request_Abstract $request)
 {
     // remove zend error handler
     $front = Zend_Controller_Front::getInstance();
     $front->unregisterPlugin("Zend_Controller_Plugin_ErrorHandler");
     $response = $this->getResponse();
     if ($response->isException() && !$this->_isInsideErrorHandlerLoop) {
         // get errorpage
         try {
             // enable error handler
             $front->setParam('noErrorHandler', false);
             $siteKey = Pimcore_Tool_Frontend::getSiteKey();
             $errorPath = Pimcore_Config::getSystemConfig()->documents->error_pages->{$siteKey};
             if (empty($errorPath)) {
                 $errorPath = "/";
             }
             $document = Document::getByPath($errorPath);
             if (!$document instanceof Document_Page) {
                 // default is home
                 $document = Document::getById(1);
             }
             if ($document instanceof Document_Page) {
                 $params = Pimcore_Tool::getRoutingDefaults();
                 if ($module = $document->getModule()) {
                     $params["module"] = $module;
                 }
                 if ($controller = $document->getController()) {
                     $params["controller"] = $controller;
                     $params["action"] = "index";
                 }
                 if ($action = $document->getAction()) {
                     $params["action"] = $action;
                 }
                 $this->setErrorHandler($params);
                 $request->setParam("document", $document);
                 Zend_Registry::set("pimcore_error_document", $document);
             }
         } catch (Exception $e) {
             Logger::emergency("error page not found");
         }
     }
     // call default ZF error handler
     parent::_handleError($request);
 }
Exemple #20
0
 public function getAction()
 {
     $user = User::getById(intval($this->_getParam("id")));
     $userObjects = Object_Service::getObjectsReferencingUser($user->getId());
     $userObjectData = array();
     $currentUser = Zend_Registry::get("pimcore_user");
     foreach ($userObjects as $o) {
         $hasHidden = false;
         $o->getUserPermissions($currentUser);
         if ($o->isAllowed("list")) {
             $userObjectData[] = array("path" => $o->getFullPath(), "id" => $o->getId(), "subtype" => $o->getClass()->getName());
         } else {
             $hasHidden = true;
         }
     }
     $user->setPassword(null);
     $conf = Pimcore_Config::getSystemConfig();
     $this->_helper->json(array("wsenabled" => $conf->webservice->enabled, "user" => $user->getIterator(), "objectDependencies" => array("hasHidden" => $hasHidden, "dependencies" => $userObjectData)));
 }
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $conf = Pimcore_Config::getSystemConfig();
     if (!$conf->outputfilters) {
         return $this->disable();
     }
     if (!$conf->outputfilters->imagedatauri) {
         return $this->disable();
     }
     //detect browser
     $browser = new Pimcore_Browser();
     $browserVersion = (int) $browser->getVersion();
     if ($browser->getBrowser() == "Firefox" && $browserVersion >= 3) {
         $this->supported = true;
     } else {
         if ($browser->getBrowser() == "Internet Explorer" && $browserVersion >= 8) {
             $this->supported = true;
         } else {
             if ($browser->getBrowser() == "Chrome" && $browserVersion >= 5) {
                 $this->supported = true;
             } else {
                 if ($browser->getBrowser() == "Safari" && $browserVersion >= 4) {
                     $this->supported = true;
                 } else {
                     return $this->disable();
                 }
             }
         }
     }
     // set cache key suffix for outputcache
     if ($this->supported) {
         $this->enabled = true;
         if (!($tags = $request->getParam("pimcore_cache_tag_suffix"))) {
             $tags = array();
         }
         $tags[] = "datauri";
         $request->setParam("pimcore_cache_tag_suffix", $tags);
     }
 }
 public function addAction()
 {
     $success = false;
     // check for permission
     $parentDocument = Document::getById(intval($this->_getParam("parentId")));
     if ($parentDocument->isAllowed("create")) {
         $intendedPath = $parentDocument->getFullPath() . "/" . $this->_getParam("key");
         if (!Document_Service::pathExists($intendedPath)) {
             $createValues = array("userOwner" => $this->getUser()->getId(), "userModification" => $this->getUser()->getId(), "published" => false);
             $createValues["key"] = $this->_getParam("key");
             // check for a docType
             if ($this->_getParam("docTypeId") && is_numeric($this->_getParam("docTypeId"))) {
                 $docType = Document_DocType::getById(intval($this->_getParam("docTypeId")));
                 $createValues["template"] = $docType->getTemplate();
                 $createValues["controller"] = $docType->getController();
                 $createValues["action"] = $docType->getAction();
                 $createValues["module"] = $docType->getModule();
             } else {
                 if ($this->_getParam("type") == "page" || $this->_getParam("type") == "snippet" || $this->_getParam("type") == "email") {
                     $createValues["controller"] = Pimcore_Config::getSystemConfig()->documents->default_controller;
                     $createValues["action"] = Pimcore_Config::getSystemConfig()->documents->default_action;
                 }
             }
             switch ($this->_getParam("type")) {
                 case "page":
                     $document = Document_Page::create($this->_getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "snippet":
                     $document = Document_Snippet::create($this->_getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "email":
                     //ckogler
                     $document = Document_Email::create($this->_getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "link":
                     $document = Document_Link::create($this->_getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "hardlink":
                     $document = Document_Hardlink::create($this->_getParam("parentId"), $createValues);
                     $success = true;
                     break;
                 case "folder":
                     $document = Document_Folder::create($this->_getParam("parentId"), $createValues);
                     $document->setPublished(true);
                     try {
                         $document->save();
                         $success = true;
                     } catch (Exception $e) {
                         $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
                     }
                     break;
                 default:
                     Logger::debug("Unknown document type, can't add [ " . $this->_getParam("type") . " ] ");
                     break;
             }
         } else {
             Logger::debug("prevented adding a document because document with same path+key [ {$intendedPath} ] already exists");
         }
     } else {
         Logger::debug("prevented adding a document because of missing permissions");
     }
     if ($success) {
         $this->_helper->json(array("success" => $success, "id" => $document->getId(), "type" => $document->getType()));
     } else {
         $this->_helper->json(array("success" => $success));
     }
 }
Exemple #23
0
 public function init()
 {
     parent::init();
     // set language
     if (Zend_Registry::isRegistered("Zend_Locale")) {
         $locale = Zend_Registry::get("Zend_Locale");
         $this->setLanguage($locale->getLanguage());
     } else {
         if ($this->_getParam("language")) {
             $this->setLanguage($this->_getParam("language"));
         } else {
             $config = Pimcore_Config::getSystemConfig();
             $this->setLanguage($config->general->language);
             // try to set browser-language (validation if installed is in $this->setLanguage() )
             $this->setLanguage(new Zend_Locale());
         }
     }
     if (self::$adminInitialized) {
         // this will be executed on every call to this init() method
         try {
             $this->setUser(Zend_Registry::get("pimcore_admin_user"));
         } catch (Exception $e) {
             Logger::emerg("adminInitialized was set to true although there was no user set in the registry -> to be save the process was killed");
             exit;
         }
     } else {
         // the following code is only called once, even when there are some subcalls (eg. with $this->action, ... )
         $this->disableBrowserCache();
         // general definitions
         Document::setHideUnpublished(false);
         Object_Abstract::setHideUnpublished(false);
         Object_Abstract::setGetInheritedValues(false);
         Pimcore::setAdminMode();
         // init translations
         self::initTranslations($this);
         // init zend action helpers
         Zend_Controller_Action_HelperBroker::addPrefix('Pimcore_Controller_Action_Helper');
         // this is to make it possible to use the session id as a part of the route (ZF default route) used for pixlr.com editors, etc.
         if ($this->_getParam("pimcore_admin_sid")) {
             $_REQUEST["pimcore_admin_sid"] = $this->_getParam("pimcore_admin_sid");
         }
         // authenticate user, first try to authenticate with session information
         $user = Pimcore_Tool_Authentication::authenticateSession();
         if ($user instanceof User) {
             $this->setUser($user);
             if ($this->getUser()->getLanguage()) {
                 $this->setLanguage($this->getUser()->getLanguage());
             }
         } else {
             // try to authenticate with digest, but this is only allowed for WebDAV
             if ($this->_getParam("module") == "admin" && $this->_getParam("controller") == "asset" && $this->_getParam("action") == "webdav") {
                 $user = Pimcore_Tool_Authentication::authenticateDigest();
                 if ($user instanceof User) {
                     $this->setUser($user);
                     self::$adminInitialized = true;
                     return;
                 }
             }
         }
         // redirect to the login-page if the user isn't authenticated
         if (!$this->getUser() instanceof User && !($this->_getParam("module") == "admin" && $this->_getParam("controller") == "login")) {
             // put a detailed message into the debug.log
             Logger::warn("Prevented access to " . $_SERVER["REQUEST_URI"] . " because there is no user in the session!");
             Logger::warn(array("server" => $_SERVER, "get" => $_GET, "post" => $_POST, "session" => $_SESSION, "cookie" => $_COOKIE));
             // send a auth header for the client (is covered by the ajax object in javascript)
             $this->getResponse()->setHeader("X-Pimcore-Auth", "required");
             // redirect to login page
             $this->_redirect("/admin/login");
             // exit the execution -> just to be sure
             exit;
         }
         // we're now authenticated so we can remove the default error handler so that we get just the normal PHP errors
         if ($this->_getParam("controller") != "login") {
             $front = Zend_Controller_Front::getInstance();
             $front->unregisterPlugin("Pimcore_Controller_Plugin_ErrorHandler");
             $front->throwExceptions(true);
             @ini_set("display_errors", "On");
             @ini_set("display_startup_errors", "On");
         }
         Zend_Registry::set("pimcore_admin_user", $this->getUser());
         self::$adminInitialized = true;
     }
 }
Exemple #24
0
 /**
  * returns the path to a temp file
  *
  * @return string
  */
 public function getTemporaryFile()
 {
     $conf = Pimcore_Config::getSystemConfig();
     $destinationPath = PIMCORE_TEMPORARY_DIRECTORY . "/asset_" . $this->getId() . "_" . md5(microtime());
     file_put_contents($destinationPath, $this->getData());
     chmod($destinationPath, self::$chmod);
     return str_replace(PIMCORE_DOCUMENT_ROOT, "", $destinationPath);
 }
Exemple #25
0
$browser = new Pimcore_Browser();
$browserVersion = (int) $browser->getVersion();
$platform = $browser->getPlatform();
if ($browser->getBrowser() == Pimcore_Browser::BROWSER_FIREFOX && $browserVersion >= 3) {
    $supported = true;
}
if ($browser->getBrowser() == Pimcore_Browser::BROWSER_IE && $browserVersion >= 8) {
    $supported = true;
}
if ($browser->getBrowser() == Pimcore_Browser::BROWSER_CHROME && $browserVersion >= 5) {
    $supported = true;
}
if ($browser->getBrowser() == Pimcore_Browser::BROWSER_SAFARI && $browserVersion >= 4 && $platform == Pimcore_Browser::PLATFORM_WINDOWS) {
    $supported = true;
}
$config = Pimcore_Config::getSystemConfig();
?>

<?php 
if ($config->general->loginscreencustomimage) {
    ?>
    <img src="<?php 
    echo $config->general->loginscreencustomimage;
    ?>
" class="background" id="backgroundimage" />
<?php 
} else {
    ?>
    <img src="/pimcore/static/img/login-reloaded/background.jpg" class="background" id="backgroundimage" />
<?php 
}
 public function init()
 {
     parent::init();
     // log exceptions if handled by error_handler
     $this->checkForErrors();
     // general definitions
     Pimcore::unsetAdminMode();
     Document::setHideUnpublished(true);
     Object_Abstract::setHideUnpublished(true);
     Object_Abstract::setGetInheritedValues(true);
     // contains the logged in user if necessary
     $user = null;
     // assign variables
     $this->view->controller = $this;
     // init website config
     $config = Pimcore_Config::getWebsiteConfig();
     $this->config = $config;
     $this->view->config = $config;
     if (!$this->_getParam("document")) {
         Zend_Registry::set("pimcore_editmode", false);
         $this->editmode = false;
         $this->view->editmode = false;
         // no document available, continue, ...
         return;
     } else {
         $this->setDocument($this->_getParam("document"));
     }
     if ($this->_getParam("pimcore_editmode") || $this->_getParam("pimcore_version") || $this->_getParam("pimcore_preview") || $this->_getParam("pimcore_admin") || $this->_getParam("pimcore_object_preview")) {
         $specialAdminRequest = true;
         $this->disableBrowserCache();
         // start admin session & get logged in user
         $user = Pimcore_Tool_Authentication::authenticateSession();
     }
     if (!$this->document->isPublished()) {
         if ($specialAdminRequest) {
             if (!$user) {
                 throw new Exception("access denied for " . $this->document->getFullPath());
             }
         } else {
             throw new Exception("access denied for " . $this->document->getFullPath());
         }
     }
     // register global locale if the document has the system property "language"
     if ($this->document->getProperty("language")) {
         $locale = new Zend_Locale($this->document->getProperty("language"));
         Zend_Registry::set('Zend_Locale', $locale);
         $this->getResponse()->setHeader("Content-Language", strtolower(str_replace("_", "-", (string) $locale)), true);
     }
     // for editmode
     if ($user) {
         if ($this->_getParam("pimcore_editmode") and !Zend_Registry::isRegistered("pimcore_editmode")) {
             Zend_Registry::set("pimcore_editmode", true);
             // check if there is the document in the session
             $docKey = "document_" . $this->getDocument()->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 // if there is a document in the session use it
                 $this->setDocument($docSession->{$docKey});
             } else {
                 // set the latest available version for editmode if there is no doc in the session
                 $latestVersion = $this->getDocument()->getLatestVersion();
                 if ($latestVersion) {
                     $latestDoc = $latestVersion->loadData();
                     if ($latestDoc instanceof Document_PageSnippet) {
                         $this->setDocument($latestDoc);
                     }
                 }
             }
             // register editmode plugin
             $front = Zend_Controller_Front::getInstance();
             $front->registerPlugin(new Pimcore_Controller_Plugin_Frontend_Editmode($this), 1000);
         } else {
             Zend_Registry::set("pimcore_editmode", false);
         }
     } else {
         Zend_Registry::set("pimcore_editmode", false);
     }
     // for preview
     if ($user) {
         // document preview
         if ($this->_getParam("pimcore_preview")) {
             // get document from session
             $docKey = "document_" . $this->_getParam("document")->getId();
             $docSession = new Zend_Session_Namespace("pimcore_documents");
             if ($docSession->{$docKey}) {
                 $this->setDocument($docSession->{$docKey});
             }
         }
         // object preview
         if ($this->_getParam("pimcore_object_preview")) {
             $key = "object_" . $this->_getParam("pimcore_object_preview");
             $session = new Zend_Session_Namespace("pimcore_objects");
             if ($session->{$key}) {
                 $object = $session->{$key};
                 // add the object to the registry so every call to Object_Abstract::getById() will return this object instead of the real one
                 Zend_Registry::set("object_" . $object->getId(), $object);
             }
         }
     }
     // for version preview
     if ($this->_getParam("pimcore_version")) {
         if ($user) {
             // only get version data at the first call || because of embedded Snippets ...
             if (!Zend_Registry::isRegistered("pimcore_version_active")) {
                 $version = Version::getById($this->_getParam("pimcore_version"));
                 $this->setDocument($version->getData());
                 Zend_Registry::set("pimcore_version_active", true);
             }
         }
     }
     // for public versions
     if ($this->_getParam("v")) {
         try {
             $version = Version::getById($this->_getParam("v"));
             if ($version->getPublic()) {
                 $this->setDocument($version->getData());
             }
         } catch (Exception $e) {
         }
     }
     // check if document is a wrapped hardlink, if this is the case send a rel=canonical header to the source document
     if ($this->getDocument() instanceof Document_Hardlink_Wrapper_Interface) {
         // get the cononical (source) document
         $hardlinkCanonicalSourceDocument = Document::getById($this->getDocument()->getId());
         $request = $this->getRequest();
         $this->getResponse()->setHeader("Link", '<' . $request->getScheme() . "://" . $request->getHttpHost() . $hardlinkCanonicalSourceDocument->getFullPath() . '>; rel="canonical"');
     }
     // set some parameters
     $this->editmode = Zend_Registry::get("pimcore_editmode");
     $this->view->editmode = Zend_Registry::get("pimcore_editmode");
 }
Exemple #27
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $requestUri = $request->getRequestUri();
     $excludePatterns = array();
     // only enable GET method
     if (!$request->isGet()) {
         return $this->disable();
     }
     try {
         $conf = Pimcore_Config::getSystemConfig();
         if ($conf->cache) {
             $conf = $conf->cache;
             if (!$conf->enabled) {
                 return $this->disable();
             }
             if ($conf->lifetime) {
                 $this->setLifetime((int) $conf->lifetime);
             }
             if ($conf->excludePatterns) {
                 $confExcludePatterns = explode(",", $conf->excludePatterns);
                 if (!empty($confExcludePatterns)) {
                     $excludePatterns = $confExcludePatterns;
                 }
             }
             if ($conf->excludeCookie) {
                 $cookies = explode(",", strval($conf->excludeCookie));
                 foreach ($cookies as $cookie) {
                     if (isset($_COOKIE[trim($cookie)])) {
                         return $this->disable();
                     }
                 }
             }
         } else {
             return $this->disable();
         }
     } catch (Exception $e) {
         return $this->disable();
     }
     foreach ($excludePatterns as $pattern) {
         if (preg_match($pattern, $requestUri)) {
             return $this->disable();
         }
     }
     $appendKey = "";
     // this is for example for the image-data-uri plugin
     if ($request->getParam("pimcore_cache_tag_suffix")) {
         $tags = $request->getParam("pimcore_cache_tag_suffix");
         if (is_array($tags)) {
             $appendKey = "_" . implode("_", $tags);
         }
     }
     $this->cacheKey = "output_" . md5(Pimcore_Tool::getHostname() . $requestUri) . $appendKey;
     if ($cacheItem = Pimcore_Model_Cache::load($this->cacheKey, true)) {
         header("X-Pimcore-Cache-Tag: " . $this->cacheKey, true, 200);
         header("X-Pimcore-Cache-Date: " . $cacheItem["date"]);
         foreach ($cacheItem["rawHeaders"] as $header) {
             header($header);
         }
         foreach ($cacheItem["headers"] as $header) {
             header($header['name'] . ': ' . $header['value'], $header['replace']);
         }
         echo $cacheItem["content"];
         exit;
     }
 }
<?php

// get db connection
$db = Pimcore_Resource::get();
try {
    $config = Pimcore_Config::getReportConfig()->toArray();
    if (isset($config["analytics"]) && is_array($config["analytics"]["sites"])) {
        foreach ($config["analytics"]["sites"] as $siteKey => &$siteConfig) {
            if (!$siteConfig["universalcode"]) {
                $siteConfig["asynchronouscode"] = 1;
            }
        }
    }
    $config = new Zend_Config($config, true);
    $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_DIRECTORY . "/reports.xml"));
    $writer->write();
} catch (\Exception $e) {
    echo $e->getMessage();
}
Exemple #29
0
 /**
  * Initializes the mailer with the settings form Settings -> System -> Email Settings
  *
  * @return void
  */
 protected function init()
 {
     $systemConfig = Pimcore_Config::getSystemConfig()->toArray();
     $emailSettings =& $systemConfig['email'];
     if ($emailSettings['sender']['email']) {
         $this->setDefaultFrom($emailSettings['sender']['email'], $emailSettings['sender']['name']);
     }
     if ($emailSettings['return']['email']) {
         $this->setDefaultReplyTo($emailSettings['return']['email'], $emailSettings['return']['name']);
     }
     if ($emailSettings['method'] == "smtp") {
         $config = array();
         if ($emailSettings['smtp']['name']) {
             $config['name'] = $emailSettings['smtp']['name'];
         }
         if ($emailSettings['smtp']['ssl']) {
             $config['ssl'] = $emailSettings['smtp']['ssl'];
         }
         if ($emailSettings['smtp']['port']) {
             $config['port'] = $emailSettings['smtp']['port'];
         }
         if ($emailSettings['smtp']['auth']['method']) {
             $config['auth'] = $emailSettings['smtp']['auth']['method'];
             $config['username'] = $emailSettings['smtp']['auth']['username'];
             $config['password'] = $emailSettings['smtp']['auth']['password'];
         }
         $transport = new Zend_Mail_Transport_Smtp($emailSettings['smtp']['host'], $config);
         $this->setDefaultTransport($transport);
     }
     //setting debug email addresses
     if (empty(self::$debugEmailAddresses)) {
         if ($emailSettings['debug']['emailaddresses']) {
             foreach (explode(',', $emailSettings['debug']['emailaddresses']) as $emailAddress) {
                 self::$debugEmailAddresses[] = $emailAddress;
             }
         }
     }
     $this->placeholderObject = new Pimcore_Placeholder();
 }
 public function setSystemAction()
 {
     if ($this->getUser()->isAllowed("system_settings")) {
         $values = Zend_Json::decode($this->_getParam("data"));
         $oldConfig = Pimcore_Config::getSystemConfig();
         $oldValues = $oldConfig->toArray();
         $smtpPassword = $values["email.smtp.auth.password"];
         if (empty($smtpPassword)) {
             $smtpPassword = $oldValues['email']['smtp']['auth']['password'];
         }
         // convert all special characters to their entities so the xml writer can put it into the file
         $values = array_htmlspecialchars($values);
         $settings = array("general" => array("timezone" => $values["general.timezone"], "php_cli" => $values["general.php_cli"], "domain" => $values["general.domain"], "language" => $values["general.language"], "validLanguages" => $values["general.validLanguages"], "theme" => $values["general.theme"], "loginscreenimageservice" => $values["general.loginscreenimageservice"], "loginscreencustomimage" => $values["general.loginscreencustomimage"], "debug" => $values["general.debug"], "debug_ip" => $values["general.debug_ip"], "firephp" => $values["general.firephp"], "loglevel" => array("debug" => $values["general.loglevel.debug"], "info" => $values["general.loglevel.info"], "notice" => $values["general.loglevel.notice"], "warning" => $values["general.loglevel.warning"], "error" => $values["general.loglevel.error"], "critical" => $oldValues["general"]["loglevel"]["critical"], "alert" => $oldValues["general"]["loglevel"]["alert"], "emergency" => $oldValues["general"]["loglevel"]["emergency"]), "devmode" => $values["general.devmode"], "logrecipient" => $values["general.logrecipient"], "welcomescreen" => $values["general.welcomescreen"], "viewSuffix" => $values["general.viewSuffix"]), "database" => $oldValues["database"], "documents" => array("versions" => array("days" => $values["documents.versions.days"], "steps" => $values["documents.versions.steps"]), "default_controller" => $values["documents.default_controller"], "default_action" => $values["documents.default_action"], "error_page" => $values["documents.error_page"], "allowtrailingslash" => $values["documents.allowtrailingslash"], "allowcapitals" => $values["documents.allowcapitals"]), "objects" => array("versions" => array("days" => $values["objects.versions.days"], "steps" => $values["objects.versions.steps"])), "assets" => array("webdav" => array("hostname" => $values["assets.webdav.hostname"]), "versions" => array("days" => $values["assets.versions.days"], "steps" => $values["assets.versions.steps"]), "ffmpeg" => $values["assets.ffmpeg"]), "services" => array("googlemaps" => array("apikey" => $values["services.googlemaps.apikey"]), "translate" => array("apikey" => $values["services.translate.apikey"]), "google" => array("username" => $values["services.google.username"], "password" => $values["services.google.password"])), "cache" => array("enabled" => $values["cache.enabled"], "lifetime" => $values["cache.lifetime"], "excludePatterns" => $values["cache.excludePatterns"], "excludeCookie" => $values["cache.excludeCookie"]), "outputfilters" => array("imagedatauri" => $values["outputfilters.imagedatauri"], "less" => $values["outputfilters.less"], "lesscpath" => $values["outputfilters.lesscpath"], "cssminify" => $values["outputfilters.cssminify"], "javascriptminify" => $values["outputfilters.javascriptminify"], "javascriptminifyalgorithm" => $values["outputfilters.javascriptminifyalgorithm"], "htmlminify" => $values["outputfilters.htmlminify"], "cdn" => $values["outputfilters.cdn"], "cdnhostnames" => $values["outputfilters.cdnhostnames"], "cdnpatterns" => $values["outputfilters.cdnpatterns"]), "email" => array("sender" => array("name" => $values["email.sender.name"], "email" => $values["email.sender.email"]), "return" => array("name" => $values["email.return.name"], "email" => $values["email.return.email"]), "method" => $values["email.method"], "smtp" => array("host" => $values["email.smtp.host"], "port" => $values["email.smtp.port"], "ssl" => $values["email.smtp.ssl"], "name" => $values["email.smtp.name"], "auth" => array("method" => $values["email.smtp.auth.method"], "username" => $values["email.smtp.auth.username"], "password" => $smtpPassword)), "debug" => array("emailaddresses" => $values["email.debug.emailAddresses"])), "webservice" => array("enabled" => $values["webservice.enabled"]), "httpclient" => array("adapter" => $values["httpclient.adapter"], "proxy_host" => $values["httpclient.proxy_host"], "proxy_port" => $values["httpclient.proxy_port"], "proxy_user" => $values["httpclient.proxy_user"], "proxy_pass" => $values["httpclient.proxy_pass"]));
         $config = new Zend_Config($settings, true);
         $writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $this->_helper->json(array("success" => true));
     } else {
         if ($this->getUser() != null) {
             Logger::err("user [" . $this->getUser()->getId() . "] attempted to change system settings, but has no permission to do so.");
         } else {
             Logger::err("attempt to change system settings, but no user in session.");
         }
     }
     $this->_helper->json(false);
 }