private function __construct($accountId = null) { if ($accountId == null) { throw new Gpf_Exception("Account Id cannot be null"); } $this->settingsDirectory = Gpf_Paths::getInstance()->getRealAccountConfigDirectoryPath(); $this->file = $this->settingsDirectory . self::FILE_NAME; }
public function loadNoRpc(Gpf_Rpc_Params $params, $useParent = true) { $data = new Gpf_Rpc_Data($params); $signupFormPanel = new Pap_Affiliates_Promo_SignupFormPanel(); $addScript = ''; if ($useParent) { $parentUserId = '<input type="hidden" name="parentuserid"' . ' value="' . Gpf_Session::getAuthUser()->getPapUserId() . '" />'; } else { $parentUserId = '<input type="hidden" name="parentuserid" id="parentuserid" value="" />'; $scriptUrl = Gpf_Paths::getInstance()->getFullScriptsUrl().'salejs.php'; $addScript = '<script id="pap_x2s6df8d" src="'.$scriptUrl.'" type="text/javascript"> </script> <script type="text/javascript"> PostAffTracker.writeAffiliateToCustomField(\'parentuserid\'); </script>'; } if ($signupFormPanel->containsId("parentuserid")) { $signupFormPanel->add($parentUserId, "parentuserid"); } else { $signupFormPanel->addWidget($parentUserId, "parentuserid"); } $signupFormPanelHtml = '<form action="' . self::getSignupScriptUrl($useParent) . '" method="post">' . $signupFormPanel->render() . '</form>' . $addScript; $data->setValue("formSource", $signupFormPanelHtml); $data->setValue("formPreview", $signupFormPanelHtml); return $data; }
/** * @return Gpf_Lang_Languages */ public static function getInstance($ignoreInstall = false) { if (Gpf_Paths::getInstance()->isInstallModeActive() && !$ignoreInstall) { return new Gpf_Lang_InstallLanguages(); } return new Gpf_Lang_Languages(); }
/** * Load javascript library required for google gears * * @param Gpf_Contexts_Module $context */ public function initJsResources(Gpf_Contexts_Module $context) { //install mode will not connect google gears if (Gpf_Paths::getInstance()->isInstallModeActive()) { return; } try { $file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountConfigDirectoryPath() . GoogleGears_Definition::getManifestFileName()); if (!$file->isExists()) { $def = new GoogleGears_Definition(); $def->generateManifest(); } $context->addJsResource(Gpf_Paths::getInstance()->getFrameworkPluginsDirectoryUrl() . 'GoogleGears/gears_init.js'); $manifestUrl = Gpf_Paths::getInstance()->getBaseServerUrl() . Gpf_Paths::getInstance()->getAccountDirectoryRelativePath() . Gpf_Paths::CONFIG_DIR . GoogleGears_Definition::getManifestFileName(); $context->addJsScript("try { var localServer = google.gears.factory.create('beta.localserver'); var store = localServer.createManagedStore('GwtPHP'); store.manifestUrl = '$manifestUrl'; store.checkForUpdate(); store.enabled = true; } catch (e) {} "); } catch (Gpf_Exception $e) { } }
protected function loadSetting() { parent::loadSetting(); $this->addSetting(Pap_Settings::AFFILIATE_LOGOUT_URL); $this->addSetting(Pap_Settings::AFFILIATE_AFTER_LOGIN_SCREEN); $this->addSetting(Pap_Settings::AFFILIATE_AFTER_LOGIN_SCREEN_MAXIMIZE); $this->addSetting(Pap_Settings::SUPPORT_VAT_SETTING_NAME); $this->addValue('signupSubaffiliatesLink', Pap_Affiliates_Promo_SignupForm::getSignupScriptUrl()); $this->addValue('signupPageUrl', Gpf_Paths::getAffiliateSignupUrl()); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_ON_NEW_SALE_ENABLED_SETTING_NAME); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_ENABLED_SETTING_NAME); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_ON_SUBAFF_SIGNUP_ENABLED_SETTING_NAME); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_ON_SUBAFF_SALE_ENABLED_SETTING_NAME); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_ON_DIRECT_LINK_ENABLED); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_DAILY_REPORT_ENABLED); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_WEEKLY_REPORT_ENABLED); $this->addSetting(Pap_Settings::NOTIFICATION_WEEKLY_REPORT_SENT_ON); $this->addSetting(Pap_Settings::NOTIFICATION_WEEKLY_REPORT_START_DAY); $this->addSetting(Pap_Settings::AFF_NOTIFICATION_MONTHLY_REPORT_ENABLED); $this->addSetting(Pap_Settings::NOTIFICATION_MONTHLY_REPORT_SENT_ON); $this->addSetting(Pap_Settings::AFFILIATE_CANNOT_CHANGE_HIS_USERNAME); $this->addSetting(Pap_Settings::MAIL_TO_FRIEND_ALLOW_TO_USE_SYSTEM_EMAIL); }
/** * @service report_problem write * * @param Gpf_Rpc_Params $params * @return Gpf_Rpc_Form */ public function report(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $subject = 'PAP4: '.$form->getFieldValue('subject'); $message = 'License: '.$form->getFieldValue('licenseId').'<br>'. 'Product: <b>'.Gpf_Settings::get(Pap_Settings::BRANDING_TEXT_POST_AFFILIATE_PRO).' '.Gpf_Settings::get(Gpf_Settings_Gpf::VARIATION).'</b><br>'. 'Version: <b>'.Gpf_Application::getInstance()->getVersion().'</b><br>'. 'Url: <a href="'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'">'.Gpf_Paths::getInstance()->getFullBaseServerUrl().'</a><br>'. '-------------------------------------------------------------------------------<br>'. $form->getFieldValue('message'); $mail = new Gpf_Db_Mail(); $mail->setSubject($subject); $mail->setHtmlBody($message); $mail->setFromMail($form->getFieldValue('email')); $mail->setRecipients("*****@*****.**"); try { $mail->insert(); $mail->scheduleNow(true); $form->setInfoMessage($this->_("Email sent")); } catch (Exception $e) { $form->setErrorMessage($this->_("Error while sending mail")); } return $form; }
public function __construct($url = '') { $this->url = $url; if (strlen($url) <= 0) { $this->url = Gpf_Paths::getInstance()->getFullBaseServerUrl(); } $this->stripProtocolAndWWW(); }
public static function getDbDirPath($application) { $basePath = Gpf_Paths::getInstance()->getTopPath(); if ($application == self::GPF) { $basePath = Gpf_Paths::getInstance()->getFrameworkPath(); } return $basePath . Gpf_Paths::INSTALL_DIR . 'db/' . $application . '/'; }
public function execute() { $dir = new Gpf_Io_DirectoryIterator(Gpf_Paths::getInstance()->getAccountsPath(), '', true); foreach ($dir as $fullPath => $filename) { if ($filename == 'engineconfig.php') { $file = new Gpf_Io_File($fullPath); $file->delete(); } } }
protected function saveUploadedFile() { $file = parent::saveUploadedFile(); $file = str_replace('../' . Gpf_Paths::getInstance()->getAccountDirectoryRelativePath(), Gpf_Paths::getInstance()->getFullAccountServerUrl(), $file); return $file; }
public function __construct() { $this->file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountPath() . self::GEOIP_FILE); if (!$this->file->isExists()) { $this->file = new Gpf_Io_File(Gpf_Paths::getInstance()->getAccountsPath() . self::GEOIP_FILE); if (!$this->file->isExists()) { $this->file = new Gpf_Io_File(Gpf_Paths::getInstance()->getFrameworkPath() . 'plugins/GeoIp/' . self::GEOIP_FILE); } } }
/** * Start main import procedure */ public function import() { $dirs = array(); $dirs = array_merge($dirs, Gpf_Paths::getInstance()->getIncludePaths()); $dirs = array_merge($dirs, Gpf_Paths::getInstance()->getThemesTemplatePaths()); $dirs[] = Gpf_Paths::getInstance()->getFrameworkTemplatesPath(); $dirs = array_merge($dirs, Gpf_Paths::getInstance()->getClientPaths()); $this->importDirectories($dirs); }
public static function existsClass($className) { foreach (Gpf_Paths::getInstance()->getIncludePaths() as $includePath) { $fileName = self::existsClassName($className, $includePath); if($fileName) { return $fileName; } } return false; }
private function existTemplate($templateName) { foreach (Gpf_Paths::getInstance()->getTemplateSearchPaths() as $templateDir) { if (Gpf_Io_File::isFileExists($templateDir . $templateName . ".tpl")) { return true; } } return false; }
public function onActivate() { $zipDir = new Gpf_Io_File(Gpf_Paths::getInstance()->getFullAccountPath().Pap_Features_ZipBanner_Unziper::ZIP_DIR); if ($zipDir->isExists() === false) { $zipDir->mkdir(); } $cacheZipDir = new Gpf_Io_File(Gpf_Paths::getInstance()->getCacheAccountDirectory().'zip/'); if ($cacheZipDir->isExists() === false) { $cacheZipDir->mkdir(); } }
public function __construct($accountId = null) { $this->accountId = $accountId; if ($accountId === null) { $settingsDirectory = Gpf_Paths::getInstance()->getAccountsPath(); } else { $settingsDirectory = Gpf_Paths::getInstance()->getAccountsPath() . $accountId . '/'; } parent::__construct($settingsDirectory . self::SETTING_FILE_NAME); }
/** * Method will be called, when plugin is activated. e.g. create some tables required by plugin. * * @throws Gpf_Exception when plugin can not be activated */ public function onActivate() { if (Gpf_Paths::getInstance()->isDevelopementVersion()) { return; } if(!Gpf_Php::isFunctionEnabled('iconv')) { throw new Gpf_Exception($this->_('Please enable "iconv" extension.')); } if(!Gpf_Php::isExtensionLoaded('ionCube Loader')) { throw new Gpf_Exception($this->_('Please enable "ionCube Loader" extension.')); } }
private function getBaseCode(Pap_Common_User $user, $fileName = 'hover.php', $flags = '') { $url = Gpf_Paths::getInstance()->getFullBaseServerUrl() . "include/Pap/Features/HoverBanner/LyteBox/"; $code = '<script type="text/javascript" src="'. $url . 'lytebox.js"></script> <link rel="stylesheet" href="'. $url . 'lytebox.css" type="text/css" media="screen" /> <div id="' . $this->getId() . '" rel="lyteframe" rev="width: {$width}px; height: {$height}px; scrolling: no;" href="'. Gpf_Paths::getInstance()->getFullScriptsUrl() . $fileName . '?'.Gpf_Settings::get(Pap_Settings::PARAM_NAME_USER_ID).'='.$user->getId(). '&'.Gpf_Settings::get(Pap_Settings::PARAM_NAME_BANNER_ID).'='.$this->getId() . '"></div>'; return $this->replaceWidthHeightConstants($code, $flags); }
/** * Upload file to server * * @param Gpf_Rpc_Params $params * @service db_file write * @return Gpf_Rpc_Form */ public function upload(Gpf_Rpc_Params $params) { $cacheExportDirectory = Gpf_Paths::CACHE_DIRECTORY . Gpf_Csv_ImportExportService::EXPORT_DIRECTORY; $this->clearTempDirectory(Gpf_Paths::getInstance()->getAccountDirectoryPath() . $cacheExportDirectory); $this->setRelativeUploadPath(Gpf_Paths::getInstance()->getAccountDirectoryRelativePath() . $cacheExportDirectory); $form = parent::upload($params); $form->setField("filename", Gpf_Paths::getInstance()->getFullAccountServerUrl() . $cacheExportDirectory . $this->getName()); $form->setField("fileid", Gpf_Paths::getInstance()->getAccountPath() . $cacheExportDirectory . $this->getName()); $form->setField("filesize", $this->size); $form->setField("filetype", $this->type); return $form; }
public static function getBannerScriptUrl($userId, $bannerId, $channelId = null, $parentBannerId = null){ $url = Gpf_Paths::getInstance()->getFullScriptsUrl().'banner.php'. '?'; $url .= Gpf_Settings::get(Pap_Settings::PARAM_NAME_USER_ID).'='.$userId; $url .= '&'.Gpf_Settings::get(Pap_Settings::PARAM_NAME_BANNER_ID).'='.$bannerId; if($channelId != null){ $url .= '&'.Pap_Tracking_Request::getChannelParamName().'='.$channelId; } if($parentBannerId != null) { $url .= '&'.Pap_Tracking_Request::getRotatorBannerParamName().'='.$parentBannerId; } return $url; }
/** * Compute active languages recordset from install directory language files * * @return Gpf_Data_IndexedRecordSet */ public function getActiveLanguagesNoRpc() { $result = new Gpf_Data_IndexedRecordSet('code'); $result->setHeader(array(Gpf_Db_Table_Languages::CODE, Gpf_Db_Table_Languages::NAME, Gpf_Db_Table_Languages::ENGLISH_NAME, Gpf_Db_Table_Languages::IS_DEFAULT)); $langCacheDirectory = Gpf_Paths::getInstance()->getInstallDirectoryPath() . Gpf_Paths::CACHE_DIRECTORY . Gpf_Lang_Dictionary::LANGUAGE_DIRECTORY; foreach (new Gpf_Io_DirectoryIterator($langCacheDirectory) as $file) { if (preg_match('!^' . Gpf_Application::getInstance()->getCode() . '_(.+)\\.s\\.php$!', $file, $matches)) { $language = $this->loadLanguage($matches[1]); $result->add(array($matches[1], $language->getName(), $language->getEnglishName(), Gpf::NO)); } } return $result; }
public function getModule(Gpf_Io_File $file) { $fileName = str_replace(strtolower(Gpf_Paths::getInstance()->getTopPath()), '', strtolower($file->getFileName())); if (strpos($fileName, 'merchant') !== false) { return 'merchant'; } if (strpos($fileName, 'affiliate') !== false) { return 'affiliate'; } return ''; }
/** * Generate csv file * * @service import_export export * @param $fields (classNames{className1,className2,..}, delimiter, note) */ public function exportCSV(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $this->codes = $form->getFieldValue("codes"); $this->delimiter = self::getDelimiter($form->getFieldValue("delimiter")); $this->note = $form->getFieldValue("note"); $date = date("Y-m-d_H-i-s"); $this->date = str_replace("_", " ", $date); $fileName = "export_" . $date . "_" . rand() . ".csv"; $filePath = Gpf_Paths::getInstance()->getAccountDirectoryPath() . self::EXPORT_DIRECTORY . $fileName; $this->sendToExportObjects($filePath); $this->writeToExportTable($fileName); $form->setInfoMessage($this->_("Data was successfully exported to file %s", $fileName)); return $form; }
/** * Returns url for popup/popunder */ function getBannerPopupPopunderUrl($user) { $url = Gpf_Paths::getInstance()->getFullScriptsUrl(); if ($this->popType == $this->popBanner) { $banner = $this->bannerFactory->getBanner($this->sourceurl); //$banner->setOtherBannerIdForClickUrl($this->getId()); $url .= "popBanner.php". "?bannerContent=".urlencode($banner->getBannerCode($user, $this->getId())); } else { $url .= "popUrl.php". "?bannerUrl=".urlencode($this->sourceurl); "&clickUrl=".urlencode($this->getClickUrl($user)); } $url .= "&impressionCode=".urlencode($this->getTrackingCode($user)); return $url; }
/** * * @service banners_categories add * @param $fields * @return Gpf_Rpc_Form */ public function add(Gpf_Rpc_Params $params) { $form = parent::add($params); if ($form->isSuccessful() && $form->getFieldValue("code") == "Custom-Page") { try { $templatePaths = Gpf_Paths::getInstance()->getTemplateSearchPaths("affiliates", "", true); $fileName = $templatePaths[0] . $form->getFieldValue("templateName").".tpl"; $file = new Gpf_Io_File($fileName); $file->open('w'); $file->write($form->getFieldValue("templateName").".tpl"); $file->close(); } catch (Exception $e) { $form->setErrorMessage($e->getMessage()); return $form; } } return $form; }
private function getNewDistributionFileName() { $filePreffix = Gpf_Application::getInstance()->getCode() . '_'; $directory = new Gpf_Io_DirectoryIterator(Gpf_Paths::getInstance()->getTopPath() . Gpf_paths::INSTALL_DIR, self::FILE_EXTENSION); $maxVersion = '0'; foreach ($directory as $file) { if (strpos($file, $filePreffix) !== 0) { continue; } $version = substr($file, strlen($filePreffix), strlen($file) - strlen(self::FILE_EXTENSION) - strlen($filePreffix)); if (version_compare($maxVersion, $version) == -1) { $maxVersion = $version; } } if (version_compare($maxVersion, Gpf_Application::getInstance()->getVersion()) <= 0) { return null; } return $filePreffix . $maxVersion . self::FILE_EXTENSION; }
/** * Create new language * * @service language add * @return Gpf_Rpc_Form */ public function add(Gpf_Rpc_Params $params) { $form = new Gpf_Rpc_Form($params); $lang = new Gpf_Db_Language(); $lang->setCode($form->getFieldValue(Gpf_Db_Table_Languages::CODE)); $lang->setAccountId(Gpf_Application::getInstance()->getAccountId()); $lang->setId($lang->generateId()); try { //Load should fail, otherwise it is error - language already exists $lang->load(); $form->setErrorMessage($this->_('Language code %s is already used in your installation', $form->getFieldValue(Gpf_Db_Table_Languages::CODE))); return $form; } catch (Exception $e) { } try { //Load language from default csv file $fileNameDefault = Gpf_Paths::getInstance()->getLanguageInstallDirectory() . Gpf_Application::getInstance()->getCode() . '_' . Gpf_Lang_CsvHandler::DEFAULT_LANGUAGE . '.csv'; $file = new Gpf_Io_Csv_Reader($fileNameDefault, ';', '"', array('source', 'translation', 'type', 'module', 'status', 'customer')); $csvLanguage = new Gpf_Lang_CsvLanguage(); $csvLanguage->loadFromCsvFile($file); $form->fill($lang); $lang->setAccountId(Gpf_Application::getInstance()->getAccountId()); $lang->setId($lang->generateId()); $lang->setActive(true); $lang->setTranslatedPercentage(0); $lang->insert(); //update metadata $csvLanguage->copyMetadataFromDbLanguage($lang); foreach ($csvLanguage->getTranslations() as $translation) { $translation->setStatus(Gpf_Lang_Parser_Translation::STATUS_NOT_TRANSLATED); } //export cache $csvLanguage->exportAccountCache(); } catch (Exception $e) { $form->setErrorMessage($this->_('Failed to create new language: %s', $e->getMessage())); return $form; } $form->setInfoMessage($this->_('New language with code %s created', $form->getFieldValue(Gpf_Db_Table_Languages::CODE))); return $form; }
/** * Returns row data for grid * * @service language read * * @param $filters * @param $limit * @param $offset * @param $sort_col * @param $sort_asc * @param Gpf_Data_RecordSet $columns * @return Gpf_Rpc_Serializable */ public function getRows(Gpf_Rpc_Params $params) { $this->_params = $params; $this->_sortColumn = $params->get('sort_col'); $this->_sortAsc = $params->get('sort_asc'); $this->_requiredColumns = new Gpf_Data_IndexedRecordSet('id'); $this->_requiredColumns->loadFromArray($params->get('columns')); $response = new Gpf_Rpc_Object(); $recordHeader = new Gpf_Data_RecordHeader(); $result = new Gpf_Data_RecordSet(); foreach ($this->getAllViewColumns() as $column) { $result->addColumn($column->get('id')); $recordHeader->add($column->get('id')); } $result->addColumn('id'); $recordHeader->add('id'); $languagesIterator = new Gpf_Io_DirectoryIterator(Gpf_Paths::getInstance()->getLanguageInstallDirectory(), 'csv', false); $languagesCount = 0; foreach ($languagesIterator as $fullName => $file) { if (preg_match('/^' . Gpf_Application::getInstance()->getCode() . '_(.+)\\.csv$/', $file, $matches)) { $file = new Gpf_Io_Csv_Reader($fullName, ';', '"', array('source', 'translation', 'type', 'module', 'status', 'customer')); $language = new Gpf_Lang_CsvLanguage(); $language->loadFromCsvFile($file, true); $languagesCount++; $record = new Gpf_Data_Record($recordHeader); $record->set('id', $fullName); $record->set(Gpf_Db_Table_Languages::CODE, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_CODE)); $record->set(Gpf_Db_Table_Languages::NAME, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_NAME)); $record->set(Gpf_Db_Table_Languages::ENGLISH_NAME, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_ENG_NAME)); $record->set(Gpf_Db_Table_Languages::TRANSLATED_PERCENTAGE, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_TRANSLATION_PERCENTAGE)); $record->set(Gpf_Db_Table_Languages::AUTHOR, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_AUTHOR)); $record->set(Gpf_Db_Table_Languages::VERSION, $language->getMetaValue(Gpf_Lang_CsvLanguage::LANG_VERSION)); $result->addRecord($record); } } $response->rows = $result->toObject(); $response->count = $languagesCount; return $response; }
public function toText() { if ($this->panelWidth == 0) { $this->panelWidth = $this->getWidth(); } if ($this->panelHeight == 0) { $this->panelHeight = $this->getHeight(); } $template = new Gpf_Templates_Template($this->getTemplateName()); $template->setDelimiter('/*{', '}*/'); $template->assign('id', $this->getId()); $template->assign('name', $this->getName()); $template->assign('url', $this->getUrl()); $template->assign('width', $this->getWidth()); $template->assign('height', $this->getHeight()); $template->assign('panelWidth', $this->panelWidth - 10); $template->assign('panelHeight', $this->panelHeight - 10); $template->assign('properties', $this->getProperties()); $template->assign('rssEntries', $this->getRssEntries()); $template->assign('rssEntryImgUrl', Gpf_Paths::getInstance()->getImageUrl('icon-rss-small.png')); $template->assign('rssImgUrl', Gpf_Paths::getInstance()->getImageUrl('icon-rss-big.png')); return $template->getHTML(); }
/** * @param $imageCode * @return String */ public function getLink($imageCode) { $link = Gpf_Paths::getInstance()->getFullScriptsUrl() . 'qrcode.php'; $link .= '?' . self::QR_IMAGE_CODE . '=' . $imageCode; return '<img src="' . $link . '">'; }