dongle0396 2013-08-11 14:56
浏览 52

如何从远程页面跟踪获取的$ _GET对象的原始uri?

Thousands of ?queries are listed in hundreds of html pages. When one of these queries is clicked and passed to a specific page:-

<?php 
      $obtained= $_GET['query']; 

How to trace the URI of where it came from and paste it here? :-

      file_get_contents(../folder_of_pages_contain_queries/originated_page.html);
?>
  • 写回答

1条回答 默认 最新

  • douken7402 2013-08-11 15:05
    关注

    Use $_SERVER['HTTP_REFERER'] in your second page to figure out where the request came from.

    If you want to paste the contents in the second page, you can try:

    if (isset ($_SERVER['HTTP_REFERER']) && ! empty ($_SERVER['HTTP_REFERER']))
    {
        $contents = file_get_contents ($_SERVER['HTTP_REFERER']);
    }
    

    Here is an example:

    file1.html:

    Link 1: <a href="test.php?query=link1">link 1</a>
    Link 2: <a href="test.php?query=link2">link 2</a>
    Link 3: <a href="test.php?query=link3">link 3</a>
    

    file2.html:

    Link 1: <a href="test.php?query=link1">link 1</a>
    Link 2: <a href="test.php?query=link2">link 2</a>
    Link 3: <a href="test.php?query=link3">link 3</a>
    

    test.php:

    $query = $_GET['query'];
    $referer = $_SERVER['HTTP_REFERER'];
    

    Depending on your test cases:

    1. If user clicks on link 2 from file1.html, then the value of $query will be "link2", and $referer will be "file1.html".
    2. If user clicks on link 3 from file2.html, then the value of $query will be "link3", and $referer will be "file2.html".
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM
  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题