dougao2830 2013-08-07 14:56
浏览 53

Smarty从PHP中的.conf文件中读取配置值

For a meeting schedule, I want to have dynamic pages for any given room. User can edit a file named "schedules.conf" in the config folder. At the moment it looks like this:

[rooms]
room = 5022
room = 5082

And I can load it normally and it shows 2 links in my web page:

{config_load file="schedules.conf" section="rooms"}
......
......
......

{foreach from=#room# item=r}

<li><span><span><a href="{$smarty.const.SITE_URL}/admin/schedules.list.php?room={$r}">Schedules {$r}</a></span></span></li>                    

{/foreach}

So it links to the handler PHP file, now in the php file I want to check weather that room exist in the config file, so if someone manually change the GET value for room in the address bar I could have a chance to handle that:

  if(!isset($_GET["room"]))
  {
      header('location: '.SITE_URL.'/admin/index.php');
  }
  else
  {
      $validRooms = $smarty->getConfigDir();

      //How to check id the $_GET["room"] value exist in the config file      
  }
  • 写回答

3条回答 默认 最新

  • doubianyu7844 2013-08-07 15:16
    关注

    Grep this page Conditional checks using smarty for isset()

    EDIT

    In light of comment #1 by the OP:

    How about use a conditional check along with in_array($_GET['room'], $validRooms)

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号