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

include "login.inc.php";
include "config.php";
////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="myownblog/blog.".$go.".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()&&$myspace[$i]['owner']==$rawuser) {
include("header.php");

// EDITION DU BLOG
loged($rawuser);
echo "<b>".menu_options($go).
$blogdir="myownblog/$go";

$user=$rawuser;/*
if (!is_dir($blogdir)) { 
mkdir ($blogdir,0777);
$firstblog=1;
chown($blogdir, "1033");
chgrp($blogdir, "www-data") ;
chmod ($blogdir, 0777); } //CREATION D'1 DOSSIER blog POUR L'UTILISATEUR $go
echo "group:".filegroup ($blogdir)."<br>";
echo "owner:".fileowner ($blogdir)."<br>";*/
////////////////////////////////////////////
//+++++++++++++++++++++++++++AJOUT D'UN BLOG
////////////////////////////////////////////

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

$conf_file="myownblog/blog.".$go.".php";

include $conf_file;
//echo $conf_file;

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

$arrayconf='<? $myownblog=array(';
$myownblog[$n]['titre']=stripslashes($_POST['titre']);
//$myownblog[$n]['blog']= $file;
$myownblog[$n]['date']= date(r);

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

$arrayconf.=') ?>';
//echo '<PRE>'.$arrayconf.'</PRE>';
echo '<H4>Add this to conf file!</H4><br><a href="myownblog.php?pic='.$n.'&go='.$go.'">Back to myownBLOG</a>';
writeTXT($conf_file ,$arrayconf);

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

}

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

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

$nb=$_POST['change'];
/// RE-FORMATAGE DU FICHIER DE CONFIG
$array='<? $myownblog=array(';
for($j=1;$j<=count($myownblog);$j++)
{
if($j==$nb){
///MISE A JOUR DU CONTENU EN .TXT
$blog=stripslashes($_POST['blog']);
$file = "myownblog/blog.".$go.".".$nb.".txt";
writeTXT($file ,$blog);
chmod ($file, 0777);
change_update($go);
////////////////////////////////
$titre=cleanhtml($_POST['titre']);
echo $titre;
$date=$_POST['date'];
}
else{
$titre=stripslashes($myownblog[$j]['titre']);

$date=$myownblog[$j]['date'];
}

///**************** PRINT
$array.='"'.$j.'" => array 
("titre"=>"'.$titre.'", 
"date"=>"'.$date.'"),
';
}
$array.=');?>';
//// SAUVEGARDE DE LA MODIF

writeTXT($conf_file ,$array);
chmod($file,0777);
change_update($go);
echo '<H4>Saved!</H4><br><a href="myownblog.php?go='.$go.'">Back to myownBLOG!</a><br><br>';

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

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

for ($i=1;$i<=$p;$i++) {
// Loop Through The Array To Build The String And Drop Down List
$dropmenu .= "<option value=".$i.">".$myownblog[$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 BLOG\" class=\"user\"></FORM>\n"; 
$page= '<H3>MyOwnBlog</H3>
</form>'.$dropmenu.'<form name="newblog" action="myownblog.php" method="GET"><input type="hidden" name="go" value="'.$go.'"><input type="hidden" name="new"><input type="submit"  value="POST a new BLOG" class="user"></FORM><FORM name="clean" action="myownblog.php" method="POST">';
for($i=1;$i<=(count($myownblog));$i++)
{
$txtfile="myownblog/blog.".$_GET['go'].".".$i.".txt";
$titre[$i]=$myownblog[$i]['titre'];
$blog[$i]=file_get_contents($txtfile);
$date[$i]=$myownblog[$i]['date'];
$array.='"'.$i.'" => array 
("titre"=>"'.$titre[$i].'", 
"blog"=>"'.$blog[$i].'", 
"date"=>"'.$date[$i].'"), 
';

$code= '<pre>'.$blog[$i].'</pre>
<br><font style="line-height:12px; font-size:11px; font-family:verdana,arial,sans-serif;">
<b>'.$titre[$i].'</b></font></td><td  >
';
}
if($_GET['pic']!="") 
{
$n=$_GET['pic'];
$txtfile="myownblog/blog.".$_GET['go'].".".$n.".txt";
$page .='<fieldset><legend><b>Edit YourOwnBlog !</b></legend>
<FORM name="add" action="myownblog.php" method="POST">
<br>
<label>Title :</label><br><input type="text" size="70" name="titre" value="'.$myownblog[$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="'.$myownblog[$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>'.$myownblog[$n]['titre'].'</b></legend></font>
<br><pre><small>['.$myownblog[$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){
echo '<fieldset><legend><b>Add YourOwnBLOG !</b></legend>
<FORM name="add" action="myownblog.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>BLOG:</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="add" value="'.$i.'">
<input type="submit" value="ADD TO MyOwnBLOG!"></FORM></fieldset><hr>';

}
}
}
include("myowntip.html");
include("footer.php");
?>
Return current item: MyOWNSpace