Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
    $writer = new Zend_Log_Writer_Stream('php://output');
    $logger = new Zend_Log($writer);
    Logger::addLogger($logger);
    // set all priorities
    Logger::setPriorities(array(Zend_Log::DEBUG, Zend_Log::INFO, Zend_Log::NOTICE, Zend_Log::WARN, Zend_Log::ERR, Zend_Log::CRIT, Zend_Log::ALERT, Zend_Log::EMERG));
}
$forceType = null;
if ($opts->getOption("manager")) {
    $forceType = $opts->getOption("manager");
}
$validJobs = array();
if ($opts->getOption("job")) {
    $validJobs = explode(",", $opts->getOption("job"));
}
// create manager
$manager = Schedule_Manager_Factory::getManager("maintenance.pid", $forceType);
$manager->setValidJobs($validJobs);
// register scheduled tasks
$manager->registerJob(new Schedule_Maintenance_Job("scheduledtasks", new Schedule_Task_Executor(), "execute"));
$manager->registerJob(new Schedule_Maintenance_Job("logmaintenance", new Pimcore_Log_Maintenance(), "mail"));
$manager->registerJob(new Schedule_Maintenance_Job("httperrorlog", new Pimcore_Log_Maintenance(), "httpErrorLogCleanup"));
$manager->registerJob(new Schedule_Maintenance_Job("sanitycheck", "Element_Service", "runSanityCheck"));
$manager->registerJob(new Schedule_Maintenance_Job("cleanupoldpidfiles", "Schedule_Manager_Factory", "cleanupOldPidFiles"), true);
$manager->registerJob(new Schedule_Maintenance_Job("versioncleanup", new Version(), "maintenanceCleanUp"));
$manager->registerJob(new Schedule_Maintenance_Job("redirectcleanup", "Redirect", "maintenanceCleanUp"));
$manager->registerJob(new Schedule_Maintenance_Job("cleanupbrokenviews", "Pimcore_Resource", "cleanupBrokenViews"));
// call plugins
$plugins = Pimcore_API_Plugin_Broker::getInstance()->getPlugins();
foreach ($plugins as $plugin) {
    $id = get_class($plugin);
    $jobRegistered = null;
Ejemplo n.º 3
0
 /**
  * @param  string[] $urls
  * @return void
  */
 public function findLinks($urls)
 {
     //inital for all urls
     $cookieJar = new Zend_Http_CookieJar();
     foreach ($urls as $url) {
         try {
             $uri = Zend_Uri_Http::fromString($url);
             $url = str_ireplace($uri->getHost(), strtolower($uri->getHost()), $url);
         } catch (Zend_Uri_Exception $e) {
         }
         $url = $this->addEvictOutputFilterParameter($url);
         $client = Pimcore_Tool::getHttpClient();
         $client->setUri($url);
         $client->setConfig(array('maxredirects' => $this->maxRedirects, 'timeout' => $this->timeout));
         $client->setCookieJar($cookieJar);
         $client->setHeaders('If-Modified-Since', null);
         try {
             $response = $client->request();
         } catch (Zend_Http_Client_Adapter_Exception $e) {
             logger::log(get_class($this) . ": Could not get response for Link [ {$url} ] ", Zend_Log::ERR);
         }
         if ($response instanceof Zend_Http_Response and ($response->isSuccessful() or $response->isRedirect())) {
             //we don't use port - crawler ist limited to standard port 80
             $client->getUri()->setPort(null);
             //update url - maybe we were redirected
             $url = $client->getUri(true);
             $url = $this->removeOutputFilterParameters($url);
             //$this->linksDone[] = $url;
             try {
                 $success = $this->parse($url, $response, $client->getUri()->getHost(), $client->getCookieJar(), 0);
                 logger::log(get_class($this) . ": parsed entry point  [ {$url} ] ", Zend_Log::INFO);
             } catch (Exception $e) {
                 logger::log($e);
             }
         } else {
             logger::log(get_class($this) . ": Invalid Respose for URL  [ {$url} ] ", Zend_Log::DEBUG);
         }
     }
     $manager = Schedule_Manager_Factory::getManager("searchphpcrawlermanager.pid");
     for ($i = 1; $i <= $this->maxThreads; $i++) {
         $manager->registerJob(new Schedule_Maintenance_Job("crawler-" . $i, $this, "continueWithFoundLinks", array()));
     }
     $manager->registerJob(new Schedule_Maintenance_Job("crawler-indexer", $this, "doIndex", array()));
     $manager->run();
     //make sure that there are no more links left in DB
     $this->continueWithFoundLinks();
     //final indexer run
     $this->doIndex(true);
 }