<?php
/**
 * $Source: /home/cvs/nukescripts/kernel/ultramode.php,v $
 * $Revision: 1.1.0a $
 * $Author: cyril $
 * $Date: 2006/06/19 21:03:12 $
 *
 */
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* 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.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied ultramode MAXIMUS directly...');


function ultramode() {
	global $prefix, $db;
	$ultra = "ultramode.txt";
	$file = fopen("$ultra", "w");
	fwrite($file, "General purpose self-explanatory file with news headlines\n");
	$sql = "SELECT sid, aid, title, time, comments, topic FROM ".TABLE_STORIES." ORDER BY time DESC LIMIT 0,10";
	if ( !($result = $db->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain stories ultramode', '', __LINE__, __FILE__, $sql);}
	while ($row = $db->sql_fetchrow($result)) {
		$raid = $rsid = $db->XMFnum($row['sid']);
		$rtitle = stripslashes(check_html($row['title'], "nohtml"));
		$rtime = $row['time'];
		$rcomments = stripslashes($row['comments']);
		$rtopic = $db->XMFnum($row['topic']);
		$row2 = $db->sql_fetchrow($db->sql_query("select topictext, topicimage from ".TABLE_TOPICS." where topicid='$rtopic'"));
		$topictext = stripslashes(check_html($row2['topictext'], "nohtml"));
		$topicimage = stripslashes($row2['topicimage']);
		$content = "%%\n$rtitle\n/modules.php?name=News&file=article&sid=$rsid\n$rtime\n$raid\n$topictext\n$rcomments\n$topicimage\n";
		fwrite($file, $content);
	}
	fclose($file);
}