Advertisement
Guest User

Alex

a guest
Dec 14th, 2008
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. # Powermail: Additional information for every powermail email (google searchword, ip address, page, referer)
  2. ###POWERMAIL_TYPOSCRIPT_AI###
  3. # Additional informations like google searchword, etc... in marker ###POWERMAIL_TYPOSCRIPT_AI###
  4. plugin.tx_powermail_pi1.dynamicTyposcript {
  5. ai = COA
  6. ai.wrap = <hr />|
  7. ai {
  8. # Current page
  9. 10 = COA
  10. 10.wrap = <b>conject page:</b>&nbsp;|<br />
  11. 10.10 = TEXT
  12. 10.10.typolink.parameter.data = TSFE:id
  13. 10.10.typolink.returnLast = url
  14. 10.10.wrap = <a href="http://www.conject.com/|">
  15. 10.20 = TEXT
  16. 10.20.data = page:title
  17. 10.20.wrap = |</a>
  18.  
  19. # Current language
  20. 20 = COA
  21. 20.wrap = <b>Preferred language:</b>&nbsp;|<br />
  22. 20.10 = CASE
  23. 20.10.key.data = GPvar:L
  24. 20.10.default = TEXT
  25. 20.10.default.value = EN
  26. 20.10.1 = TEXT
  27. 20.10.1.value = DE
  28. 20.10.4 = TEXT
  29. 20.10.4.value = RU
  30. 20.10.5 = TEXT
  31. 20.10.5.value = ME
  32.  
  33. # Geoinfo City
  34. 30 = COA
  35. 30.10 = USER
  36. 30.10.userFunc = user_pmgeoinfo->city
  37. 30.wrap = <b>City:</b>&nbsp;|<br />
  38.  
  39. # Geoinfo Country
  40. 40 = COA
  41. 40.10 = USER
  42. 40.10.userFunc = user_pmgeoinfo->country
  43. 40.wrap = <b>Country:</b>&nbsp;|<br />
  44.  
  45. # Google Searchword if any
  46. 50 = TEXT
  47. 50.data = TSFE:fe_user|sesData|wt_googlesession|searchword
  48. 50.wrap = <b>Google searchword:</b>&nbsp;|<br />
  49.  
  50. # Referrer if any
  51. 60 = TEXT
  52. 60.data = TSFE:fe_user|sesData|wt_referersession
  53. 60.wrap = <b>Referer:</b>&nbsp;|<br />
  54.  
  55. # Googleaddwords code
  56. 70 = TEXT
  57. 70.data = TSFE:fe_user|sesData|wt_googleaddscode
  58. 70.wrap = <b>Google adwords code:</b>&nbsp;|<br />
  59.  
  60. # IP address
  61. 100 = TEXT
  62. 100.data = getIndpEnv:REMOTE_ADDR
  63. 100.wrap = <b>IP Address:</b>&nbsp;|<br />
  64. }
  65. }
  66.  
  67.  
  68.  
  69.  
  70. ######################################
  71. # Example file for method user_googlesession (add this userFunc on every page - e.g. with page.1 = USER)
  72. ######################################
  73.  
  74. <?php
  75.  
  76. // This class adds referer and google searchword to session (for using in powermail later)
  77. class user_googlesession {
  78.  
  79. var $allow = array(1,1,1); // enable or disable the infos (1. Searchword, 2. Referer, 3. IP Address)
  80. var $sesprefix = array('wt_googlesession', 'wt_referersession'); // prefix for session
  81. var $finalarray = array(); // empty array for session
  82. var $test = 0; // testmode (show google searchword)
  83.  
  84.  
  85. // Main function for additional google information
  86. function user_main($content='', $conf=array()) {
  87. $this->makeSession(); // generate session
  88. if ($this->test === 1) return $this->user_test();
  89. }
  90.  
  91.  
  92. // Function to generate the session
  93. function makeSession() {
  94. // 1. save google searchword to session if exists
  95. $infoArray = $this->infoArray(); // Array with information about user
  96. if ($infoArray['searchword']) { // if searchword variable is not empty
  97. $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sesprefix[0], $infoArray); // Generate Session with array
  98. $GLOBALS['TSFE']->storeSessionData(); // Save session
  99. }
  100.  
  101. // 2. save refer to session if not conject.com or conject.de
  102. if (strpos(t3lib_div::getIndpEnv('HTTP_REFERER'), 'conject.com') === false && strpos(t3lib_div::getIndpEnv('HTTP_REFERER'), 'conject.de') === false) { // if referer is from extern
  103. $GLOBALS['TSFE']->fe_user->setKey('ses', $this->sesprefix[1], t3lib_div::getIndpEnv('HTTP_REFERER')); // Generate Session with array
  104. $GLOBALS['TSFE']->storeSessionData(); // Save session
  105. }
  106. }
  107.  
  108.  
  109. // Function infoArray() generates array with needed stuff for session (searchword, referer, ip)
  110. function infoArray() {
  111. $GETparams = parse_url(t3lib_div::getIndpEnv('HTTP_REFERER')); // Get GET params of an url
  112. $GETarray = t3lib_div::trimExplode('&', $GETparams['query'], 1); // split Get params at &
  113. if (is_array($GETarray)) { // if $GETarray is filled
  114. $nGETarray = array();
  115. foreach ($GETarray as $key => $value) { // one loop for every part in GET array
  116. $temp = t3lib_div::trimExplode('=', $value, 1); // split q=blabla at =
  117. $nGETarray[$temp[0]] = $temp[1]; // array ('q' => 'blabla')
  118. }
  119. }
  120.  
  121. if ($this->allow[0]) $this->finalarray['searchword'] = urldecode($nGETarray['q']); // q=searchword
  122. if ($this->allow[1]) $this->finalarray['referer'] = t3lib_div::getIndpEnv('HTTP_REFERER'); // 2. referer
  123. if ($this->allow[2]) $this->finalarray['ip'] = t3lib_div::getIndpEnv('REMOTE_ADDR'); // 3. IP address
  124.  
  125. // return whole array
  126. if (!empty($this->finalarray)) return $this->finalarray; // return info array
  127. }
  128.  
  129.  
  130. // test function
  131. function user_test($content='', $conf=array()) {
  132. $content = 'Sessionentry: ';
  133. $content .= print_r($GLOBALS['TSFE']->fe_user->sesData[$this->sesprefix[0]]['searchword'], 1);
  134. if (!empty($content)) return $content;
  135. }
  136.  
  137. }
  138.  
  139. ?>
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. ######################################
  147. # Example file for method user_pmgeoinfo (needs TYPO3 extension geoip from Georg Ringer)
  148. ######################################
  149.  
  150. <?php
  151.  
  152. class user_pmgeoinfo {
  153.  
  154. var $geoDBpath = 'fileadmin/12project/scripts/GeoLiteCity.dat'; // path to geoip database
  155. 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)
  156.  
  157. // Get country
  158. function country($content='', $conf=array()) {
  159. $this->geoInfo(); // init geoip
  160. if (!empty($this->GEOinfos['countryName'])) return $this->GEOinfos['countryName'];
  161. }
  162.  
  163. // Get country ISO code
  164. function countryISO($content='', $conf=array()) {
  165. $this->geoInfo(); // init geoip
  166. $this->GEOinfos['countryCode'] = $this->changeISO_3_2($this->GEOinfos['countryCode']); // changes ISO code from 3 to 2
  167.  
  168. if (!empty($this->GEOinfos['countryCode'])) return $this->GEOinfos['countryCode'];
  169. }
  170.  
  171. // Get city
  172. function city($content='', $conf=array()) {
  173. $this->geoInfo(); // init geoip
  174. if (!empty($this->GEOinfos['city'])) return $this->GEOinfos['city'];
  175. }
  176.  
  177. // use geo ip if loaded
  178. function geoInfo() {
  179. if (t3lib_extMgm::isLoaded('geoip')) {
  180. require_once(t3lib_extMgm::extPath('geoip').'/pi1/class.tx_geoip_pi1.php');
  181. $this->media = t3lib_div::makeInstance('tx_geoip_pi1');
  182. $this->media->init($this->geoDBpath); // Initialize the Geoip Ext
  183. $this->GEOinfos = $this->media->getGeoIP(($this->ip ? $this->ip : t3lib_div::getIndpEnv('REMOTE_ADDR'))); // get all the infos
  184. }
  185. }
  186.  
  187. // function changeISO_3_2 changes country with ISO code 3 to ISO code 2 (DEU => DE, AUT => AT)
  188. function changeISO_3_2($country) {
  189. if (t3lib_extMgm::isLoaded('static_info_tables', 0)) { // if ext static_info_tables is loaded
  190.  
  191. $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery (
  192. 'cn_iso_2',
  193. 'static_countries',
  194. 'cn_iso_3 = "'.$country.'"',
  195. '',
  196. '',
  197. '1'
  198. );
  199. $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
  200.  
  201. if (!empty($row['cn_iso_2'])) return $row['cn_iso_2'];
  202. }
  203. }
  204.  
  205. }
  206.  
  207. ?>
  208.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement