PHP Classes

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

Recommend this page to a friend!
  Info   View files Example   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 57 All time: 10,534 This week: 82Up
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  
Name: Isa Eken <contact>
Classes: 20 packages by
Country: Turkey Turkey
Age: 22
All time rank: 275844 in Turkey Turkey
Week rank: 286 Up4 in Turkey Turkey Up
Innovation award
Innovation award
Nominee: 13x

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  
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

  Files folder image Files  /  bin  
File Role Description
  Plain text file proxier Appl. Application script

  Files folder image Files  /  examples  
File Role Description
  Plain text file index.php Example Example script

  Files folder image Files  /  resources  
File Role Description
  Plain text file script.js Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Converter.php Class Class source
  Plain text file Html.php Class Class source
  Plain text file LoggerInterface.php Class Class source
  Plain text file Proxier.php Class Class source
  Plain text file Response.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file Feature.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:57
This week:0
All time:10,534
This week:82Up
User Comments (1)