douliedai4838 2014-03-06 09:21
浏览 8
已采纳

列表目录未按预期运行

I have used usercake to make a login system, I am now altering it to suit my needs.

Originally I a list dir setup on the page to show all of the "help files" within a specific folder. It worked fine but it was not secure and anyone could view. So I have changed my security but am now having a few problems with my code:

//Links for logged in user
if(isUserLoggedIn()) {


    //Links for permission level 3 (BOF)
    if ($loggedInUser->checkPermission(array(3))){

    if ($handle = opendir('CD500/')) {
    while (false !== ($file = readdir($handle)))
        {
            if ($file != '.' && $file != '..'){
             $thelist .= '<a href="/CD500/'.$file.'' target='_blank' >'.$file.'</a></br>';
            }
        }

    closedir($handle);
    } 

    echo "
    <div id='output'>
    List of help files:</div>
    <div id='List'>
    $thelist 

This is the whole completed package. I am wondering if its simple as too many if statements?

It does not parse, the html loads and images appear but this just never materializes.

I set up:

//Links for logged in user
if(isUserLoggedIn()) {


    //Links for permission level 3 (BOF)
    if ($loggedInUser->checkPermission(array(3))){


    foreach(glob('./BOF/*.*') as $filename){


    echo $filename ;

    }



} 

My only problem whilst this works, is to make it presentable which I have so far failed to do.

I would Ideally like to fix the first solution, if not how can I style the second?

  • 写回答

1条回答 默认 最新

  • dongxi4335 2014-03-06 09:27
    关注

    This line

    $thelist .= '<a href="/CD500/'.$file.'' target='_blank' >'.$file.'</a></br>';
    

    Should be

    $thelist .= '<a href="/CD500/'.$file.'" target="_blank" >'.$file.'</a></br>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100