Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Powermail: Additional information for every powermail email (google searchword, ip address, page, referer)
- ###POWERMAIL_TYPOSCRIPT_AI###
- # Additional informations like google searchword, etc... in marker ###POWERMAIL_TYPOSCRIPT_AI###
- plugin.tx_powermail_pi1.dynamicTyposcript {
- ai = COA
- ai.wrap = <hr />|
- ai {
- # Current page
- 10 = COA
- 10.wrap = <b>conject page:</b> |<br />
- 10.10 = TEXT
- 10.10.typolink.parameter.data = TSFE:id
- 10.10.typolink.returnLast = url
- 10.10.wrap = <a href="http://www.conject.com/|">
- 10.20 = TEXT
- 10.20.data = page:title
- 10.20.wrap = |</a>
- # Current language
- 20 = COA
- 20.wrap = <b>Preferred language:</b> |<br />
- 20.10 = CASE
- 20.10.key.data = GPvar:L
- 20.10.default = TEXT
- 20.10.default.value = EN
- 20.10.1 = TEXT
- 20.10.1.value = DE
- 20.10.4 = TEXT
- 20.10.4.value = RU
- 20.10.5 = TEXT
- 20.10.5.value = ME
- # Geoinfo City
- 30 = COA
- 30.10 = USER
- 30.10.userFunc = user_pmgeoinfo->city
- 30.wrap = <b>City:</b> |<br />
- # Geoinfo Country
- 40 = COA
- 40.10 = USER
- 40.10.userFunc = user_pmgeoinfo->country
- 40.wrap = <b>Country:</b> |<br />
- # Google Searchword if any
- 50 = TEXT
- 50.data = TSFE:fe_user|sesData|wt_googlesession|searchword
- 50.wrap = <b>Google searchword:</b> |<br />
- # Referrer if any
- 60 = TEXT
- 60.data = TSFE:fe_user|sesData|wt_referersession
- 60.wrap = <b>Referer:</b> |<br />
- # Googleaddwords code
- 70 = TEXT
- 70.data = TSFE:fe_user|sesData|wt_googleaddscode
- 70.wrap = <b>Google adwords code:</b> |<br />
- # IP address
- 100 = TEXT
- 100.data = getIndpEnv:REMOTE_ADDR
- 100.wrap = <b>IP Address:</b> |<br />
- }
- }
- ######################################
- # Example file for method user_googlesession (add this userFunc on every page - e.g. with page.1 = USER)
- ######################################
- <?php
- // This class adds referer and google searchword to session (for using in powermail later)
- class user_googlesession {
- var $allow = array(1,1,1); // enable or disable the infos (1. Searchword, 2. Referer, 3. IP Address)
- var $sesprefix = array('wt_googlesession', 'wt_referersession'); // prefix for session
- var $finalarray = array(); // empty array for session
- var $test = 0; // testmode (show google searchword)
- // Main function for additional google information
- function user_main($content='', $conf=array()) {
- $this->makeSession(); // generate session
- if ($this->test === 1) return $this->user_test();
- }
- // Function to generate the session
- function makeSession() {
- // 1. save google searchword to session if exists
- $infoArray = $this->infoArray(); // Array with information about user
- if ($infoArray['searchword']) { // if searchword variable is not empty
- $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sesprefix[0], $infoArray); // Generate Session with array
- $GLOBALS['TSFE']->storeSessionData(); // Save session
- }
- // 2. save refer to session if not conject.com or conject.de
- if (strpos(t3lib_div::getIndpEnv('HTTP_REFERER'), 'conject.com') === false && strpos(t3lib_div::getIndpEnv('HTTP_REFERER'), 'conject.de') === false) { // if referer is from extern
- $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sesprefix[1], t3lib_div::getIndpEnv('HTTP_REFERER')); // Generate Session with array
- $GLOBALS['TSFE']->storeSessionData(); // Save session
- }
- }
- // Function infoArray() generates array with needed stuff for session (searchword, referer, ip)
- function infoArray() {
- $GETparams = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); // Get GET params of an url
- $GETarray = t3lib_div::trimExplode('&', $GETparams['query'], 1); // split Get params at &
- if (is_array($GETarray)) { // if $GETarray is filled
- $nGETarray = array();
- foreach ($GETarray as $key => $value) { // one loop for every part in GET array
- $temp = t3lib_div::trimExplode('=', $value, 1); // split q=blabla at =
- $nGETarray[$temp[0]] = $temp[1]; // array ('q' => 'blabla')
- }
- }
- if ($this->allow[0]) $this->finalarray['searchword'] = urldecode($nGETarray['q']); // q=searchword
- if ($this->allow[1]) $this->finalarray['referer'] = t3lib_div::getIndpEnv('HTTP_REFERER'); // 2. referer
- if ($this->allow[2]) $this->finalarray['ip'] = t3lib_div::getIndpEnv('REMOTE_ADDR'); // 3. IP address
- // return whole array
- if (!empty($this->finalarray)) return $this->finalarray; // return info array
- }
- // test function
- function user_test($content='', $conf=array()) {
- $content = 'Sessionentry: ';
- $content .= print_r($GLOBALS['TSFE']->fe_user->sesData[$this->sesprefix[0]]['searchword'], 1);
- if (!empty($content)) return $content;
- }
- }
- ?>
- ######################################
- # Example file for method user_pmgeoinfo (needs TYPO3 extension geoip from Georg Ringer)
- ######################################
- <?php
- class user_pmgeoinfo {
- var $geoDBpath = 'fileadmin/12project/scripts/GeoLiteCity.dat'; // path to geoip database
- var $ip = ''; // test some ip addresses (e.g. DEU: 83.236.183.130, UAE: 195.229.237.36, UAE: 87.200.131.139, RUS: 89.113.208.15)
- // Get country
- function country($content='', $conf=array()) {
- $this->geoInfo(); // init geoip
- if (!empty($this->GEOinfos['countryName'])) return $this->GEOinfos['countryName'];
- }
- // Get country ISO code
- function countryISO($content='', $conf=array()) {
- $this->geoInfo(); // init geoip
- $this->GEOinfos['countryCode'] = $this->changeISO_3_2($this->GEOinfos['countryCode']); // changes ISO code from 3 to 2
- if (!empty($this->GEOinfos['countryCode'])) return $this->GEOinfos['countryCode'];
- }
- // Get city
- function city($content='', $conf=array()) {
- $this->geoInfo(); // init geoip
- if (!empty($this->GEOinfos['city'])) return $this->GEOinfos['city'];
- }
- // use geo ip if loaded
- function geoInfo() {
- if (t3lib_extMgm::isLoaded('geoip')) {
- require_once(t3lib_extMgm::extPath('geoip').'/pi1/class.tx_geoip_pi1.php');
- $this->media = t3lib_div::makeInstance('tx_geoip_pi1');
- $this->media->init($this->geoDBpath); // Initialize the Geoip Ext
- $this->GEOinfos = $this->media->getGeoIP(($this->ip ? $this->ip : t3lib_div::getIndpEnv('REMOTE_ADDR'))); // get all the infos
- }
- }
- // function changeISO_3_2 changes country with ISO code 3 to ISO code 2 (DEU => DE, AUT => AT)
- function changeISO_3_2($country) {
- if (t3lib_extMgm::isLoaded('static_info_tables', 0)) { // if ext static_info_tables is loaded
- $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery (
- 'cn_iso_2',
- 'static_countries',
- 'cn_iso_3 = "'.$country.'"',
- '',
- '',
- '1'
- );
- $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
- if (!empty($row['cn_iso_2'])) return $row['cn_iso_2'];
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement