TYPO3 userFunc将GET参数提供给php文件

时间:2017-04-07 11:00:10

标签: php parameters typo3 typoscript

我通过userFunc包含一个php文件,并希望给出参数“?session_start = 1”并在函数中使用它。

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文件

<?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>";
 }
}
?>

当我回显$ session_start时输出= GP:session_start而不是1

事先提前

1 个答案:

答案 0 :(得分:0)

我认为你错误地分配了GP,试试这样:

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