Retour au WoSiBlog | Installer le WoSiBlog |
Source générée par la fonction show_source("index.php")
<?php
$email = "gilou.gonon@wanadoo.fr"; /* Email du bloggueur */
$alias = "Gilles"; /* Alias qui apparaît pour l'email du bloggueur */
$windowtitle = "Carnet de route du voyage au Pérou, par Gilles"; /* Titre de la fenetre */
$entete = "Carnet de route du voyage au Pérou"; /* Texte de l'entête */
/* $entete = "<img src=\"boutons/entete_journal.png\">"; pour mettre une image, par ex.*/
$icon = "boutons/icone_site_16.ico";
// Récupération des variables GET
if (array_key_exists('action', $_GET)) { $action = htmlspecialchars($_GET["action"]); } else { $action = ''; }
if (array_key_exists('choix', $_GET)) { $choix = htmlspecialchars($_GET["choix"]); } else { $choix = ''; }
if (array_key_exists('num_theme', $_GET)) { $num_theme = htmlspecialchars($_GET["num_theme"]); } else { $num_theme = ''; }
if (array_key_exists('article_num', $_GET)) { $article_num = htmlspecialchars($_GET["article_num"]); } else { $article_num = ''; }
if (empty($action))
{
$action="resume";
}
if (empty($num_theme))
{
$num_theme = "0";
}
echo "<HTML>";
/* echo "action $action, theme = $num_theme"; */
/******************/
/* Voir la source */
/******************/
if ($action == "showsource")
{
echo "<HEAD><TITLE>$windowtitle</TITLE>";
include("stylesheet_blog.txt");
echo " <link rel=\"shortcut icon\" href=\"$icon\">";
echo "</HEAD>";
echo "<BODY>";
echo "<table width=\"100%\" cols=2><tr><td><a href=\"index.php\">Retour au WoSiBlog </a></td>";
echo "<td algin=\"right\"><a href=\"installation.html\">Installer le WoSiBlog</a></td></tr></table>";
echo "<p> Source générée par la fonction show_source(\"index.php\") </p> <hr>";
show_source("index.php");
echo "<br> <hr 100%> <a href=\"index.php\"> Retour au WoSiBlog </a>";
}
elseif ($action == "imprimer")
{
echo "<HEAD>";
include("stylesheet_print.txt");
echo " <link rel=\"shortcut icon\" href=\"$icon\">";
echo "</HEAD>";
echo "<BODY>";
$dirnews = "./news/";
$liste = ChercheRep($dirnews);
$i = intval($article_num)-1;
$article = Analyse_News($dirnews,$liste[$i]);
Affiche_Article($article,$action);
} /******************/
/* Voir le Blog */
/******************/
else
{
$dirnews = "./news/";
$liste = ChercheRep($dirnews);
$nblignes = sizeof($liste);
/*************************************************************/
/* MISE EN PAGE HTML */
/*************************************************************/
echo "<HEAD><TITLE>$windowtitle</TITLE>";
include("stylesheet_blog.txt");
echo " <link rel=\"shortcut icon\" href=\"$icon\">";
echo "</HEAD>";
echo "<BODY>";
Entete_Page($entete);
Barre_Navigation($email);
// Table de 3 colonnes pour le corps de la page
echo"<table BORDER=0 COLS=3 WIDTH=\"100%\" CELLPADDING=\"0\" CELLSPACING=\"5\">";
/****************/
/* 1ere colonne */
/****************/
echo "<tr><td WIDTH=180 valign=\"TOP\">";
Navigation_Gauche($liste,$dirnews,$num_theme);
//Who_Am_I();
echo "</td>";
/***************************************************************/
/* 2eme colonne Par défaut, on affiche les résumés des articles*/
/***************************************************************/
echo "<td valign=\"TOP\">";
/* echo "action $action, theme = $num_theme, $nblignes lignes"; */
$compteur = 0;
if ($action == "resume")
{
for ( $i = 0; $i < $nblignes ; $i++ )
{
$nom = str_replace(".txt","",$liste[$i]);
$info_news = Analyse_News($dirnews,$liste[$i]);
if ($choix=="theme")
{
/* Si on choisit de voir les articles par thème, on affiche que le thème concerné */
if (is_integer(strpos($info_news[4],$num_theme)))
{
Affiche_Resume($info_news,$num_theme,$i+1);
$compteur++;
}
}
else
{
Affiche_Resume($info_news,$num_theme,$i+1);
$compteur++;
}
}
if ($compteur==0) {echo "<p>.. Pas d'article ..</p>";}
}
elseif ($action == "view_article")
{
$i = intval($article_num)-1;
$article = Analyse_News($dirnews,$liste[$i]);
Affiche_Article($article,$action);
/* Ajout de la version imprimable ci dessous */
echo "<p></p><div align=\"right\">";
$impression = "index.php?action=imprimer&article_num=$article_num";
// echo "<a href=\"#\" onclick=\"javascript:window.open($impression,'Version pour impression','directories=0, height=500, location=0, resizable=1, scrollbars=1, toolbar=1, width=400');\">";
echo "<a href=\"$impression\" target=\"blank\">Version imprimable</a></div>";
}
echo "</td>";
/****************/
/* 3eme colonne */
/****************/
echo "<td WIDTH=180 valign=\"TOP\">";
Navigation_Droite($liste,$dirnews,$num_theme);
Mes_Liens();
echo "</td></tr></table>";
/* Notes de bas de page */
Bas_De_Page($email);
}
echo "</BODY>";
echo "</HTML>";
/*************************************************************/
/* FIN DE MISE EN PAGE HTML */
/*************************************************************/
/* Fonction qui prend en compte */
Function ChercheRep($basedir)
{
$handle= opendir($basedir);
$i = 0;
while ($fichier = readdir($handle))
{
$is_backup = strpos($fichier,".txt~");
$isstring = strpos($fichier,".txt");
if (is_integer($isstring) & !is_integer($is_backup))
{
$date[$i] = filemtime($basedir.$fichier);
$nom[$i] = $fichier;
$i++;
}
}
arsort($date);
$i=0;
while (list ($key, $val) = each ($date))
{
$liste[$i++] = $nom[$key];
}
return $liste;
};
Function Analyse_News($basedir,$news)
{
$filename=$basedir.$news;
$fid = fopen($filename,"r");
$file = fread($fid,filesize ($filename));
fclose ($fid);
/* Extraction of subject, title and text */
$mottopic = "Topic:";
$mottitle = "Sujet:";
$motsum = "Abstract:";
$mottxt = "Texte:";
$where_topic = strpos($file,$mottopic);
$where_title = strpos($file,$mottitle);
$where_summary = strpos($file,$motsum);
$where_texte = strpos($file,$mottxt);
/* Analyzed is an array containing */
// $analyzed[0] Title of article
// $analyzed[1] Summary of article
// $analyzed[2] Text of article
// $analyzed[3] date of article
// $analyzed[4] Theme of article
$i = 0;
$analyzed[$i++] = substr($file,$where_title+strlen($mottitle),$where_summary-$where_title-strlen($mottitle));
$analyzed[$i++] = substr($file,$where_summary+strlen($motsum),$where_texte-$where_summary-strlen($motsum));
$analyzed[$i++] = substr($file,$where_texte+strlen($mottxt),strlen($file)-$where_texte);
$analyzed[$i++] = filemtime($filename);
if (is_integer($where_topic))
{
$analyzed[$i] = substr($file,$where_topic+strlen($mottopic),$where_title-$where_topic-strlen($mottopic));
$analyzed[$i] = str_replace(" ","",$analyzed[$i]);
$i++;
}
else
{
$analyzed[$i++] = "Autre ";
}
return $analyzed;
};
Function Barre_Navigation($email)
{
echo "<div id=\"barre_nav\">";
echo "<center><table BORDER=0 COLS=4 WIDTH=\"70%\" CELLPADDING=0 CELLSPACING=0><tr>";
echo "<td align=\"center\" ><a class=\"barre_nav\" href=\"index.php\" title=\"Résumé de tous les articles\">En bref ...</a></td>";
echo "<td align=\"center\" ><a class=\"barre_nav\" href=\"image.php\" title=\"des images ...\">Photos</a></td>";
echo "<td align=\"center\" ><a class=\"barre_nav\" href=\"mailto:$email\" title=\"Envoyez un commentaire\">Ecrivez moi</a></td>";
// echo "<td align=\"center\" ><a href=\"#\" >Rien</a></td>";
echo "</tr></table></center>";
echo "</div>";
};
Function Navigation_Gauche($list,$dir,$theme)
{
$nblignes=sizeof($list);
if ($theme=="0")
{
$texte = "$nblignes Articles";
}
else
{
$texte = $theme;
}
echo "<div class=\"title\">$texte:</div>";
echo "<div id=\"content\"><p>";
$compteur = 0;
for ( $i = 0; $i < $nblignes ; $i++ )
{
$info_news = Analyse_News($dir,$list[$i]);
$txt_date = My_Date($info_news[3],"resume");
if (is_integer(strpos($info_news[4],$theme)))
{
$val = $i + 1;
echo "<a href=\"index.php?choix=theme&action=view_article&article_num=$val&num_theme=$theme\" >$txt_date</a><br>";
$compteur++;
} if ($theme=="0")
{
$val = $i + 1;
echo "<table width=180 BORDER=0 COLS=2 CELLPADDING=0 CELLSPACING=0><tr>";
echo "<td><a href=\"index.php?action=view_article&article_num=$val\" >$info_news[4]</a></td>";
echo "<td align=\"right\"><p class=\"date\">$txt_date</p></td>";
echo "</tr></table>";
}
}
echo "</p></div>";
if ($theme!="0")
{
echo "<div class=\"title\">$compteur articles.</div>";
}
echo "<p align=\"right\">".Date("d M Y | H:i:s")."</p>";
};
Function Affiche_Resume($info_news,$theme,$val)
{
echo"<table BORDER=0 COLS=2 WIDTH=\"100%\" NOSAVE CELLPADDING=\"0\" CELLSPACING=\"0\">";
echo "<tr><td WIDTH=\"70%\" valign=\"top\">";
echo "<div id=\"title_article\">";
if (is_integer(strpos($info_news[4],$theme)))
{
$lien = "index.php?choix=theme&action=view_article&article_num=$val&num_theme=$theme";
}
if ($theme=="0")
{
$lien = "index.php?action=view_article&article_num=$val";
}
echo "<a href=\"$lien\">$info_news[4] : </a>";
echo "$info_news[0]";
echo "</div>";
echo "</td><td align=\"right\" valign=\"top\">";
echo "<div id=\"title_article\">";
echo My_Date($info_news[3],"normal");
echo "</div>";
echo "</td></tr></table>";
echo "<div id=\"resume\">";
echo "<table><tr><td>";
echo "<p>$info_news[1]</p>";
echo "<p><a href=\"$lien\">.:Lire l´article:. </a></p></td></tr></table>";
echo "</div>";
};
Function Affiche_Article($info_news,$action)
{
if ($action=="imprimer")
{
echo "<div id=\"title_article\">";
echo "<b>$info_news[4] : </b>";
echo "$info_news[0]";
echo ", ".My_Date($info_news[3],normal);
echo "</div>";
}
else
{
echo"<table BORDER=0 COLS=2 WIDTH=\"100%\" NOSAVE CELLPADDING=\"0\" CELLSPACING=\"0\">";
echo "<tr><td WIDTH=\"70%\" valign=\"top\">";
echo "<div id=\"title_article\">";
echo "<b>$info_news[4] : </b>";
echo "$info_news[0]";
echo "</div>";
echo "</td><td align=\"right\" valign=\"top\">";
echo "<div id=\"title_article\">";
echo My_Date($info_news[3],"normal");
echo "</div>";
echo "</td></tr></table>";
}
echo "<div id=\"article\">";
echo "<table><tr><td>";
$corps_article = Replace_Pop_Up($info_news[2]);
echo "<p>$corps_article</p>";
echo "</td></tr></table>";
echo "</div>";
};
Function Navigation_Droite($list,$dir,$theme)
{
$i = 0;
$liste_theme[$i++] = "Quotidien";
$liste_theme[$i++] = "Infos";
$liste_theme[$i++] = "Pays";
$liste_theme[$i++] = "Anecdotes";
$liste_theme[$i++] = "Autre";
echo "<div class=\"title\">Thématiques:</div>";
echo "<div id=\"content\">";
$nb = sizeof($liste_theme)+1;
for ($i=0; $i<$nb; $i++)
{
echo "<a href=\"index.php?choix=theme&num_theme=$liste_theme[$i]\">$liste_theme[$i]</a>";
if ($i<$nb-1) {echo "<br>";}
}
echo "</div>";
};
Function Entete_Page($texte)
{
// Table pour l'entete de la page
echo"<table BORDER=0 COLS=1 WIDTH=\"100%\" NOSAVE CELLPADDING=\"0\" CELLSPACING=\"0\">";
echo "<tr><td align=\"CENTER\">";
/* Ici Changer l'entete (lien vers une image, ...) */
/***********************************************************/
echo "<h1>$texte</h1>";
echo "</td></tr></table>";
};
Function My_Date($timestamp,$type)
{
// $timestamp += strtotime("Tuesday 7/15/2003 17:28") - strtotime("Thursday 1/14/1971 15:27");
// echo "<br>".date("l n/j/Y H:i",$offset_time_free);
$jour[0]="dimanche";
$jour[1] = "lundi";
$jour[2] = "mardi";
$jour[3] = "mercredi";
$jour[4] = "jeudi";
$jour[5] = "vendredi";
$jour[6] = "samedi";
$mois[1] = "Janv"; $mois[2] = "Fév";
$mois[3] = "Mars"; $mois[4] = "Avril";
$mois[5] = "Mai"; $mois[6] = "Juin";
$mois[7] = "Juil"; $mois[8] = "Aout";
$mois[9] = "Sept"; $mois[10] = "Oct";
$mois[11] = "Nov"; $mois[12] = "Déc";
$day = $jour[intval(date(w,$timestamp))];
$month = $mois[intval(date(n,$timestamp))];
if ($type == "resume")
{
$date_formatted = date("G",$timestamp)."h".date("i",$timestamp).", le ".date("j-n",$timestamp);
}else
{
$date_formatted = date("H",$timestamp)."h".date("i, ",$timestamp).$day.date(" d ",$timestamp).$month;
}
return $date_formatted;
};
Function Replace_Pop_Up($texte)
{
$tableau = explode("!Pop_Up!",$texte);
if (sizeof($tableau)==1)
{
$texte_final = $texte;
}
else
{
$texte_final = "";
for ($i=0;$i<sizeof($tableau);$i=$i+2)
{
$texte_final = $texte_final.$tableau[$i];
if (sizeof($tableau)>$i+1)
{
$infos_lien = explode("!",$tableau[$i+1]);
$texte_final = $texte_final.Lien_Pop_Up_Image("images/".$infos_lien[0],$infos_lien[1]);
}
}
}
return $texte_final;
};
Function Lien_Pop_Up_Image($filename,$text_lien)
{
if (file_exists($filename))
{$img_info = getimagesize($filename);
if ($img_info != null)
{
$h = $img_info[1]; $w = $img_info[0];
return "<a href=\"#\" onclick=\"javascript:window.open('$filename','Image','directories=0, height=$h, location=0, resizable=1, scrollbars=1, toolbar=0, width=$w');\">$text_lien</a>";
}
else
{ return "$text_lien (image non reconnnue)"; }
}
else
{ return "$text_lien (image inexistante)"; }
};
Function Who_Am_I()
{
echo"<div class=\"title\">?Qui suis-je</div>";
echo "<div id=\"content\"><p>?nom : Gilou<br>?age : 40+";
echo "<br>?taille : 1.79<br>?yeux : verts (les 2)<br>?Zone: Tinténiac";
echo "<br>?tattoo : non<br>?trous : non plus<br>?photo : ";
$image = "images/Gallilee_2.jpg";
echo Lien_Pop_Up_Image($image,"ici");
};
Function Mes_Liens()
{
echo"<div class=\"title\">Liens:</div>";
echo "<div id=\"content\"><p>";
echo "<a href=\"../index.html\" title=\"Retour à l'accueil\">Accueil</a>";
echo "<br><a href=\"https://gueulomaton.org/\" title=\"Site du Gueulomaton\">Site professionnel</a>";
echo "<br><a href=\"http://gilles.gonon.free.fr/\" title=\"Site Gilles Gonon Free Fr\">Site perso</a>";
echo "</p></div>";
};
Function Bas_De_Page($mail)
{
echo "<h1><p>Ceci est la version 2.0 du WoSiBlog. Il s'agit d'un weblog, sans base de données. Le projet est open source donné sous <a href=\"http://www.gnu.org\">licence GPL</a>. Ce projet est initié par";
echo " <a href=\"mailto:$mail\">Gilouzz</a>.";
echo " Vous pouvez <a href=\"index.php?action=showsource\">voir la source</a> composée d'un unique fichier PHP. Une <a href=\"../equateur/installation.html\">page d'intallation</a> explique également comment récupérer et installer le WoSiBlog.";
echo "<br>... et c'est plus joli avec <a href=\"http://www.mozilla.org\">Mozilla</a>. Enfin <a href=\"../equateur/make_article\">modèle</a> pour poster un article (attention au traits)";
echo "<br><div align=\"right\"><a href=\"index_old_browser.php\">Thème graphique pour faibles résolutions (TX)</a> </div></p></h1>";
};
?>