<style type="text/css">
.gray-dashed {
border-bottom: #000 1px dashed;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #3c3c3c;
LINE-HEIGHT: 16px
}
.list {
LINE-HEIGHT: 16px
}
</style>
<?php
header("Content-Type: text/html; charset=utf-8"); $employee_no = $_GET['employeeid'];
$employee_name = $_GET['username_erp'];

?>
<script type="text/javascript">
function showDetail_erpforum(para){
alert("tid是多少 "+para);
var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid="+$employee_no+"&username_erp="+$employee_name+"&tid="+para ;
window.open(url);
}
</script><?php
$conn = mysql_connect("10.222.1.104","root","passw0rd");
    mysql_select_db("discuz");
    mysql_query("set names utf8;",$conn);
$sql = "select * from cdb_posts p where p.fid =26 and subject <> '' ORDER by dateline desc limit 5 ";
$rs = mysql_query($sql);
?><?php  if(@mysql_num_rows($rs)>0){
          while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {    ?>
  <table class=list border=0 cellSpacing=0 cellPadding=0 width="105%" align=center>
        <tr vAlign=top style="cursor:hand"    onclick="showDetail_erpforum(<?php $row['tid'] ?>);">
          <td height="10" width="10" align="right" valign="bottom">&nbsp;
            <image width="10" height="10" src="./images/arrow.gif" />&nbsp;
          </td>
          <td height=10 align="left" valign="bottom" class="gray-dashed">
            <font style="font-size:12px;color:#353535"> &nbsp;&nbsp;
              <?php echo $row['subject'] ?>
            </font>
          </td>
          <td height=10 align="right" valign="bottom" class="gray-dashed">&nbsp;
            <font style="font-size:12px;color:#353535"> 
<? $d=date('Y-m-d',$row['dateline']); ?>          
               [<?echo $d; ?>
            </font>]
          </td>
          <td width="5">&nbsp;</td>
        </tr>
</table>
    <?php
        }
        mysql_close($conn);
    }
    ?>这里有几个比较关键的,<script type="text/javascript">
function showDetail_erpforum(para){
alert("tid是多少 "+para);
var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid="+$employee_no+"&username_erp="+$employee_name+"&tid="+para ;
window.open(url);
}
</script>
<?php
header("Content-Type: text/html; charset=utf-8"); $employee_no = $_GET['employeeid'];
$employee_name = $_GET['username_erp'];

?>
<tr vAlign=top style="cursor:hand"    onclick="showDetail_erpforum(<?php $row['tid'] ?>);">
这里 onclick 总是报错 不清楚php ,不知道该咋写

