public function saveConfiguration(Gpf_Plugins_EngineSettings $configuration) { if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('Writing configuration: ' . print_r($configuration, true)); } $this->setSetting(self::CONFIGURATION, serialize($configuration)); }
protected function execute() { Gpf_Log::info('Executing Currency updater task'); $this->updateDailyCurrencies(); $this->setDone(); Gpf_Log::info('End of Currency updater task'); }
public function sendNewUserSignupDeclinedMail(Pap_Common_User $user, $recipient) { if (Gpf_Settings::get(Pap_Settings::AFF_NOTOFICATION_SIGNUP_APPROVED_DECLINED) == Gpf::NO) { Gpf_Log::info('Sending approval/declined mails to affiliate was disabled'); return; } $signupMail = new Pap_Mail_NewUserSignupDeclined(); $signupMail->setUser($user); $signupMail->addRecipient($recipient); $signupMail->sendNow(); }
private function handleError($sth) { if ($sth->getErrorCode() == self::CR_SERVER_GONE_ERROR) { Gpf_Log::disableType(Gpf_Log_LoggerDatabase::TYPE); Gpf_Log::info($this->_sys('MySql server has gone away: Reconnecting...')); Gpf_Log::enableAllTypes(); throw new Gpf_DbEngine_ConnectionGoneException($this->_sys('MySql server has gone away.')); } Gpf_Log_Benchmark::end(self::BENCHMARK_EXECUTE, "SQL ERROR: " . $sth->getStatement()); $this->resetFailedConnectionsCount(); throw new Gpf_DbEngine_Driver_Mysql_SqlException($sth->getStatement(), $sth->getErrorMessage(), $sth->getErrorCode()); }
/** * Execute request to CPanel * * @param $path CPanel command path * @param $params Array of parameters, which input to CPanel command * @return SimpleXMLElement */ protected function execute($path, $params = array()) { $client = new Gpf_Net_Http_Client(); $request = new Gpf_Net_Http_Request(); $url = ($this->useSsl ? 'https://' : 'http://') . $this->host . ':' . $this->port . $path; Gpf_Log::info('Request URL: ' . $url); $query = ''; foreach ($params as $name => $value) { $query .= '&' . $name . '=' . urlencode($value); } Gpf_Log::info('Request params: ' . $query); $request->setUrl($url . (strlen($query) ? '?' : '') . ltrim($query, '&')); $request->setHttpUser($this->user); $request->setHttpPassword($this->passwd); Gpf_Log::info("Executing HTTP request: " . $request->toString()); return $this->parseResult($client->execute($request)); }
/** * returns commission group for user. * If it doesn't exists, it will create default commission group and assign user to it. * * @param string $userId * @return string or false */ public function getCommissionGroupForUser($userId) { $commGroupId = $this->checkUserIsInCampaign($userId); if($commGroupId != false) { return $commGroupId; } if($this->getCampaignType() == Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC) { $defaultCommGroupId = $this->getDefaultCommissionGroup(); return $defaultCommGroupId; } Gpf_Log::info($this->_('No commissiongroup recognized - this is just hint: This campaign has type: %s. If, problem occured during commissiongrup recognition, you shoud check if this type is correct.', $this->getCampaignType())); return false; }
private function writeSettingToFile(Gpf_Io_File $file) { $file->setFilePermissions(0777); if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('(writeSettingsValues - before write) file ' . @$file->getFileName() . ' size: ' . @$file->getSize() . ', permissions: ' . @$file->getFilePermissions() . ', owner: ' . @$file->getFileOwner()); } $file->open('w'); $text = '<?php /*' . "\n"; foreach ($this->parameters as $key => $value) { $text .= $key . '=' . $value . "\r\n"; } $text .= '*/ ?>'; $file->write($text); $file->close(); if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('(writeSettingsValues - after write) file ' . @$file->getFileName() . ' size: ' . @$file->getSize() . ', permissions: ' . @$file->getFilePermissions() . ', owner: ' . @$file->getFileOwner()); } }
/** * @throws Gpf_Tasks_LongTaskInterrupt */ public function importCSV(){ Gpf_Log::info('Importing file' . $this->form->getFieldValue(self::FILENAME)); $transactionHeader = $this->getHeader(); $rowsList = $this->getDataFromFile(); $this->cache = new Pap_Merchants_Transaction_TransactionsImportCache(); $i = 0; while($this->row = $rowsList->readArray()) { $this->interruptIfMemoryFull(); if ($this->isPending($i, $this->_('Importing transactions'))) { if ($i == 0 && $this->form->getFieldValue(self::SKIP_FIRST_ROW) == Gpf::YES) { Gpf_Log::info('Skipping first row'); $this->row[]='errorMessage'; $this->errorHeader = $this->row; $i++; continue; } if(count($this->row)<=1) { Gpf_Log::info('Skipping empty row ' . $i); $i++; continue; } $transaction = $this->getTransactionObject(); try { $this->saveTransaction($transaction, $transactionHeader, $this->row); } catch (Gpf_DbEngine_DuplicateEntryException $e) { $this->addError($this->_('Duplicate row')); } catch (Gpf_Exception $e){ $this->addError($this->_($e->getMessage())); } $this->setDone(); } $i++; } Gpf_Log::info('Import complete'); if ($this->errorFile !== null) { $this->errorFile->close(); if($this->errorFile->isExists()) { Gpf_Log::warning('Error occured during import, please check ' . Gpf_Paths::getInstance()->getCacheAccountDirectory().self::ERROR_FILE); $this->form->setInfoMessage("Import was not successful<br /><a href='" . Gpf_Paths::getInstance()->getCacheAccountDirectory().self::ERROR_FILE. "'>" . $this->_("Download unimported .csv") . "</a><br /> (error messages are at the end of each line)"); } else{ $this->form->setInfoMessage("Import was successful"); } } else{ $this->form->setInfoMessage("Import was successful"); } $this->form->setErrorMessage($this->_('Import was not successful.')); $this->form->setSuccessful(); $this->cache->clearCache(); return $this->form; }
public function logout() { Gpf_Log::info($this->_sys('Logged out user %s', $this->getUsername())); Gpf_Db_LoginHistory::logLogout(); $this->clearRememberMeCookie(); Gpf_Session::getInstance()->destroy(); Gpf_Plugins_Engine::extensionPoint('Gpf_Auth_User.logout', $this); }
private function callFunction($functionName, $params) { Gpf_Log::info('GetResponse - callFunction ' . $functionName . ', params: ' . print_r($params, true)); try { $result = $this->client->$functionName($this->apiKey, $params); Gpf_Log::info('GetResponse - callFunction result: ' . print_r($result, true)); return $result; } catch (Exception $e) { $this->logError('GetResponse Exception - Failed to signup affiliate to GetResponse newsletter with error: ' . $e->getMessage()); } }
protected function setAuthenticationSucesful(Gpf_Rpc_Form $loginForm, Gpf_Auth_User $authUser) { try { if ($loginForm->getFieldValue(self::REMEMBER_ME) == Gpf::YES) { $authUser->saveRememberMeCookie(); } } catch (Gpf_Exception $e) { } $authUser->setLanguage($loginForm->getFieldValue(self::LANGUAGE)); Gpf_Db_UserAttribute::saveAttribute(self::LANGUAGE, $loginForm->getFieldValue(self::LANGUAGE), $authUser->getAccountUserId()); Gpf_Db_UserAttribute::saveAttribute(self::TIME_OFFSET, Gpf_Session::getInstance()->getTimeOffset(), $authUser->getAccountUserId()); Gpf_Http::setCookie(self::COOKIE_LANGUAGE, $authUser->getLanguage(), time() + 20000000, '/'); $loginForm->addField("S", Gpf_Session::getInstance()->getId()); $loginForm->setInfoMessage($this->_("User authenticated. Logging in.")); Gpf_Log::info($this->_sys("User %s authenticated. Logging in.", $authUser->getUsername())); }
private function setActivePlugins(Gpf_Data_RecordSet $inputResult) { $actualConfiguration = Gpf_Plugins_Engine::getInstance()->getConfiguration(); if ($actualConfiguration === null) { if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::error('Plugin engine configuration is incorrect'); } throw new Gpf_Exception("Plugin engine configuration is incorrect"); } foreach ($inputResult as $record) { $codename = $record->get(Gpf_Plugins_Definition::CODE); if ($actualConfiguration->isPluginActive($codename)) { if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('setActivePlugins with plugin: ' . $codename . ' - activating'); } $record->set(Gpf_Plugins_Definition::ACTIVE, 'Y'); } else { if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('setActivePlugins with plugin: ' . $codename . ' - deactivating'); } $record->set(Gpf_Plugins_Definition::ACTIVE, 'N'); } } return $inputResult; }
/** * @param Gpf_Plugins_Definition $plugin * @param boolean $activate */ protected function activatePlugin(Gpf_Plugins_Definition $plugin, $activate) { if ($activate) { $plugin->check(); $plugin->onActivate(); if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('Gpf_Plugins_Engine/activatePlugin: ' . $plugin->getName() . ' - activating'); } // add to active plugins array $activePluginsCodes = $this->configuration->getActivePlugins(); if (!in_array($plugin->getCodeName(), $activePluginsCodes)) { $activePluginsCodes[$plugin->getCodeName()] = $plugin->getCodeName(); } } else { $plugin->onDeactivate(); // remove from active plugins array if (defined('ENABLE_ENGINECONFIG_LOG')) { Gpf_Log::info('Gpf_Plugins_Engine/activatePlugin: ' . $plugin->getName() . ' - deactivating'); } $activePluginsCodes = $this->configuration->getActivePlugins(); if (array_key_exists($plugin->getCodeName(), $activePluginsCodes)) { unset($activePluginsCodes[$plugin->getCodeName()]); } } $this->configuration = $this->generateConfiguration($activePluginsCodes); }
protected function info($message) { Gpf_Log::info($message, 'HTTP'); }
/** * @return Pap_Common_Banner */ private function getBanner($bannerId, $userId = null, $channelId = '') { $bannerFactory = new Pap_Common_Banner_Factory(); $banner = $bannerFactory->getBanner($bannerId); if(isset($_REQUEST[Pap_Db_Table_CachedBanners::DYNAMIC_LINK])) { $banner->setDynamicLink($_REQUEST[Pap_Db_Table_CachedBanners::DYNAMIC_LINK]); } if ($channelId == '' || $userId == null || $userId == '') { return $banner; } try { $banner->setChannel($this->getChannel($userId, $channelId)); } catch (Gpf_Exception $e) { Gpf_Log::info('Invalid channel '.$channelId.' used in banner '.$bannerId.' for user '.$userId.': '. $e->getMessage()); } return $banner; }
/** * * @param Gpf_Net_Server_Http_Request $request * @return Gpf_Net_Server_Http_Response */ public function handle(Gpf_Net_Server_Http_Request $request) { $file = new Gpf_Io_File($this->getFileName($request->getPath())); $fileETag = $this->computeEtag($file); Gpf_Log::debug($request->toString()); if ($this->isCacheableFile($file) && $request->ifNoneMatch($fileETag)) { $response = new Gpf_Net_Server_Http_Response(304, $file); $response->setConnection('Keep-Alive'); $response->setBody("Not Modified"); $response->setETag($fileETag); Gpf_Log::debug($this->_sys("Resource not modified, returned 304 for %s", $request->getPath())); return $response; } //TODO load file from memory cache if available and not from file // - but I'm not sure if file cache will help - it can just use quite huge amount of server memory try { $file->open(); } catch (Gpf_Exception $e) { $response = new Gpf_Net_Server_Http_Response(404); $response->setBody('File not found'); Gpf_Log::info($e->getMessage()); return $response; } $response = new Gpf_Net_Server_Http_StreamResponse(200, $file); $response->setConnection('Keep-Alive'); $response->setContentType(self::getContentType(self::getFileExtension($request->getPath()))); $response->setContentLength($file->getSize()); if ($this->isCacheableFile($file)) { $response->setETag($fileETag); } Gpf_Log::debug($this->_sys("Return static file %s" . $request->getPath())); return $response; }
public function firstTimeUserApprovedEmail(Pap_Affiliates_User $user) { if ($this->isUserAutomaticallyRegistered($user) && $this->getNumberOfSalesActions($user->getId()) > 0) { Gpf_Log::info('AutoRegisteringAffiliates - firstTimeUserApprovedEmailAndSalesExists - sendApprovedAffiliateFirstSaleEmail to userid: ' . $user->getId() . ' (' . $user->getUserName() .')' ); $this->sendApprovedAffiliateFirstSaleEmail($user); } }
protected function processCsvList($csv) { $list = $this->csvStringToArray($csv, ','); if (count($list) == 0) { Gpf_Log::info('No rebills found for period: ' . $this->getTimeProgress()); return; } foreach ($list as $item) { $time = new Gpf_DateTime(); Gpf_Log::debug('CCBILL LOG: ' . print_r($item, true)); if ($item[0] == 'REBILL') { $this->processRebill($item); } else { Gpf_Log::debug('Unsupported row: ' . print_r($item, true)); } } }