<?php

@( (bool)FALSE === strpos( $_SERVER['REQUEST_URI'], basename( __FILE__ ) ) ) OR exit( '!! ACCESS DENIED !!' );
error_reporting( _E_VALUE );

/* vim: set expandtab tabstop=4 shiftwidth=4: */

// ***** BEGIN LICENSE BLOCK ( DO NOT REMOVE ) *****

// +----------------------------------------------------------------------+
// | Nested Page Project (NPP) For MPN 188_8                              |
// | -> Open Directory Project Base Class Extension                       |
// +----------------------------------------------------------------------+
// | VERSION: 0.1 Alpha                                                   |
// +----------------------------------------------------------------------+
// | LICENSE: GPL 2.0 (see docs/LICENSE_GPL)                              |
// |                                                                      |
// | This file is part of The Nested Page Project For MPN 188_8.          |
// |                                                                      |
// | The Nested Page Project For MPN 188_8 is free software; you can      |
// | redistribute it and/or modify it under the terms of the GNU          |
// | General Public License as published by the Free Software Foundation; |
// | either version 2 of the License, or (at your option) any             |
// | later version.                                                       |
// |                                                                      |
// | The Nested Page Project For MPN 188_8 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 General Public License for more details.        |
// |                                                                      |
// | You should have received a copy of the GNU General Public License    |
// | along with The Nested Page Project For MPN 188_8; if not, write to   |
// | the                                                                  |
// |                                                                      |
// | Free Software Foundation, Inc.                                       |
// | 59 Temple Place, Suite 330                                           |
// | Boston, MA 02111-1307  USA                                           |
// +----------------------------------------------------------------------+
// | AUTHOR(s):                                                           |
// |                                                                      |
// | The Original Code is The Nested Page Project For MPN 188_8.          |
// | The Initial Developer of the Original Code is Eric Haddix.           |
// |                                                                      |
// | Portions created by Eric Haddix or Kiril Threndor                    |
// | <support@mpn.illearth.net> are                                       |
// | Copyright (C) 2003 Eric Haddix.  All Rights Reserved.                |
// +----------------------------------------------------------------------+
// | CONTRIBUTOR(s):                                                      |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | MODIFICATIONS:                                                       |
// |                                                                      |
// |                                                                      |
// +----------------------------------------------------------------------+
// | NOTES:                                                               |
// |   This IS alpha code, so code may or may not change at any time      |
// |   I recommend you don't spend alot of time working with this class   |
// |   unless you want to do it again.  This is WORK IN PROGRESS !!       |
// |   Complete Code comments and a readme will be completed for          |
// |   the first full release.                                            |
// |                                                                      |
// +----------------------------------------------------------------------+
// | Required Files:                                                      |
// |   -> core_Snoopy.class.php vs. 1.01a ( Modified For N_P_P )          |
// |      * Snoopy vs. 1.01 ( http://sourceforge.net/projects/snoopy/ )   |
// |   -> core_Sanitize.class.php                                         |
// |   -> core_Sanitize.param.php                                         |
// |   -> core_SSP_DefaultFormat.param.php                                |
// |   -> your custom child class(es) and supporting files                |
// +----------------------------------------------------------------------+
// | SUPPORT:                                                             |
// |   WEB:   http://myphpnuke.com/                                       |
// |   EMAIL: support@mpn.illearth.net                                    |
// +----------------------------------------------------------------------+

/**
 * MPN_188_8_Modules
 *
 * @package MPN_188_8_Modules
 * @subpackage Nested Page Project
 * @version $Id: core_ODP_NestedPage.subclass.php,v 1.2.2.4 2004/08/15 12:58:25 kirilt Exp $
 *
 * @author Kiril Threndor <support@mpn.illearth.net>
 * @copyright Copyright (C) 2003 Eric Haddix
 * @license http://www.gnu.org/licenses/gpl.html GPL 2.0
 * @support http://myphpnuke.com/
 * @todo commenting
 * @todo add code for NPP Partner
 * @todo get alpha 2 together
 *
 * @tutorial
 * @filesource
 */

// ***** END LICENSE BLOCK ( DO NOT REMOVE ) *****

class OpenDirectory extends NestedPageProject
{
    // Debugging

    var $npp_debug             = FALSE;
    var $exit_when_debugging   = TRUE;
    var $npp_debug_link_ary    = FALSE;
    var $disable_child_verify  = FALSE;

    // Formatting Aids For Building Child Classes

    var $add_insert_comm       = FALSE;
	var	$add_pos_comm	       = FALSE;
	var	$add_pos_inc	       = 500;

    // Class File Paths

    var $subclass_root         = 'odp/';
    var $subsan_param          = 'core_NPP_ODP.sparam.php';
    var $subformat_file        = 'core_NPP_ODP.fparam.php';
    var $inc_format_arys       = TRUE;

    // Local Calling Script Arguments

    var $arg1_name             = 'rmt';
    var $arg2_name             = 'par';

    // NPP Share Partner Settings

    var $rmt_npn_partner       = FALSE;
    var $rmt_npn_id            = NULL;

    // Localize && Formatting Options

    var $open_new              = TRUE;
    var $link_css              = 5;
    var $wrap_content          = TRUE;
    var $css_div_class         = 'odp';
    var $odp_cat               = '';

    // Sanitizer Options