解决方案 »

  1.   

    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid="+<?php echo $employee_no;?>+"&username_erp="+<?php echo $employee_name;?>+"&tid="+para;
    onclick="showDetail_erpforum('<?php echo $row['tid'];?>');">
      

  2.   

    <script type="text/javascript">
    function showDetail_erpforum(para){
    alert("tid是多少 "+para);
    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid="+<?php echo $employee_no; ?>+"&username_erp="
     +<?php echo $employee_name; ?>+"&tid="+para ;
    alert("url"+url);
    window.open(url);
    }
    </script>
    第一个alert 输出了,第二个没有出来,报错“张三”undefined
    其实指向的就是那个 $employee_name
     不知道为嘛
      

  3.   

    职位名称: PHP工程师-北京 
     
    行业要求: 互联网 
       
    职位描述: PHP开发工程师岗位职责与任职要求 岗位职责 
    互联网相关产品开发,项目开发,系统维护等 任职要求 
    1. 精通PHP开发语言,熟悉面向对象的软件设计方法; 
    2. 熟悉Unix/Linux操作系统,熟悉C/C++编程,熟悉Shell脚本编程及常用Unix管理命 
    令,熟悉bash/python/perl; 
    3. 熟悉HTTP协议及W3C相关互联网规范,熟练掌握XHTML、CSS、DIV、Javascript 
    等页面技术; 
    4. 熟悉MySQL数据库应用开发,了解MySQL的数据库配置管理、性能优化等基本操 
    作技能; 
    5. 具备良好的代码编程习惯及较强的文档编写能力; 
    6. 具备强烈的进取心、求知欲及团队合作精神,有较强的沟通及协调能力; 
    QQ(1486904696)MSN:[email protected]
      

  4.   

    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid=<?php echo $employee_no; ?>&username_erp=<?php echo $employee_name; ?>&tid="+para;
      

  5.   

    url 最后的那个 para 被认定为一个变量了。。说undefined
      

  6.   

    <tr vAlign=top style="cursor:hand"   onclick="showDetail_erpforum('<?php echo $row['tid'];?>');">
    这里改了吗?
      

  7.   

    function showDetail_erpforum(tid){
    var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid=<?php echo $employee_no; ?>&username_erp=<?php echo $employee_name; ?>&tid="+tid ;
    window.open(url);
    }
    这里已经正常的跳转到那个php了,而且参数通过alert来看 都是正确的。<?php 
    define('IN_DISCUZ', true);
    define('DISCUZ_ROOT', './');
    require_once './config.inc.php';
    require_once './include/db_'.$database.'.class.php';
    require_once './forumdata/cache/cache_settings.php';
    header("Content-Type: text/html; charset=utf-8");$tid = $_GET['tid'];if ( !$ssoauth ) {
    /* 若URL中没有SSO相关的参数,则尝试从HTTP请求中获取用户信息并进行SSO */ // 从请求中取sso信息,可自定义从url参数或者header中取
    //$filterInfo = $employeeid; // from request
    $headers = getallheaders();
    //$filterInfo = $headers['iv-user'];
    $filterInfo = $_GET['employeeid'];
    $erp_username = $_GET['username_erp'];
    // 下述情况下,需要根据filter信息重新生成用户session
    if ( $filterInfo ) {
    /*  取uid、pwd、secques,可自定义SQL条件,但查询结果不能变 */
    $db = new dbstuff;
    $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    $query = $db->query("SELECT uid, password, secques FROM {$tablepre}members
    WHERE uid=(SELECT uid FROM {$tablepre}memberfields WHERE employeeid='$filterInfo')");
    $member = $db->fetch_array($query);
    /* 若用户不存在,可自定义,如直接生成用户 */
    if( !$member['uid'] ) {
    // 直接插入用户,用户名为工号,密码为md5(123456), coped from admin/members.inc.php
    $db->query("INSERT INTO {$tablepre}members (uid, password, groupid, username, timeoffset) 
    VALUES (NULL, 'e10adc3949ba59abbe56e057f20f883e', 10, '$filterInfo', '8');");
    $uid = $db->insert_id();
    $db->query("REPLACE INTO {$tablepre}memberfields (uid, employeeid) VALUES ('$uid','$filterInfo')");
    //
    $member['uid'] = $filterInfo;
    $member['password'] = 'e10adc3949ba59abbe56e057f20f883e';
    $member['secques'] = '';
    }
    $db->close(); /* 用户存在,则生成加密的cookie信息,并作为参数拼装到URL中重定向到论坛的实际地址 */
    if( $member['uid'] ) {
    $ssoauth = base64_encode(authcode($member['password']."\t".$member['secques']."\t".$member['uid'], 'ENCODE'));
    $ssourl = $_DCACHE['settings']['siteurl'] . substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/"));
    $ssourl = "$ssourl?ssoauth=$ssoauth&time=" . time();
    // 采用js来进行重定向,并将url拆分,以免被WebSEAL截获并修改
    print ('<script>');
    print ('location.replace("' . substr($ssourl,0,6) . '"+"' . substr($ssourl,6) . '")');
    print ('</script>');
    }
    }
    } else {
    /* 根据URL中的参数,重新生成cookie,并重定向到ERP论坛 */
    dsetcookie('sid', '');
    dsetcookie('cookietime', 0);
    dsetcookie('auth', base64_decode($ssoauth), 0);
    dsetcookie('erpvalidate', 'hide');

    if( $tid ){
    header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid=$tid&extra=page%3D1&sid=ywqyMG');
    }else{
    header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
    }
    }
    就不正常了,print &tid 是空的,不知道为嘛 代码不走header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid=$tid&extra=page%3D1&sid=ywqyMG');
      

  8.   

    header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');
      

  9.   

    define('IN_DISCUZ', true);
    define('DISCUZ_ROOT', './');
    require_once './config.inc.php';
    require_once './include/db_'.$database.'.class.php';
    require_once './forumdata/cache/cache_settings.php';
    header("Content-Type: text/html; charset=utf-8");
    $tid = $_GET['tid'];if ( !$ssoauth ) {
    /* 若URL中没有SSO相关的参数,则尝试从HTTP请求中获取用户信息并进行SSO */ // 从请求中取sso信息,可自定义从url参数或者header中取
    //$filterInfo = $employeeid; // from request
    $headers = getallheaders();
    //$filterInfo = $headers['iv-user'];
    $filterInfo = $_GET['employeeid'];
    $erp_username = $_GET['username_erp'];
    // 下述情况下,需要根据filter信息重新生成用户session
    if ( $filterInfo ) {
    /*  取uid、pwd、secques,可自定义SQL条件,但查询结果不能变 */
    $db = new dbstuff;
    $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    $query = $db->query("SELECT uid, password, secques FROM {$tablepre}members
    WHERE uid=(SELECT uid FROM {$tablepre}memberfields WHERE employeeid='$filterInfo')");
    $member = $db->fetch_array($query);
    /* 若用户不存在,可自定义,如直接生成用户 */
    if( !$member['uid'] ) {
    // 直接插入用户,用户名为工号,密码为md5(123456), coped from admin/members.inc.php
    $db->query("INSERT INTO {$tablepre}members (uid, password, groupid, username, timeoffset) 
    VALUES (NULL, 'e10adc3949ba59abbe56e057f20f883e', 10, '$filterInfo', '8');");
    $uid = $db->insert_id();
    $db->query("REPLACE INTO {$tablepre}memberfields (uid, employeeid) VALUES ('$uid','$filterInfo')");
    //
    $member['uid'] = $filterInfo;
    $member['password'] = 'e10adc3949ba59abbe56e057f20f883e';
    $member['secques'] = '';
    }
    $db->close(); /* 用户存在,则生成加密的cookie信息,并作为参数拼装到URL中重定向到论坛的实际地址 */
    if( $member['uid'] ) {
    $ssoauth = base64_encode(authcode($member['password']."\t".$member['secques']."\t".$member['uid'], 'ENCODE'));
    $ssourl = $_DCACHE['settings']['siteurl'] . substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/"));
    $ssourl = "$ssourl?ssoauth=$ssoauth&time=" . time();
    // 采用js来进行重定向,并将url拆分,以免被WebSEAL截获并修改
    print ('<script>');
    print ('location.replace("' . substr($ssourl,0,6) . '"+"' . substr($ssourl,6) . '")');
    print ('</script>');
    }
    }
    } else {
    /* 根据URL中的参数,重新生成cookie,并重定向到ERP论坛 */
    dsetcookie('sid', '');
    dsetcookie('cookietime', 0);
    dsetcookie('auth', base64_decode($ssoauth), 0);
    dsetcookie('erpvalidate', 'hide');
    print ('<script>');
    print ('alert("'.$tid.'");');
    print ('</script>');
    if( $tid ){
    header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');
    }else{
    header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
    }
    }这样的话先是弹一个alert,空的,什么也不显示,后来就报错,指向header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
    我发现到了这里之后 判断 $tid 有问题,是空的,不进这个判断啊~~
      

  10.   

    php里:
    echo $_GET['tid'];
    echo $_REQUEST['tid'];哪一个有值?
    都没值那就看:     alert("tid是多少 "+para);//这里有值吗?
        var url = "http://10.222.1.104:8080/discuz/erp_sso.php?employeeid="+$employee_no+"&username_erp="+$employee_name+"&tid="+para ;
        window.open(url);或者看window.open打开的窗口的地址栏的地址是什么?
      

  11.   

    echo $_GET['tid'];
    echo $_REQUEST['tid'];怎么写啊? 用alert的方式?
      

  12.   

    php文件里:define('IN_DISCUZ', true);
    define('DISCUZ_ROOT', './');
    require_once './config.inc.php';
    require_once './include/db_'.$database.'.class.php';
    require_once './forumdata/cache/cache_settings.php';
    header("Content-Type: text/html; charset=utf-8");
    $tid = $_GET['tid'];echo "GET:".$_GET['tid']."<br>";
    echo "REQUEST:".$_REQUEST['tid']."<br>";
    exit;.....
      

  13.   


    都有值的GET:9
    REQUEST:9
      

  14.   

    我在13楼的回复中 ,代码比较能说明问题,当链接进入这个文件时 是反复走两遍的 第一遍是走 
    if ( !$ssoauth ) {
    第二次走的是 else 的那个
      

  15.   

    dsetcookie('sid', '');
        dsetcookie('cookietime', 0);
        dsetcookie('auth', base64_decode($ssoauth), 0);
        dsetcookie('erpvalidate', 'hide');
    /*这里不能有输出否则后面的header会出错
        print ('<script>');
        print ('alert("'.$tid.'");');
        print ('</script>');
    */
        if($tid){
            header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');    
        }else{
            header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
        }
      

  16.   

    我这个erp_sso.php被两次调用,第一次走的是
    if ( !$ssoauth ) {
    这里面也确实能获取tid 并 print 出来,然后第二次走的是 
    if ( !$ssoauth ) {
    对应的else 里面,这时文件又一次重新读取,$tid = $_GET['tid']; 就获取不到东西了,所以里面的判断就...
     if($tid){
      header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');   
      }else{
      header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
      }我在想 在
    if ( !$ssoauth ) {
    里面获取即 $tid = $_GET['tid']; 并 存入cookie,等第二次到了else的时候 ,从cookie里面取出来放到里面进行判断,行么? 我的思路是这样就是不知道该怎么写?
      

  17.   

    我在 if ( !$ssoauth ) { 中这样写
    dsetcookie('tid', $_GET['tid']);
    else 中这样写
    else {
    /* 根据URL中的参数,重新生成cookie,并重定向到ERP论坛 */
    dsetcookie('erpvalidate', 'hide');
    if( $_COOKIE["tGO_tid"] ){
    header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');
    }else{
    header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
    }
    }
    这次走的是header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG'); 但是在地址栏中看到 tid是 无值的.
      

  18.   


     $ssourl = "$ssourl?tid=".$tid."&ssoauth=$ssoauth&time=" . time(); 
    //第一次调用后进行第二次调用,那这里也要将tid的值传过去。不然第二次当然就没有值了。           
      

  19.   

    感谢 麻烦您再看下define('IN_DISCUZ', true);
    define('DISCUZ_ROOT', './');
    require_once './config.inc.php';
    require_once './include/db_'.$database.'.class.php';
    require_once './forumdata/cache/cache_settings.php';
    header("Content-Type: text/html; charset=utf-8");
    if ( !$ssoauth ) {
    /* 若URL中没有SSO相关的参数,则尝试从HTTP请求中获取用户信息并进行SSO */ // 从请求中取sso信息,可自定义从url参数或者header中取
    //$filterInfo = $employeeid; // from request
    $headers = getallheaders();
    //$filterInfo = $headers['iv-user'];
    $filterInfo = $_GET['employeeid'];
    $erp_username = $_GET['username_erp'];
    $tid = $_GET['tid'];
    //dsetcookie('tid', $_GET['tid']);
    // 下述情况下,需要根据filter信息重新生成用户session
    if ( $filterInfo ) {
    /*  取uid、pwd、secques,可自定义SQL条件,但查询结果不能变 */
    $db = new dbstuff;
    $db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
    $query = $db->query("SELECT uid, password, secques FROM {$tablepre}members
    WHERE uid=(SELECT uid FROM {$tablepre}memberfields WHERE employeeid='$filterInfo')");
    $member = $db->fetch_array($query);
    /* 若用户不存在,可自定义,如直接生成用户 */
    if( !$member['uid'] ) {
    // 直接插入用户,用户名为工号,密码为md5(123456), coped from admin/members.inc.php
    $db->query("INSERT INTO {$tablepre}members (uid, password, groupid, username, timeoffset) 
    VALUES (NULL, 'e10adc3949ba59abbe56e057f20f883e', 10, '$filterInfo', '8');");
    $uid = $db->insert_id();
    $db->query("REPLACE INTO {$tablepre}memberfields (uid, employeeid) VALUES ('$uid','$filterInfo')");
    //
    $member['uid'] = $filterInfo;
    $member['password'] = 'e10adc3949ba59abbe56e057f20f883e';
    $member['secques'] = '';
    }
    $db->close(); /* 用户存在,则生成加密的cookie信息,并作为参数拼装到URL中重定向到论坛的实际地址 */
    if( $member['uid'] ) {
    $ssoauth = base64_encode(authcode($member['password']."\t".$member['secques']."\t".$member['uid'], 'ENCODE'));
    $ssourl = $_DCACHE['settings']['siteurl'] . substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], "/"));
    $ssourl = "$ssourl?tid=".$tid."&ssoauth=$ssoauth&time=" . time();
    // 采用js来进行重定向,并将url拆分,以免被WebSEAL截获并修改
    print ('<script>');
    print ('location.replace("' . substr($ssourl,0,6) . '"+"' . substr($ssourl,6) . '")');
    print ('</script>');
    }
    }
    } else {
    /* 根据URL中的参数,重新生成cookie,并重定向到ERP论坛 */
    dsetcookie('sid', '');
    dsetcookie('cookietime', 0);
    dsetcookie('auth', base64_decode($ssoauth), 0);
    dsetcookie('erpvalidate', 'hide');
    if( $tid ){
    header('Location: '.'http://10.222.1.104:8080/discuz/viewthread.php?tid='.$tid.'&extra=page%3D1&sid=ywqyMG');
    }else{
    header('Location: '.'http://10.222.1.104:8080/discuz/forumdisplay.php?fid=26');
    }
    }
    else 中的 判断和 header 中的写法 合适么? 我没学过php 对语法什么的一窍不通,谢谢指教!