Location: PHPKode > scripts > Bioloide > botlane/ara-build-rss.php
<?php

	/**	ARA Build RSS
		(c) 2007 Denis Sureau - Scriptol.com
		Licence GNU GPL 2.
	*/

            session_start(); 
	
	include_once("authorize.php");
	include_once("ara-class.php");

	$ulogin= $_SESSION["login"];
	$upass= $_SESSION["password"];
	$pass5 = "x" . MD5($upass);
	$registered= authorize($ulogin, $upass); 
	
	
	$unwanted   = array("\r\n", "\n", "\r", "\t", "  ");  // char to replace

function logMessage($message)
{
	$fp = fopen("ara.log", 'a'); 
	fwrite($fp, $message);
	fclose($fp);
}	

function araMessage($message)
{
	$fp = fopen("ara-build-result.txt", 'w'); 
	fwrite($fp, $message);
	fclose($fp); 
}

  unlink("ara.log");
  
	$fp = fopen("ara-build-result.txt", 'w'); 
	if($fp == false)
		die("Enable to open file for writing...");
	if(fwrite($fp, "error") === false)
		die("Enable to write...");
	fclose($fp); 

  logMessage("Starting...\n"); 

	if(! $registered) 
	{
	  araMessage("User $ulogin not registered");
		die("You must be registered to use this software");
	}

  logMessage("Registered\n");
	
	if (isset( $_POST ))
		$posted = &$_POST ;			
	else
		$posted = &$HTTP_POST_VARS ;	

	$feed =  $posted["feed"];
	$title = $posted["title"];
	$link = $posted["link"];
	$desc = $posted["description"];
	$date = $posted["date"];
	$type = $posted["type"];

	$ext = "";
	$l=strripos($feed, ".");
	if($l !== false)
		$ext = strtolower(substr($feed, $l));

	if(! in_array($ext, array(".xml", ".rss", ".atom", ".rdf", ".feed")))
		die("Bad extension in feed filename");

  logMessage("feed=$feed\n");

	$myfeed = new Ara();
	$title= stripslashes($title);
	$detected = mb_detect_encoding($title);
	$title = mb_convert_encoding($title, "UTF-8", $detected);
	
  $detected = mb_detect_encoding($desc);
  $desc = mb_convert_encoding($desc, "UTF-8", $detected);
  $desc = stripslashes($desc);
	$myfeed->ARAFeed($title, $link, $desc, $date);	

	// processing other parameters
	foreach($posted as $key => $value)
	{

		if(strlen($key) < 4) continue;		// unknown
		
		$key = substr($key, 0, 4);
		
		if(strcasecmp($key, "titl") == 0) 	
		{
			$title = stripslashes($value);
	    $detected = mb_detect_encoding($title);
      $title = mb_convert_encoding($title, "UTF-8", $detected);
			continue;
		}	

		if(strcasecmp($key, "link") == 0) 	
		{
			$link = $value;
			continue;
		}	
		if(strcasecmp($key, "desc") == 0) 	
		{
			$description = stripslashes($value);
      $detected = mb_detect_encoding($description);			
			$description = str_replace($unwanted, " ", $description);
      $description = mb_convert_encoding($description, "UTF-8", $detected);
			continue;
		}	
		if(strcasecmp($key, "date") == 0) 	
		{
			$date = $value;
			continue;
		}	
		
		if(strcasecmp($key, "type") == 0) 	
		{
			if($value != 1) continue;
			$myfeed->ARAItem($title, $link, $description, $date);
			continue;
		}	
	}

	$thisdir = getcwd();

  logMessage("current directory=$thisdir\n");

	$ximage = $myfeed->saveXML();
	$xf = fopen($feed, "w");
	 
	if($xf != false)
	{
		fwrite($xf, $ximage);
		fclose($xf);
	  araMessage("$feed created");
	}
	else
	{
    araMessage("Enable to open $feed, NOT CREATED.");
  }


	header("Location:ara.php");


?>
Return current item: Bioloide