Beispiel #1
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);
     }
 }
Beispiel #2
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);
         }
     }
 }
Beispiel #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;
 }
Beispiel #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);
     }
 }
Beispiel #6
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);
 }
Beispiel #7
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();
     }
 }
Beispiel #8
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;
 }
Beispiel #9
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");
     }
 }
Beispiel #11
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();
     }
 }
Beispiel #12
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");
 }
Beispiel #13
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);
 }
Beispiel #15
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);
     }
 }
Beispiel #17
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 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);
 }
Beispiel #19
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;
     }
 }
Beispiel #20
0
 /**
  * @static
  * @return bool|string
  */
 public static function getQtfaststartCli()
 {
     if (Pimcore_Config::getSystemConfig()->assets->qtfaststart) {
         if (is_executable(Pimcore_Config::getSystemConfig()->assets->qtfaststart)) {
             return Pimcore_Config::getSystemConfig()->assets->qtfaststart;
         } else {
             Logger::critical("qtfaststart binary: " . Pimcore_Config::getSystemConfig()->assets->qtfaststart . " is not executable");
         }
     }
     $paths = array("/usr/bin/qtfaststart", "/usr/local/bin/qtfaststart", "/bin/qtfaststart");
     foreach ($paths as $path) {
         if (is_executable($path)) {
             return $path;
         }
     }
     return false;
 }
Beispiel #21
0
 /**
  * @return string
  */
 public static function getRGBColorProfile()
 {
     if (!self::$RGBColorProfile) {
         if ($path = Pimcore_Config::getSystemConfig()->assets->icc_rgb_profile) {
             if (file_exists($path)) {
                 self::$RGBColorProfile = file_get_contents($path);
             }
         }
     }
     return self::$RGBColorProfile;
 }
Beispiel #22
0
 /**
  * $directCall is true when the method is called from outside (eg. directly in the controller "save only version")
  * it is false when the method is called by $this->update()
  * @param bool $setModificationDate
  * @param bool $directCall
  * @return Version
  */
 public function saveVersion($setModificationDate = true, $directCall = true)
 {
     if ($setModificationDate) {
         $this->setO_modificationDate(time());
     }
     // hook should be also called if "save only new version" is selected
     if ($directCall) {
         Pimcore_API_Plugin_Broker::getInstance()->preUpdateObject($this);
     }
     // scheduled tasks are saved always, they are not versioned!
     if ($directCall) {
         $this->saveScheduledTasks();
     }
     $version = null;
     // only create a new version if there is at least 1 allowed
     if (Pimcore_Config::getSystemConfig()->objects->versions) {
         // create version
         $version = new Version();
         $version->setCid($this->getO_Id());
         $version->setCtype("object");
         $version->setDate($this->getO_modificationDate());
         $version->setUserId($this->getO_userModification());
         $version->setData($this);
         $version->save();
     }
     // hook should be also called if "save only new version" is selected
     if ($directCall) {
         Pimcore_API_Plugin_Broker::getInstance()->postUpdateObject($this);
     }
     return $version;
 }
