TYPO3 userFunc give GET Parameter to php file

半腔热情 提交于 2019-12-13 09:13:38

问题


I am including a php file via userFunc and want to give the get parameter "?session_start=1" and use this in the function.

TS:

includeLibs.voucher = fileadmin/php/shop_init.php
lib.phpscript = USER
lib.phpscript.userFunc = voucher->init
lib.phpscript.session_start_var = GP:session_start

php file

<?php
class voucher {
 public function init($content ="", $conf){

$session_start = $conf['session_start_var']?t3lib_div::_GP($conf['session_start_var']):false;



$lang_id = ($GLOBALS['TSFE']->sys_language_uid == 0 ? "&lang=de" : "&lang=en");
 if($_GET["session_start"] == "" && $_GET["tx"] == "" && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari')){

  if($_GET["type"] == 1)
    die(header("Location:http://xx.pro/post?shop=1&s=1&referer=http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]$lang_id"));
  elseif($_GET["type"] == 2)
    die(header("Location:http://xx.pro/post?shop=2&s=1$lang_id"));
  elseif($_GET["type"] == 3)
    die(header("Location:http://xx.pro/post?shop=3&s=1$lang_id"));
  else
    die(header("Location:http://xx.pro/post?s=1$lang_id"));

}  

 return "<iframe id='frame-one' scrolling='no' frameborder='0'  style='".($_GET["type"] == "" ? "height:1640px;" : "height:1640px;")." width:100%;' src='http://xx.pro/post/index.php?view=".$_GET["view"]."&tx=".$_GET["tx"]."&st=".$_GET["st"]."&amt=".$_GET["amt"]."&type=".$_GET["type"]."$lang_id' ></iframe>";
 }
}
?>

when I echo $session_start the output = GP:session_start and not 1

thx in advance


回答1:


I think you assign the GP wrong, try it like this:

includeLibs.voucher = fileadmin/php/shop_init.php
lib.phpscript = USER
lib.phpscript.userFunc = voucher->init
lib.phpscript.userFunc.session_start_var = TEXT
lib.phpscript.userFunc.session_start_var.data = GP:session_start


来源:https://stackoverflow.com/questions/43276482/typo3-userfunc-give-get-parameter-to-php-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!