/** * back up retrived files that were processed to a third patry path. * @param \Billrun_Processor $processor the processor instace contain the current processed file data. */ public function afterProcessorStore(\Billrun_Processor $processor) { if ($processor->getType() != $this->getName()) { return; } $path = Billrun_Factory::config()->getConfigValue($this->getName() . '.thirdparty.backup_path', false, 'string'); if (!$path) { return; } if ($processor->retrievedHostname) { $path = $path . DIRECTORY_SEPARATOR . $processor->retrievedHostname; } Billrun_Factory::log()->log("Saving file to third party at : {$path}", Zend_Log::DEBUG); if (!$processor->backupToPath($path, true)) { Billrun_Factory::log()->log("Couldn't save file to third patry path at : {$path}", Zend_Log::ERR); } }
/** * TODO * @param \Billrun_Processor $processor * @return type */ public function afterProcessorStore($processor) { if ($processor->getType() != "ggsn") { return; } Billrun_Factory::log('Plugin fraud afterProcessorStore', Zend_Log::INFO); $runAsync = Billrun_Factory::config()->getConfigValue('fraud.runAsync', 1); if (function_exists("pcntl_fork") && $runAsync && -1 !== ($pid = pcntl_fork())) { if ($pid == 0) { Billrun_Util::resetForkProcess(); Billrun_Factory::log('Plugin fraud::afterProcessorStore run it in async mode', Zend_Log::INFO); $this->insertRoamingGgsn($processor->getData()['data']); Billrun_Factory::log('Plugin fraud::afterProcessorStore async mode done.', Zend_Log::INFO); exit; // exit from child process after finish } } else { Billrun_Factory::log('Plugin fraud::afterProcessorStore runing in sync mode', Zend_Log::INFO); $this->insertRoamingGgsn($processor->getData()['data']); } Billrun_Factory::log('Plugin fraud afterProcessorStore was ended', Zend_Log::INFO); }
/** * move zip files to backup path after the processing was done * @param Billrun_Processor $processor the proce * @param string $file_path the path of the current processing file. */ public function afterProcessorBackup($processor, &$file_path) { if ($processor->getType() != $this->getName()) { return; } $path = Billrun_Factory::config()->getConfigValue($this->getName() . '.processor.zip_move_path', false, 'string'); if (!$path) { return; } if ($processor->retrievedHostname) { $path = $path . DIRECTORY_SEPARATOR . $processor->retrievedHostname; } $path .= DIRECTORY_SEPARATOR . date("Ym"); if (!file_exists($path)) { Billrun_Factory::log()->log("Creating Directory : {$path}", Zend_Log::DEBUG); mkdir($path, 0777, true); } $srcPath = $file_path . ".zip"; if (file_exists($srcPath)) { Billrun_Factory::log()->log("Saving zip file to : {$path}", Zend_Log::DEBUG); if (!rename($srcPath, $path . DIRECTORY_SEPARATOR . basename($srcPath))) { Billrun_Factory::log()->log(" Failed when trying to save file : " . basename($srcPath) . " to third party path : {$path}", Zend_Log::ERR); } } }