Beispiel #23
0
 /**
  * @param  $path
  * @param bool $partial
  * @return array|bool
  */
 public function match($path, $partial = false)
 {
     $matchFound = false;
     $config = Pimcore_Config::getSystemConfig();
     $routeingDefaults = Pimcore_Tool::getRoutingDefaults();
     $params = array_merge($_GET, $_POST);
     $params = array_merge($routeingDefaults, $params);
     // set the original path
     $originalPath = $path;
     // check for a registered site
     try {
         if ($config->general->domain != $_SERVER["HTTP_HOST"]) {
             $domain = $_SERVER["HTTP_HOST"];
             $site = Site::getByDomain($domain);
             $site->setRootPath($site->getRootDocument()->getFullPath());
             $path = $site->getRootDocument()->getFullPath() . $path;
             Zend_Registry::set("pimcore_site", $site);
         }
     } catch (Exception $e) {
     }
     // check for direct definition of controller/action
     if (!empty($_REQUEST["controller"]) && !empty($_REQUEST["action"])) {
         $matchFound = true;
         //$params["document"] = $this->getNearestDocumentByPath($path);
     }
     // you can also call a page by it's ID /?pimcore_document=XXXX
     if (!$matchFound) {
         if (!empty($params["pimcore_document"]) || !empty($params["pdid"])) {
             $doc = Document::getById($params["pimcore_document"] ? $params["pimcore_document"] : $params["pdid"]);
             if ($doc instanceof Document) {
                 $path = $doc->getFullPath();
             }
         }
     }
     // test if there is a suitable redirect with override = all (=> priority = 99)
     if (!$matchFound) {
         $this->checkForRedirect(true);
     }
     // test if there is a suitable page
     if (!$matchFound) {
         try {
             $document = Document::getByPath($path);
             // check for a parent hardlink with childs
             if (!$document instanceof Document) {
                 $hardlinkedParentDocument = $this->getNearestDocumentByPath($path, true);
                 if ($hardlinkedParentDocument instanceof Document_Hardlink) {
                     if ($hardLinkedDocument = Document_Hardlink_Service::getChildByPath($hardlinkedParentDocument, $path)) {
                         $document = $hardLinkedDocument;
                     }
                 }
             }
             // check for direct hardlink
             if ($document instanceof Document_Hardlink) {
                 $hardlinkParentDocument = $document;
                 $document = Document_Hardlink_Service::wrap($hardlinkParentDocument);
             }
             if ($document instanceof Document) {
                 if (in_array($document->getType(), array("page", "snippet", "email"))) {
                     if (!empty($params["pimcore_version"]) || !empty($params["pimcore_preview"]) || !empty($params["pimcore_admin"]) || !empty($params["pimcore_editmode"]) || $document->isPublished() || !empty($_COOKIE["pimcore_admin_sid"])) {
                         $params["document"] = $document;
                         if ($controller = $document->getController()) {
                             $params["controller"] = $controller;
                             $params["action"] = "index";
                         }
                         if ($action = $document->getAction()) {
                             $params["action"] = $action;
                         }
                         if ($module = $document->getModule()) {
                             $params["module"] = $module;
                         }
                         // check for a trailing slash in path, if exists, redirect to this page without the slash
                         // the only reason for this is: SEO, Analytics, ... there is no system specific reason, pimcore would work also with a trailing slash without problems
                         // use $originalPath because of the sites
                         if ($config->documents->allowtrailingslash) {
                             if ($config->documents->allowtrailingslash == "no") {
                                 if (substr($originalPath, strlen($originalPath) - 1, 1) == "/" && $originalPath != "/") {
                                     $redirectUrl = rtrim($originalPath, "/");
                                     if ($_SERVER["QUERY_STRING"]) {
                                         $redirectUrl .= "?" . $_SERVER["QUERY_STRING"];
                                     }
                                     header("Location: " . $redirectUrl, true, 301);
                                     exit;
                                 }
                             }
                         }
                         if ($config->documents->allowcapitals) {
                             if ($config->documents->allowcapitals == "no") {
                                 if (strtolower($originalPath) != $originalPath) {
                                     $redirectUrl = strtolower($originalPath);
                                     if ($_SERVER["QUERY_STRING"]) {
                                         $redirectUrl .= "?" . $_SERVER["QUERY_STRING"];
                                     }
                                     header("Location: " . $redirectUrl, true, 301);
                                     exit;
                                 }
                             }
                         }
                         $matchFound = true;
                     }
                 } else {
                     if ($document->getType() == "link") {
                         // if the document is a link just redirect to the location/href of the link
                         header("Location: " . $document->getHref(), true, 301);
                         exit;
                     }
                 }
             }
         } catch (Exception $e) {
             // no suitable page found
         }
     }
     // test if there is a suitable static route
     if (!$matchFound) {
         try {
             $cacheKey = "system_route_staticroute";
             if (!($routes = Pimcore_Model_Cache::load($cacheKey))) {
                 $list = new Staticroute_List();
                 $list->setOrderKey("priority");
                 $list->setOrder("DESC");
                 $routes = $list->load();
                 Pimcore_Model_Cache::save($routes, $cacheKey, array("system", "staticroute", "route"), null, 998);
             }
             foreach ($routes as $route) {
                 if (@preg_match($route->getPattern(), $originalPath) && !$matchFound) {
                     $params = array_merge($route->getDefaultsArray(), $params);
                     $variables = explode(",", $route->getVariables());
                     preg_match_all($route->getPattern(), $originalPath, $matches);
                     if (is_array($matches) && count($matches) > 1) {
                         foreach ($matches as $index => $match) {
                             if ($variables[$index - 1]) {
                                 $params[$variables[$index - 1]] = $match[0];
                             }
                         }
                     }
                     $controller = $route->getController();
                     $action = $route->getAction();
                     $module = trim($route->getModule());
                     // check for dynamic controller / action / module
                     $dynamicRouteReplace = function ($item, $params) {
                         if (strpos($item, "%") !== false) {
                             foreach ($params as $key => $value) {
                                 $dynKey = "%" . $key;
                                 if (strpos($item, $dynKey) !== false) {
                                     return str_replace($dynKey, $value, $item);
                                 }
                             }
                         }
                         return $item;
                     };
                     $controller = $dynamicRouteReplace($controller, $params);
                     $action = $dynamicRouteReplace($action, $params);
                     $module = $dynamicRouteReplace($module, $params);
                     $params["controller"] = $controller;
                     $params["action"] = $action;
                     if (!empty($module)) {
                         $params["module"] = $module;
                     }
                     // try to get nearest document to the route
                     $params["document"] = $this->getNearestDocumentByPath($path);
                     $matchFound = true;
                     Staticroute::setCurrentRoute($route);
                     break;
                 }
             }
         } catch (Exception $e) {
             // no suitable route found
         }
     }
     // test if there is a suitable redirect
     if (!$matchFound) {
         $this->checkForRedirect(false);
     }
     if (!$matchFound && $site instanceof Site) {
         if ($config->general->domain) {
             header("Location: http://" . $_SERVER["HTTP_HOST"], true, 301);
         } else {
             $errorMessage = "You have to specify a main domain in system-settings (Settings -> System -> Website -> Domain) if you want to use sites!";
             Logger::emerg($errorMessage);
             die($errorMessage);
         }
         exit;
     }
     if (!$matchFound) {
         return false;
     }
     // remove pimcore magic parameters
     unset($params["pimcore_outputfilters_disabled"]);
     unset($params["pimcore_document"]);
     unset($params["nocache"]);
     return $params;
 }