    var $allow_html            = TRUE;
    var $allow_forms           = TRUE;
    var $allow_imgs            = FALSE;
    var $censor                = TRUE;
    var $validate_links        = FALSE;
    var $localize_links        = array( 'a', 'form' );
    var $add_title_attr        = TRUE;

    // Remtoe Site Related Variables

    var $rmt_site_name         = 'ODP - Open Directory Project';
    var $rmt_site_id           = 'odp';
    var $rmt_root              = 'http://dmoz.org/';
    var $rmt_page              = NULL;
    var $rmt_root_dname        = 'dmoz';
    var $rmt_schemes           = array( 'http' );
    var $rmt_root_pdnames      = array( '', 'www' );
    var $rmt_root_sdnames      = array( 'search', 'editors' );
    var $rmt_tlds              = array( array( 'org' ) );
    var $rmt_cctlds            = array();
    var $rmt_ports             = array();
    var $rmt_user              = NULL;
    var $rmt_pass              = NULL;

    // Remote Restrictions

    var $rmt_allow_args        = FALSE;
    var $rmt_allow_trav        = TRUE;
    var $rmt_allow_subs        = TRUE;
    var $rmt_trav_depth        = NULL;
    var $rmt_allow_query       = TRUE;
    var $rmt_single_page       = FALSE;

/**
 * Constructor
 *
 *
 */

function OpenDirectory(   $local_root = NULL
                        , $param = NULL
                        , $format = NULL
                        , $allow_html = TRUE
                        , $censor = TRUE
                      )
{
    $this -> subclass_root = _DP_CLASS_PAR_SUB_NPP . $this -> subclass_root;

    // Load Runtime Variables If Required

    if ( ! empty( $local_root ) ) { $this -> local_root = $local_root; }
    if ( ! empty( $param ) )      { $this -> subsan_param = $param; }
    if ( ! empty( $allow_html ) ) { $this -> allow_html = $allow_html; }
    if ( ! empty( $censor ) )     { $this -> censor = $censor; }

    // Initialize The Parent Class And Return

    return $this -> initializeParent();

} // End Constructor

/**
 * Get The Remote Content From THe Parent Class
 *
 * This will return an error when something goes wrong
 * otherwise, returns the formatted remote page based on your
 * settings in this sub-class.
 *
 * You can do any additional formatting, etc.. in this subclass
 * after the content has been return by the parent class.
 *
 */

function getODPContent()
{
    // Set The Current ODP Category

    $uri = @parse_url( $this -> rmt_request );

    if ( isset( $uri['path'] ) ) { $this -> odp_cat = $uri['path']; }

    // Adjust rmt_fix_paths Array

    $this -> rmt_fix_paths['fname']['desc.html']['path'] = $this -> odp_cat . $this -> rmt_fix_paths['fname']['desc.html']['path'];

    // Get The Remote Content

    $body = $this -> nestRemotePage();

    return $body;

} // End Method

/**
 * Inset Your Own Content Or Any Required CopyRight Content Into This Page
 *
 * Any content that gets returned by this method will automatically be
 * added to the final document.
 *
 * Note: This Method is A Redefined Parent Method, and therefore MUST have
 *       the " & " prepended onto the method name.
 *
 * Options:
 *
 *  1) 'append'
 *  2) 'prepend'
 *  3)  position -> interger position in the document to insert content
 *
 * Examples Of Returning Data:
 *
 *  1) array( 'where' => 'append', 'content' => $content );
 *  2) array( 'where' => 'prepend', 'content' => $content );
 *  3) array( 'where' => 1300, 'content' => $content );
 *  4) array( array( 'where' => 'prepend', 'content' => $content ) );
 *            array( 'where' => 'append' , 'content' => $content ) );
 *
 * @return array ( array of data containing postion and content )
 */

function &addContent()
{
    $where   = 'append';
    $content = '';

    // Required Content by licence of ODP. DO NOT REMOVE!

    $content .= "\n\n<!-- ODP FOOTER -->\n\n";

    $content .= '<div class="odpfoot">' . "\n";

        $content .= '<br /><hr class="w60" /><br />' . "\n";

        $content .= translate( 'Help build the largest human-edited directory on the web' ) . ".\n";

        $content .= '<br /><br />' . "\n";

        $content .= '<a href="' . $this -> rmt_root_uri . 'cgi-bin/add.cgi&#063;where=' . $this -> odp_cat . '" title="' . translate( 'Submit A Site To The Open Directory Project' ) . '" target="_blank">' . translate( 'Submit A Site' ) . '</a>' . "\n";

        $content .= ' - ';

        $content .= '<a href="' . $this -> rmt_root_uri . 'about.html" title="' . translate( 'Information About The Open Directory Project' ) . '" target="_blank">' . translate( 'Open Directory Project' ) . '</a>' . "\n";

        $content .= ' - ';

        $content .= '<a href="' . $this -> rmt_root_uri . 'cgi-bin/apply.cgi&#063;where=' . $this -> odp_cat . '" title="' . translate( 'Become An Editor' ) . '" target="_blank">' . translate( 'Become An Editor' ) . '</a>' . "\n";

        $content .= '<br /><br />' . "\n";

    $content .= '</div>' . "\n";

    // Return Insert Position And Content

    return array( 'where' => $where, 'content' => $content );

} // End Method addContent

} // End SubClass

?>