从访问我的图像的页面获取URL

时间:2017-05-18 18:02:00

标签: php html

想象一下任何网页ex:example1.com/something ...使用这个html:

<img src="http://www.example2.com/controller/showImage" >

web2.com中的我的控制器类似于:

function showImage() {
   getIP();                             //return USER IP (working)
   getURL();                            //return example1.com/something... (not working it returns always 'http://www.example2.com/controller/showImage')
   addMetricsSQL($ip, $url);              //add ip and url in database (working)
   header('Content-Type: image/jpeg');  //headers
   readfile($this->$path_img);        //a path
}

我目前的职能是:

public function getURL() {
        $ssl      = ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' );
        $sp       = strtolower( $_SERVER['SERVER_PROTOCOL'] );
        $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . ( ( $ssl ) ? 's' : '' );
        $port     = $_SERVER['SERVER_PORT'];
        $port     = ( ( ! $ssl && $port=='80' ) || ( $ssl && $port=='443' ) ) ? '' : ':'.$port;
        $host     = ( false && isset( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : ( isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : null );
        $host     = isset( $host ) ? $host : $_SERVER['SERVER_NAME'] . $port;
        return $protocol . '://' . $host . $_SERVER['REQUEST_URI'];
    }

但就像我说的那样,它只返回example2.com/controller/showImage

我的问题:

  • 可以获得正确的网址(在这种情况下 example1.com/something ...)使用PHP?

  • getURL()函数应该如何?

提前致谢

1 个答案:

答案 0 :(得分:0)

这很痛苦,但我的问题的答案是:

curl -k -X POST -F "upload=@xxx0101.csv" -F "mail=******" -F "pwd=******" -F "orgid=2729" -F "response=JSON" https:************* >> log.txt
SET Today=%Date:~10,4%%Date:~4,2%%Date:~7,2%
mkdir %cd%\Backup-%Today%
move %cd%\*.csv %cd%\Backup-%Today%\

HTTP_REFERER 带来所有魔力。