function onHeader($event, $data) { if (config::get('ganalytics.account') == NULL) { logger::err("No Google Analytics account key set in configuration"); return; } printf("<script type=\"text/javascript\">"); printf("var _gaq = _gaq || [];"); printf("_gaq.push(['_setAccount', '%s']);", config::get('ganalytics.account')); printf("_gaq.push(['_setDomainName', '%s']);", request::getDomain()); printf("_gaq.push(['_trackPageview']);"); printf("</script>"); printf("<script type=\"text/javascript\"> (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script>"); }
public function addAction() { $question = $this->_getParam('question'); $question = Zend_Filter::filterStatic($question, 'StripTags'); $question = Zend_Filter::filterStatic($question, 'StringTrim'); if (!empty($question)) { $poll = new Poll_Question(); $poll->setTitle($question); $poll->save(); $this->_helper->json(array("success" => true, 'id' => $poll->getId())); } else { logger::err("Poll_Plugin: Could not create poll, question must be defined"); $this->_helper->json(array("success" => false)); } }
/** * Hook called when maintenance script is called */ public function maintenance() { if (self::isInstalled()) { $currentHour = date("H", time()); $configArray = self::getSearchConfigArray(); //Frontend recrawl $lastStarted = $configArray['search']['frontend']['crawler']['started']; $lastFinished = $configArray['search']['frontend']['crawler']['finished']; $running = $configArray['search']['frontend']['crawler']['running']; $aDayAgo = time() - 24 * 60 * 60; $forceStart = $configArray['search']['frontend']['crawler']['forceStart']; if ($configArray['search']['frontend']['enabled'] and (!$running and $lastStarted <= $aDayAgo and $currentHour > 1 and $currentHour < 3 or $forceStart)) { logger::debug("starting frontend recrawl..."); $this->frontendCrawl($configArray); SearchPhp_Tool::generateSitemap(); } else { if ($running and $lastFinished <= $aDayAgo) { //there seems to be a problem if ($lastFinished <= $aDayAgo) { logger::err("Search_PluginPhp: There seems to be a problem with the search crawler! Trying to stop it."); } $this->stopFrontendCrawler(false, false); } } } else { logger::debug("SearchPhp Plugin is not installed - no maintaince to do for this plugin."); } }
public static function runIndexer($index_name = null) { if (is_null($index_name)) { $index_name = "--all"; } $lockfile = SPHINX_VAR . DIRECTORY_SEPARATOR . "lock.txt"; $output = array(); try { $indexer = SphinxSearch_Config_Plugin::getValue("path", "indexer"); } catch (Exception $e) { $indexer = "/usr/bin/indexer"; } if (!(is_file($indexer) && is_executable($indexer))) { $message = "SphinxSearch Indexer could not be executed at " . $indexer; logger::err($message); $output[] = $message; $return_var = 1; } else { $fp = @fopen($lockfile, "a+"); if ($fp === false) { $message = "SphinxSearch Indexer could open lockfile " . $lockfile; logger::err($message); $output[] = $message; $return_var = 1; } else { if (flock($fp, LOCK_EX | LOCK_NB)) { logger::debug("SphinxSearch Indexer locked with " . $lockfile); ftruncate($fp, 0); fwrite($fp, getmypid()); fflush($fp); $return_var = null; exec("{$indexer} --config " . SPHINX_VAR . DIRECTORY_SEPARATOR . "sphinx.conf " . $index_name . (self::isSearchdRunning() ? " --rotate " : ""), $output, $return_var); if ($return_var == 0) { SphinxSearch_Config_Plugin::setValue("indexer", "lastrun", time()); } flock($fp, LOCK_UN); // release the lock logger::debug("SphinxSearch Indexer unlocked" . $lockfile); } else { $message = "SphinxSearch Indexer is not executed: locked with " . $lockfile; logger::err($message); $output[] = $message; $return_var = 1; } fclose($fp); } } return array("output" => implode("\n", $output), "return_var" => $return_var); }