PHP Classes
Icontem

File: proxylist.php5


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Kai Dorschner  >  PAC_proxylist  >  proxylist.php5  
File: proxylist.php5
Role: Class source
Content type: text/plain
Description: Generates the PAC code
Class: PAC_proxylist
Generate proxy auto-configuration files from XML
 

Contents

Class file image Download
<?php
/**
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @author Kai Dorschner <webmaster@krnl.de>
 * @copyright Copyright 2009, Kai Dorschner
 * @license http://www.gnu.org/licenses/lgpl.html LGPLv3
 */ 

/**
 * Generates dynamic proxy.pac code for your browser.
 */
class proxylist {

    
protected $xmlpath;
    
protected $xslpath;
    
/**
     * Defines how many proxy IPs should be displayed.
     */
    
protected static $maxProxies 2;

    
/**
     * Containing the XML-List as DomDocument.
     */
    
protected $xml;

    
/**
     * Containing the XSL transformation definition.
     */
    
protected $xsl;


    
public function __construct($xmlpath 'proxylist.xml'$xslpath 'bestproxy.xsl') {
        
$this->xmlpath $xmlpath;
        
$this->xslpath $xslpath;
    }

    
/**
     * This function is requiered in the XSL-Parser to let him know how many proxies should be printed out.
     */ 
    
public static function maxProxies() {
        return 
self::$maxProxies;
    }

    
/**
     * Creates the proxy.pac source code.
     *
     * Define a plain output in the HTTP-header and transform source XML file.
     */
    
public function create() {
        
$this->xml = new DomDocument();
        
$this->xml->load($this->xmlpath);
        
$this->xsl = new DOMDocument();
        
$this->xsl->load($this->xslpath);

        if(!
headers_sent())
            
header('Content-Type: text/plain'true);
        
$xsl = new XSLTProcessor();
        
$xsl->registerPHPFunctions(); // Allows the XSL to access custom PHP functions.
        
$xsl->importStyleSheet($this->xsl);
        echo 
$xsl->transformToXML($this->xml);
    }
}

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products