PHP Classes

Proxier PHP Web Proxy: Retrieve and serve content from remote Web sites

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 59 All time: 10,526 This week: 57Up
Version License PHP version Categories
proxier-class 1.0MIT/X Consortium ...7HTML, HTTP, Web services, PHP 7
Description 

Author

This package can retrieve and process content from remote Web sites.

It can retrieve the content of a remote server with a given URL.

The package can process the retrieved content by converting the URLs, so the retrieved content can be served from the current site. This package serves the content to the users.

Picture of Isa Eken
  Performance   Level  
Innovation award
Innovation award
Nominee: 14x

 

Example

<?php

require_once __DIR__ . "/../vendor/autoload.php";

use
IsaEken\Proxier\LoggerInterface;
use
IsaEken\Proxier\Proxier;

$proxier = new Proxier();

class
Logger implements LoggerInterface {
    public function
log(string $url): void
   
{
       
$ip = $_SERVER['REMOTE_ADDR'];
       
$date = date("d.m.Y");
       
$time = date("H:i:s");
       
$filename = __DIR__ . "/logs/$date-$ip.log";
       
$content = file_get_contents($filename);
       
$content .= "[$time] $url\n";
       
file_put_contents($filename, $content);
    }
}

$proxier->setLogger(new Logger());

$url = "http://isaeken.com.tr";
$uri = $_SERVER['REQUEST_URI'];

if (
strlen($uri) > 3) {
    if (
str_starts_with($uri, "/")) {
       
$uri = substr($uri, strlen("/"));
    }

    if (! (
str_starts_with($uri, "http:") || str_starts_with($uri, "https:")) || str_starts_with($uri, "//")) {
       
$uri = "$url/$uri";
    }

   
$proxier->setUrl($uri);
} else {
   
$proxier->setUrl($url);
}

$proxier->setHeader(<<<HTML
<!-- isaeken/proxier -->
<div style="position:fixed; top:0; left: 0; right:0; background: white; z-index: 99999999999; box-shadow: 0 0 10px rgba(0,0,0,0.5); padding: 10px; font-family: sans-serif; font-size: 12px;">
    <div style="display: flex; justify-content: space-between; align-items: center;">
        <div style="display: flex; align-items: center;">
            <span style="font-weight: bold; font-size: 16px;">isaeken/proxier</span>
        </div>
    </div>
</div>
<div style="margin: 60px"></div>
HTML
);

$proxier->run();


Details

PHP Web Proxy

A simple PHP web proxy.

Usage

Install

composer require "isaeken/proxier"

Proxy an URL

<?php

require_once __DIR__ . '/vendor/autoload.php';

use IsaEken\Proxier\Proxier;

$proxier = new Proxier();
$proxier->setUrl('http://isaeken.com.tr');
$proxier->run();

Proxy an URL with custom html header

$proxier = new Proxier();
$proxier->setUrl('http://isaeken.com.tr');
$proxier->setHeader(<<<HTML
<!--
Your html code is here.
-->
HTML
);
$proxier->run();

Proxy with custom logger

Create a logger class

<?php
class Logger implements \IsaEken\Proxier\LoggerInterface
{
    public function log(string $url): void
    {
        echo $url;
    }
}

Create your proxy

$proxier = new Proxier();
$proxier->setUrl('http://isaeken.com.tr');
$proxier->setLogger(new Logger());
$proxier->run();

Notice

Do not use this package with a framework.

License

The MIT License (MIT). Please see License File for more information.


  Files folder image Files (13)  
File Role Description
Files folder imagebin (1 file)
Files folder imageexamples (1 file)
Files folder imageresources (1 file)
Files folder imagesrc (5 files)
Files folder imagetests (1 file)
Plain text file composer.json Data Auxiliary data
Plain text file composer.lock Data Auxiliary data
Plain text file LICENCE.md Lic. License text
Plain text file README.md Doc. Read me

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:59
This week:0
All time:10,526
This week:57Up
User Comments (1)