/**
  * @see interface_admin_systemtast::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("stats")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     $strReturn = "";
     $objWorker = new class_module_stats_worker("");
     $objWorker->hostnameLookupResetHostnames();
     $strReturn .= $this->objToolkit->getTextRow($this->getLang("worker_lookupReset_end"));
     return $strReturn;
 }
 /**
  * This generic method is called in case of dispatched events.
  * The first param is the name of the event, the second argument is an array of
  * event-specific arguments.
  * Make sure to return a matching boolean value, indicating if the event-process was successful or not. The event source may
  * depend on a valid return value.
  *
  * @param string $strEventIdentifier
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventIdentifier, array $arrArguments)
 {
     /** @var class_request_entrypoint_enum $objEntrypoint */
     $objEntrypoint = $arrArguments[0];
     if ($objEntrypoint->equals(class_request_entrypoint_enum::INDEX()) && class_carrier::getInstance()->getParam("admin") == "") {
         //process stats request
         $objStats = class_module_system_module::getModuleByName("stats");
         if ($objStats != null) {
             //Collect Data
             $objLanguage = new class_module_languages_language();
             $objStats = new class_module_stats_worker();
             $objStats->createStatsEntry(getServer("REMOTE_ADDR"), time(), class_carrier::getInstance()->getParam("page"), rtrim(getServer("HTTP_REFERER"), "/"), getServer("HTTP_USER_AGENT"), $objLanguage->getPortalLanguage());
         }
     }
 }
 /**
  * @see interface_admin_systemtast::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("stats")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     $strReturn = "";
     $objWorker = new class_module_stats_worker();
     //determin the number of ips to lookup
     $arrIpToLookup = $objWorker->getArrayOfIp2cLookups();
     if (count($arrIpToLookup) == 0) {
         return $this->objToolkit->getTextRow($this->getLang("worker_lookup_end"));
     }
     //check, if we did anything before
     if ($this->getParam("totalCount") == "") {
         $this->setParam("totalCount", $objWorker->getNumberOfIp2cLookups());
     }
     $strReturn .= $this->objToolkit->getTextRow($this->getLang("intro_worker_lookupip2c") . $this->getParam("totalCount"));
     //Lookup 10 Ips an load the page again
     for ($intI = 0; $intI < 10; $intI++) {
         if (isset($arrIpToLookup[$intI])) {
             $strIP = $arrIpToLookup[$intI]["stats_ip"];
             try {
                 $objRemoteloader = new class_remoteloader();
                 $objRemoteloader->setStrHost($this->strIp2cServer);
                 $objRemoteloader->setStrQueryParams("/ip2c.php?ip=" . urlencode($strIP) . "&domain=" . urlencode(_webpath_) . "&checksum=" . md5(urldecode(_webpath_) . $strIP));
                 $strCountry = $objRemoteloader->getRemoteContent();
             } catch (class_exception $objExeption) {
                 $strCountry = "n.a.";
             }
             $objWorker->saveIp2CountryRecord($strIP, $strCountry);
         }
     }
     //and Create a small progress-info
     $intTotal = $this->getParam("totalCount");
     $floatOnePercent = 100 / $intTotal;
     //and multiply it with the alredy looked up ips
     $intLookupsDone = ((int) $intTotal - $objWorker->getNumberOfIp2cLookups()) * $floatOnePercent;
     $intLookupsDone = round($intLookupsDone, 2);
     if ($intLookupsDone < 0) {
         $intLookupsDone = 0;
     }
     $this->setStrProgressInformation($strReturn);
     $this->setStrReloadParam("&totalCount=" . $this->getParam("totalCount"));
     return $intLookupsDone;
 }
 /**
  * @see interface_admin_systemtast::executeTask()
  * @return string
  */
 public function executeTask()
 {
     if (!class_module_system_module::getModuleByName("stats")->rightEdit()) {
         return $this->getLang("commons_error_permissions");
     }
     $strMessage = "";
     $objWorker = new class_module_stats_worker("");
     //Load all IPs to lookup
     $arrIpToLookup = $objWorker->hostnameLookupIpsToLookup();
     if (count($arrIpToLookup) == 0) {
         return $this->objToolkit->getTextRow($this->getLang("worker_lookup_end"));
     }
     //check, if we did anything before
     if ($this->getParam("totalCount") == "") {
         $this->setParam("totalCount", count($arrIpToLookup));
     }
     $strMessage .= $this->objToolkit->getTextRow($this->getLang("intro_worker_lookup") . $this->getParam("totalCount"));
     //Lookup 10 IPs an load the page again
     for ($intI = 0; $intI < 10; $intI++) {
         if (isset($arrIpToLookup[$intI])) {
             $strIP = $arrIpToLookup[$intI]["stats_ip"];
             $strHostname = gethostbyaddr($strIP);
             if ($strHostname != $strIP) {
                 //Hit. So save it to databse
                 $objWorker->hostnameLookupSaveHostname($strHostname, $strIP);
             } else {
                 //Mark the record as already touched
                 $objWorker->hostnameLookupSaveHostname("na", $strIP);
             }
         }
     }
     //and create a small progress-info
     $intTotal = $this->getParam("totalCount");
     $floatOnePercent = 100 / $intTotal;
     //and multiply it with the alredy looked up IPs
     $intLookupsDone = ((int) $intTotal - count($arrIpToLookup)) * $floatOnePercent;
     $intLookupsDone = round($intLookupsDone, 2);
     if ($intLookupsDone < 0) {
         $intLookupsDone = 0;
     }
     $this->setStrProgressInformation($strMessage);
     $this->setStrReloadParam("&totalCount=" . $this->getParam("totalCount"));
     return $intLookupsDone;
 }