dqhbuwrwq692118284 2015-11-01 05:40
浏览 61

在从URL显示之前替换PHP上的文本文件

I have a GoldIPTV.m3u and get.php that display GoldIPTV.m3u

i used this:

<?php
$file = 'GoldIPTV.m3u';

if     (file_exists    ($file)) {
    header    ('Content-Description: File Transfer');
    header    ('Content-Type: application/octet-stream');
    header    ('Content-Disposition: attachment; filename=     "'.basename    ($file).'"');
    header    ('Expires: 0');
    header    ('Cache-Control: must-revalidate');
    header    ('Pragma: public');
    header    ('Content-Length: ' . filesize($file));
    readfile   ($file);
    exit;
}



?>

GoldIPTV.m3u contain 100 lines with different links and the word (key) i want to replace

exact like this: /get.php?CODE=key

i want when i type url

domain.com/get.php?CODE=123456

it will replace (key) on the displayed page with the number witch i typed.

its possible ? thanks for help!

  • 写回答

1条回答 默认 最新

  • doumeng9188 2015-11-01 11:51
    关注

    Okay. So it sounds like you have your file

    #EXTINF:-1,Channel 1
    rtmp://cdn1.domain.com/iptv/ch2?code=key
    #EXTINF:-1,Channel 2
    rtmp://cdn1.domain.com/iptv/ch3?code=key
    #EXTINF:-1,Channel 3
    rtmp://cdn1.domain.com/iptv/ch4?code=key
    

    and when you load

    /get.php?key=112233445566

    You want the key in that file to be replaced. Is that correct?

    If so try:

    $string = file_get_contents('location');
    echo nl2br(str_replace('code=key', 'code=' . $_GET['key'], $string));
    

    A user could manipulate the content on your site with this approach so be careful with that. If key is not literal you will need to use a regex. If the case of that parameter/value can vary use str_ireplace.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用