<?php

// valid languages is new in system config
$configArray = Pimcore_Config::getSystemConfig()->toArray();
$configArray["general"]["custom_php_logfile"] = "1";
$configArray = array_htmlspecialchars($configArray);
$config = new Zend_Config($configArray, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
$writer->write();
 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));
     }
 }
Beispiel #26
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);
 }
Beispiel #27
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;
     }
 }
Beispiel #28
0
 public function translateAction()
 {
     $conf = Pimcore_Config::getSystemConfig();
     $key = $conf->services->translate->apikey;
     $locale = new Zend_Locale($this->_getParam("language"));
     $language = $locale->getLanguage();
     $supportedTypes = array("input", "textarea", "wysiwyg");
     $data = Zend_Json::decode($this->_getParam("data"));
     foreach ($data as &$d) {
         if (in_array($d["type"], $supportedTypes)) {
             $response = Pimcore_Tool::getHttpData("https://www.googleapis.com/language/translate/v2?key=" . $key . "&q=" . urlencode($d["data"]) . "&target=" . $language);
             $tData = Zend_Json::decode($response);
             if ($tData["data"]["translations"][0]["translatedText"]) {
                 $d["data"] = $tData["data"]["translations"][0]["translatedText"];
             }
         }
     }
     $this->getRequest()->setParam("data", Zend_Json::encode($data));
     $this->saveToSessionAction();
 }
Beispiel #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();
 }
Beispiel #30
0
 /**
  *
  */
 public function maintenanceCleanUp()
 {
     $conf["document"] = Pimcore_Config::getSystemConfig()->documents->versions;
     $conf["asset"] = Pimcore_Config::getSystemConfig()->assets->versions;
     $conf["object"] = Pimcore_Config::getSystemConfig()->objects->versions;
     $elementTypes = array();
     foreach ($conf as $elementType => $tConf) {
         if (intval($tConf->days) > 0) {
             $versioningType = "days";
             $value = intval($tConf->days);
         } else {
             $versioningType = "steps";
             $value = intval($tConf->steps);
         }
         if ($versioningType) {
             $elementTypes[] = array("elementType" => $elementType, $versioningType => $value);
         }
     }
     $versions = $this->getResource()->maintenanceGetOutdatedVersions($elementTypes);
     if (is_array($versions)) {
         foreach ($versions as $index => $id) {
             $version = Version::getById($id);
             if ($version->getCtype() == "document") {
                 $element = Document::getById($version->getCid());
             } else {
                 if ($version->getCtype() == "asset") {
                     $element = Asset::getById($version->getCid());
                 } else {
                     if ($version->getCtype() == "object") {
                         $element = Object_Abstract::getById($version->getCid());
                     }
                 }
             }
             if ($element instanceof Element_Interface) {
                 if ($element->getModificationDate() > $version->getDate()) {
                     // delete version if it is outdated
                     $version->delete();
                 }
             } else {
                 // delete version if the correspondening element doesn't exist anymore
                 $version->delete();
             }
             // call the garbage collector every 100 iterations, to avoid a out-of-memory
             if ($index % 100 == 0) {
                 Pimcore::collectGarbage();
             }
         }
     }
 }