Location: PHPKode > projects > MyOWNSpace > MyOWNspace_v8.2/www/myownnews.php
<?php

include "login.inc.php";
include "config.php";
$date=date("d M Y");
////verifie quon adresse bien un ID pour designer la page
if(isset($_GET['go'])&&($_GET['go']!="")){
$go=$_GET['go'];}
else 
if(isset($_POST['go'])&&($_POST['go']!="")){
$go=$_POST['go'];}
else echo "BAD !!";
////trouve le fichier de conf adequat
$conf_file="myownnews/config.php";
if (file_exists($conf_file)) {
include $conf_file; }
else  {@fopen($conf_file, "w"); chmod ($conf_file, 0777);}
/// sinon CREATION DU FICHIER DE CONF
$i=$go;
////acces a la page seulement si le user est loggué et proprietaire de la page ID
if(checklogin()&&$go==$rawuser) {
include("header.php");

// EDITION DU BLOG
loged($rawuser);
//echo "<H4><a href=\"/".$go."\">Visit MyOwnSpace</a>&nbsp;|&nbsp;<a href=\"myownpic.php?go=".$go."\">MyOwnPicture Album</a>&nbsp;|&nbsp;<a href=\"myownfriend.php?go=".$go."\">MyOwnFriends Manager</a>&nbsp;|&nbsp;<a href=\"myownascii.php?go=".$go."\">MyOwnASCII ART Collection</a>&nbsp;<a href=\"myownstat.php?go=".$go."\">MyOwnSTATISTICS!</a></H4><hr>";

//$blogdir="myownnews/$go";

$user=$rawuser;
$arrayconf='<? $myownnews=array(';
////////////////////////////////////////////
//+++++++++++++++++++++++++++AJOUT D'UN BLOG
////////////////////////////////////////////

if(isset($_POST['add'])){
$p=1;
$n=$_POST['add'];
$go=$_POST['go'];

$conf_file="myownnews/config.php";

include $conf_file;
//echo $conf_file;

/// FORMATAGE & SAUVEGARDE DU CONTENU DANS UN FICHIER TXT
$blog=cleanhtml($_POST['blog']);
$file = "myownnews/news.".$n.".txt";
writeTXT($file ,$blog);
chmod ($file, 0777);

/////////////////////////////


for($j=1;$j<$n;$j++)
{
///**************** PRINT
$arrayconf.='"'.$j.'" => array 
("titre"=>"'.$myownnews[$j]['titre'].'", 
"author"=>"'.$myownnews[$j]['author'].'",
"date"=>"'.$myownnews[$j]['date'].'") ,
';

}
$arrayconf.='"'.$n.'" => array 
("titre"=>"'.$_POST['titre'].'", 
"author"=>"'.$go.'",
"date"=>"'.$_POST['date'].'") ,
';
$arrayconf.=') ?>';
//echo '<PRE>'.$arrayconf.'</PRE>';
echo '<H4>Add this to conf file!</H4><br><a href="myownnews.php?pic='.$n.'&go='.$go.'">Back to myownnews</a>';
writeTXT($conf_file ,$arrayconf);

fclose ($fp);
echo '<H4>Saved!</H4><br>';

}

else 
//////////////////////////////////////////////////
//+++++++++++++++++++++++MODIFICATION D'UNE ENTRéE
//////////////////////////////////////////////////

if(isset($_POST['change'])){

$nb=$_POST['change'];
$RSSfile="myownRSS/myownnews.xml";

$myownnews[$n]['titre']=cleanhtml($_POST['titre']);
$myownnews[$n]['author']=$user;
$myownnews[$n]['date']= date("j M Y");
 //RSS
require("classes/xmlwriterclass.php");
require("classes/rss_writer_class.php");
$rss_writer_object=&new rss_writer_class;
$rss_writer_object->specification='1.0';
$rss_writer_object->rssnamespaces['dc']='http://purl.org/dc/elements/1.1/';
$rss_writer_object->about='http://www.myownspace.fr/MyownRSS/myownnews.xml';
/*
	 *  Define the properties of the channel.
	 */
	$properties=array();
	$properties['description']='MyOwnSpace Community News';
	$properties['link']='http://www.myownspace.fr/';
	$properties['title']='MyOwnNews';
	$rss_writer_object->addchannel($properties);
$properties=array();
/// RE-FORMATAGE DU FICHIER DE CONFIG
$array='<? $myownnews=array(';
for($j=count($myownnews);$j>=1;$j--)
{

if($j==$nb){
///MISE A JOUR DU CONTENU EN .TXT
$blog=cleanhtml($_POST['blog']);
$file = "myownnews/news.".$nb.".txt";
writeTXT($file ,$blog);
@chmod ($file, 0777);

////////////////////////////////
$titre=cleanhtml($_POST['titre']);
echo $titre;
$date=$_POST['date'];
$user=$user;
}
else{
$txtfile="myownnews/news.".$j.".txt";
$blog=file_get_contents($txtfile);
$titre=$myownnews[$j]['titre'];
$user=$myownnews[$j]['author'];

$date=$myownnews[$j]['date'];
}
/// ADD ITEM TO RSS
	$properties['description']=$blog;
	$properties['link']='http://www.myownspace.fr/news.php';
	$properties['title']=$myownnews[$j]['titre'];
	$properties['dc:date']=$myownnews[$j]['date'];
	$properties['dc:creator']=$myownnews[$j]['author'];
	$properties['dc:publisher']='http://myownspace.fr/'.$myownnews[$j]['author'];
	$rss_writer_object->additem($properties);
///**************** PRINT
$array.='"'.$j.'" => array 
("titre"=>"'.$titre.'", 
"author"=>"'.$user.'",
"date"=>"'.$date.'"),
';
}
/*
	 *  When you are done with the definition of the channel items, generate RSS document.
	 */
	if($rss_writer_object->writerss($output))
	{
	writeTXT($RSSfile,$output);
	echo"<pre><i>(Mise a jour du RSS!)</i></pre>";
	}
	else echo '<pre>Error: '.$rss_writer_object->error.'</pre>';
	
$array.=');?>';
//// SAUVEGARDE DE LA MODIF

writeTXT($conf_file ,$array);
@chmod($file,0777);

echo '<H4>Saved!</H4><br><a href="myownnews.php?go='.$go.'">Back to myownnews!</a><br><br>';

}
else   ////////////// affiche un formulaire de sélection
{

//************************************
 // Start Putting String Together, Starting With Form Tags
$dropmenu = "<p><form name=\"otherpages\" action=\"myownnews.php\" method=\"GET\">\n";
$dropmenu .= "<select name=\"pic\" size=\"1\" class=\"user\" onChange=\"document.otherpages.submit()\">\n";
$p=count($myownnews);
$dropmenu .= "<option value=\"\" selected>MyOwnNews (".$p.")..</option>\n";

for ($i=1;$i<=$p;$i++) {
// Loop Through The Array To Build The String And Drop Down List
if($rawuser==$myownnews[$i]['author']) $dropmenu .= "<option value=".$i.">".$myownnews[$i]['titre']."</option>\n";
}
// Finish Putting Together The String
$dropmenu .= "</select>&nbsp;\n";
$dropmenu .= "<input type=\"hidden\" name=\"go\" value=\"".$_GET['go']."\"><input type=\"submit\" value=\"EDIT THIS PUBLIC ANNOUCE\" class=\"user\"></FORM>\n"; 
$page= '<H1>MyOwnNews</H1>
<p>Here you can annouce your public news,events, meetings to the MyOWNSpace community!</br><b>This news will be posted in the main <a href="/news.php">News</a> page of MyOWNSpace!</b></p>
</form>'.$dropmenu.'<form name="newblog" action="myownnews.php" method="GET"><input type="hidden" name="go" value="'.$go.'"><input type="hidden" name="new"><input type="submit"  value="POST a new ANNOUCEMENT" class="user"></FORM><FORM name="clean" action="myownnews.php" method="POST">';
for($i=1;$i<=(count($myownnews));$i++)
{
$txtfile="myownnews/news.".$i.".txt";

$array.='"'.$i.'" => array 
("titre"=>"'.$myownnews[$i]['titre'].'", 
"blog"=>"'.file_get_contents($txtfile).'", 
"date"=>"'.$myownnews[$i]['date'].'"), 
';

$code= '<pre>'.file_get_contents($txtfile).'</pre>
<br><font style="line-height:12px; font-size:11px; font-family:verdana,arial,sans-serif;">
<b>'.$myownnews[$i]['titre'].'</b></font></td><td  >
';
}
if($_GET['pic']!="") 
{

$n=$_GET['pic'];
$txtfile="myownnews/news.".$n.".txt";
$page .='<fieldset><legend><b>Edit YourOwnNews !</b></legend>
<FORM name="add" action="myownnews.php" method="POST">
<br>
<label>Title :</label><br><input type="text" size="70" name="titre" value="'.$myownnews[$n]['titre'].'"><br>
<script type="text/javascript" src="classes/FCKeditor/fckeditor.js"></script>&nbsp;
<script type="text/javascript">
var fckloaded = 1;
window.onload = function()
{
	var oFCKeditor = new FCKeditor( \'blog\' ) ;
	oFCKeditor.Height = 400;
	oFCKeditor.BasePath	= "classes/FCKeditor/" ;
	oFCKeditor.ReplaceTextarea() ;
}
</script>
<textarea style="color:black;" name="blog" cols="70" rows="20">
'.file_get_contents($txtfile).'</textarea><br>';
$page .='<span><input type="hidden" name="date" value="'.$myownnews[$n]['date'].'" >
<input type="hidden" name="go" value="'.$go.'" ></span>
<input type="hidden" name="change" value="'.$n.'">
<input type="submit" value="SAVE YourOwnCHANGE"></FORM></fieldset>';

$page.='
<table width="158" height="" cellspacing="0" cellpadding="0" border="0">
<tr >
<td width="158" height="116" align="left" valign="middle">
<table width="158" height="114" cellspacing="0" cellpadding="0" border="0" bgcolor="#ffffff">
<tr><td>
<font style="line-height:12px; font-size:11px; font-family:verdana,arial,sans-serif;">
<fieldset><legend><b>'.$myownnews[$n]['titre'].'</b></legend></font>
<br><pre><small>['.$myownnews[$n]['date'].']</small></pre><p>'.file_get_contents($txtfile).'</p>
</fieldset></td></tr></table>
</td></tr></table><HR>';}
//echo $txtfile;
echo $page;
if (isset($_GET['new'])||$firstblog==1){
$date=date("d M Y");
echo '<fieldset><legend><b>Add YourOwnNEWS!</b></legend>
<FORM name="add" action="myownnews.php" method="POST">
<br>
<label>Title:</label><br><input type="text" size="50" name="titre" ><br>
<script type="text/javascript" src="classes/FCKeditor/fckeditor.js"></script>&nbsp;
<script type="text/javascript">
var fckloaded = 1;
window.onload = function()
{
	var oFCKeditor = new FCKeditor( \'blog\' ) ;
	oFCKeditor.Height = 400;
	oFCKeditor.BasePath	= "classes/FCKeditor/" ;
	oFCKeditor.ReplaceTextarea() ;
}
</script>
<label>NEWS:</label><BR><textarea style="color: black;" name="blog" cols="70" rows="20"></textarea><br>
<input type="hidden" name="go" value="'.$_GET['go'].'" ><br>
<input type="hidden" name="date" value="'.$date.'">
<input type="hidden" name="add" value="'.$i.'">
<input type="submit" value="ADD TO myownnews!"></FORM></fieldset><hr>';

}
}
}

?>
Return current item: MyOWNSpace