<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: jsnews.php,v 1.5.2.2 2004/04/18 12:45:43 ajvwaay Exp $



######################################################################
# PHP-NUKE Add-on : Client-side javascript headlines Plug-in
# ==========================================================
#
# Copyright (c) 2000 by Christophe Lauer (clauer@free.fr)
# http://clauer.free.fr/
#
# This was derived from a feature off http://www.phpindex.com/ , originally
# written by Armel Fauveau (webmaster@phpindex.com)
#
# This modules is to allow headlines to be seamlessly integrated in other
# web sites
#
# This program 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.
######################################################################
#
# Extra params :
#
# font :    Font name to be used. Default is Tahoma
# size :    Font size. Default is 1
# image :   0 for no image, 1 for site logo
# max :     Number of news to be displayed, must be less or equal to 10, defaults to 5
# bgcolor : Title box color, Default is 999999 (without leading #)
# fgcolor : News box color, Default is EEEEEE (without leading #)
#
######################################################################
//include("extention.inc");
//include("mainfile.$phpEx");

#
# Check for params and default values
#

if (!isset($max)) { $max = 5; }
if ($max > 15) { $max = 15; }

// if (!isset($font)) { $font = 'Tahoma,Verdana,Helvetica'; }
if (!isset($font)) { $font = $site_font; }
if (!isset($size)) { $size = 1; }
if (!isset($image)) { $image = 0; }
if (!isset($bgcolor)) { $bgcolor = '999999'; }
if (!isset($fgcolor)) { $fgcolor = 'EEEEEE'; }
if (isset($width)) { $width = "width=$width "; } else { $width = ' '; }

//dbconnect();
$result = mysql_query("SELECT sid, title, time FROM ".$mpnTables['stories']." ORDER BY sid DESC limit $max");
    if (! $result ) {
        echo "An error occured";
    } else {
        echo "document.writeln('<!-- Headlines from $sitename -->');";
        echo "document.writeln('<table $width border=0 bgcolor=#000000 cellspacing=0 cellpadding=1>'); ";
        echo "document.writeln('<tr>'); ";
        echo "document.writeln('<td>'); ";
        echo "document.writeln('<table $width border=0 bgcolor=#000000 cellspacing=0 cellpadding=1>'); ";
        echo "document.writeln('<tr>'); ";
        echo "document.writeln('<td>'); ";
        echo "document.writeln('<table width=100% border=0 bgcolor=#$bgcolor cellspacing=1 cellpadding=4>'); ";
        echo "document.writeln('<tr>'); ";
        echo "document.writeln('<td align=center>'); ";
        echo "document.writeln('<a href=" . _MPN_ROOT_URI . " target=_blank>'); ";
        echo "document.writeln('<font face=\'$font\' size=".($size+1)." color=#$fgcolor>'); ";

        if ($image==1) {
//          echo "document.writeln('<a href=$nuke_url target=_blank>'); ";
            echo "document.writeln('<img src=" . _MPN_ROOT_URI . "images/logo_small.gif width=80 height=30 border=0>'); ";

//          echo "document.writeln('</a>'); ";
        }

        echo "document.writeln('<br>'); ";
        // echo "document.writeln('<b><b>Dernières nouvelles de $sitename</b></b>'); ";
        echo "document.writeln('<b>$sitename</b>'); ";
        echo "document.writeln('</font>'); ";
        echo "document.writeln('</a>'); ";
        echo "document.writeln('</td>'); ";
        echo "document.writeln('</tr>'); ";
        echo "document.writeln('</table>'); ";
        echo "document.writeln('</td>'); ";
        echo "document.writeln('</tr>'); ";
        echo "document.writeln('<tr>'); ";
        echo "document.writeln('<td>'); ";

        echo "document.writeln('<table width=100% border=0 bgcolor=#$fgcolor cellspacing=1 cellpadding=4>'); ";
        echo "document.writeln('<tr>'); ";
        echo "document.writeln('<td align=left>'); ";

        for ($m=0; $m < $max ; $m++) {
            list($sid, $title, $time) = mysql_fetch_row($result);
            echo "document.writeln('&#149;&nbsp;');";
            echo "document.writeln('<a href=" . _MPN_ROOT_URI . "article.$phpEx?sid=$sid target=_new>');";
            echo "document.writeln('<font face=\'$font\' size=$size color=#000000>');";
            echo "document.writeln('". addslashes(htmlentities($title)) ."');";
            echo "document.writeln('</font>');";
            echo "document.writeln('</a>');";
            echo "document.writeln('<br>');";
        }

        echo "document.writeln('<br>');";
        echo "document.writeln('</font>');";
        echo "document.writeln('</td>');";
        echo "document.writeln('</tr>');";

        echo "document.writeln('<tr>');";
        echo "document.writeln('<td align=right>');";
        echo "document.writeln('<a href=" . _MPN_ROOT_URI . " target=_blank>');";
        echo "document.writeln('<font face=\'$font\' size=$size color=#000000>');";
        echo "document.writeln('more...');";
        echo "document.writeln('</font>');";
        echo "document.writeln('</a>'); ";
        echo "document.writeln('</td>');";
        echo "document.writeln('</tr>');";

        echo "document.writeln('</table>');";
        echo "document.writeln('</td>');";
        echo "document.writeln('</tr>');";
        echo "document.writeln('</table>');";
        echo "document.writeln('</td>');";
        echo "document.writeln('</tr>');";
        echo "document.writeln('</table>');";
}


/*
// Uncomment this code portion if u wanna track referers using your plugin

// Save referer info into the database to know who are linking us

if (!isset($config)) { include("config.$phpEx"); }

    $HTTP_REFERER = getenv("HTTP_REFERER");

    if($httpref>0 && isset($HTTP_REFERER) && $HTTP_REFERER!='' && !ereg("^http://www\.dotnet-fr\.(org|net|com)", $HTTP_REFERER)) {
        // Remove trailing slash
        if (substr($HTTP_REFERER, -1)=='/') {
            $HTTP_REFERER = substr($HTTP_REFERER, 0, -1);
        }
        $res = mysql_query("SELECT count,url FROM ".$mpnTables['referer']." WHERE url='$HTTP_REFERER'");
        list($refs, $url) = mysql_fetch_row($res);
        if ($refs > 0) {
            $refs += 1;
        } else {
            $refs = 1;
        }
        mysql_free_result($res);

        mysql_query("replace into ".$mpnTables['referer']." (url, count, lastvisit) values ('$HTTP_REFERER', $refs, ".time() .")" );

}
*/

?>
