Retour au WoSiBlog Installer le WoSiBlog

Source générée par la fonction show_source("image.php")


<?php
$email 
"gilles.gonon@free.fr";  /* Email du bloggueur  */ 
$alias "Gilles";      /* Alias qui apparaît pour l'email du bloggueur  */ 
$windowtitle "Les images du Pérou";            /* Titre de la fenetre */
 
$entete "Les images du 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('im_debut'$_GET)) {  $im_debut htmlspecialchars($_GET["im_debut"]); } else { $im_debut ''; }
if (
array_key_exists('im_fin'$_GET)) {  $im_fin htmlspecialchars($_GET["im_fin"]); } else { $im_fin ''; }

if (empty(
$im_debut))
{    
  
$im_debut 0;
}
else
{
 
$im_debut intval($im_debut);
}
if (empty(
$im_fin))
{
    
$im_fin 10;
}
else
{
 
$im_fin intval($im_fin);
}
    
echo 
"<HTML>";
  echo 
"<HEAD><TITLE>$windowtitle</TITLE>";
  include(
"stylesheet_blog.txt");
  echo 
"<link rel=\"shortcut icon\" href=\"$icon\" />";
  echo 
"</HEAD>";
  echo 
"<BODY>";

/* echo "action $action, theme = $num_theme"; */
  /******************/
 /* Voir la source */
/******************/
if ($action == "showsource")
{
  echo 
"<table width=\"100%\" cols=2><tr><td><a href=\"image.php\">Retour au WoSiBlog </a></td>";
  echo 
"<td algin=\"right\"><a href=\"../equateur/installation.html\">Installer le WoSiBlog</a></td></tr></table>";
  echo 
"<p> Source générée par la fonction show_source(\"image.php\") </p> <hr>";
  
show_source("image.php");
  echo 
"<br> <hr 100%> <a href=\"image.php\"> Retour au site</a>"
}
  
/******************/
 /*  Voir le Blog  */
/******************/
else
{
    
$dir_img "./images/";
    
$liste Cherche_Rep($dir_img); 
    
$nblignes sizeof($liste);
    if (
$im_fin == 10)
    {
        
$im_fin min($nblignes,10);
    }
    
      
/*************************************************************/
     /*                    MISE EN PAGE HTML                      */
    /*************************************************************/
    
Entete_Page($entete);
    
Barre_Navigation($email);

    
// Table de 3 colonnes pour le corps de la page
    
echo"<table BORDER=0 COLS=2 WIDTH=\"100%\" CELLPADDING=\"0\"  CELLSPACING=\"5\">";
        
      
/****************/
     /* 1ere colonne */
    /****************/
    
echo "<tr><td WIDTH=180 valign=\"TOP\">";
    
    
Navigation_Gauche($liste,$dir_img,$im_debut,$im_fin);
    
/* Who_Am_I(); */
    
    
echo "</td>";
  
       
/***************************************************************/
        /* 2eme colonne Par défaut, on affiche les 10 dernieres images */
       /***************************************************************/
    
echo "<td valign=\"TOP\">";
    if (
$im_fin == 0)
    {
        
$im_fin min($nblignes,10);
    }
    
Gallerie_Image($dir_img,$liste,$im_debut,$im_fin);

    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 Cherche_Rep($basedir)
{
 
$handleopendir($basedir); 
 
$i 0;
 while (
$fichier readdir($handle))  
   { 
     
/* Pour les images jpg, les vignettes se terminent par nomfichier_t.jpg */
     /* c'est la cas des vignettes faites par irfanview */
     
if (!is_dir($basedir.$fichier) & !is_integer(strpos($fichier,"_t.jpg")) & !is_integer(strpos($fichier,".html")))
       {
        
$img_info getimagesize($basedir.$fichier);
          
//echo "<br>$fichier";
        
if ($img_info != null
         {
          
$h $img_info[1]; $w $img_info[0];
          
$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\">Résumé des articles</a></td>";
     echo 
"<td align=\"center\" ><a class=\"barre_nav\" href=\"image.php\" title=\"des images ...\">Quelques 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,$im_debut,$im_fin)

  
$nblignes=sizeof($list); 
  
$texte "$nblignes Images";

  echo 
"<div class=\"title\">$texte:</div>";
  echo 
"<div id=\"content\"><p>";
  
$compteur 0;
  for ( 
$i $im_debut$i $nblignes$i++ )
    {
      
$img_ext = array(".jpg",".JPG",".JPEG",".gif",".GIF",".PNG",".png");
        
$ext_supr = array(""   ,""    ,""     ,""    ,""    ,""    ,""    );
        
$txt_lien str_replace($img_ext,$ext_supr,$list[$i]);
      
$txt_lien str_replace("_"," ",$txt_lien);
      
$title $list[$i];
      if (
strlen($txt_lien)>20)
      {
       
$txt_lien substr($txt_lien,0,17)."...";
      }

     echo 
"<table width=180 BORDER=0 COLS=2 CELLPADDING=0 CELLSPACING=0><tr>";
     echo 
"<td width=\"80%\">";
     echo 
Lien_Pop_Up_Image("$dir$list[$i]",$txt_lien,$title);
     echo 
"</td>";
     echo 
"<td align=\"right\"><p class=\"date\">".Image_Size("$dir$list[$i]")."</p></td>";
     echo 
"</tr></table>";
     }
  echo 
"</p><center><p>";
  
/* 
  $prev_debut = max(0,$im_debut-10); $prev_fin = min($nblignes,$prev_debut+10);
  $next_debut = min($nblignes,$im_debut+10); $next_fin =  min($nblignes,$next_debut+10);
  
  if ($im_debut>0)
  {
    echo "<a href=\"image.php?im_debut=$prev_debut&im_fin=$prev_fin \"><< -10 img</a>";
  }
  else
  {
    echo "<< -10 img";
  }
    echo " | ";
  if ($im_fin<$nblignes)
  {
    echo "<a href=\"image.php?im_debut=$next_debut&im_fin=$next_fin\">+10 img >></a>";
  }
  else
  {
    echo "+10 img >>";
  }

  */

  
echo "</p><p>";
  if (
$im_debut==$im_fin==$nblignes)
  {
    
$f min(10,$nblignes);
      echo 
"<a href=\"image.php?im_debut=$im_debut&im_fin=$f\">Voir les vignettes par 10</a>";
  }
  else
  {
      echo 
"<a href=\"image.php?im_debut=0&im_fin=$nblignes\">Voir toutes les vignettes</a>";
    echo 
"<br>!!! ça peut être long !!!";
  }
   echo 
"</p></center></div>";

};


Function 
Gallerie_Image($dir,$liste,$im_debut,$im_fin)
{
  
$nblignes sizeof($liste);
  echo 
"<div class=\"title\"><center>";
  
$prev_debut max(0,$im_debut-10); $prev_fin min($nblignes,$prev_debut+10);
  
$next_debut min($nblignes,$im_debut+10); $next_fin =  min($nblignes,$next_debut+10);
  
  if (
$im_debut>0)
  {
    echo 
"<a href=\"image.php?im_debut=$prev_debut&im_fin=$prev_fin \" ><< voir les 10 images précédentes</a>";
  }
  else
  {
    echo 
"début de liste";
  }
    echo 
" | ";
  if (
$im_fin<$nblignes)
  {
    echo 
"<a href=\"image.php?im_debut=$next_debut&im_fin=$next_fin\">voir les 10 images suivantes >></a>";
  }
  else
  {
    echo 
"fin de liste";
  }
   echo 
"</div>";    
  
/*echo "</center></div>";
  echo "<div id=\"title_article\">";
    echo "<b>Images : </b>";
    //echo ", ".My_Date($info_news[3]);
 
  */
  
echo "<table BORDER=0 COLS=4 WIDTH=\"100%\" CELLPADDING=5  CELLSPACING=5><tr>";
  
  for (
$i=$im_debut;$i<$im_fin;$i++)
  { 
      
$img_ext = array(".jpg",".JPG",".JPEG",".gif",".GIF",".PNG",".png");
      
$ext_supr = array(""   ,""    ,""     ,""    ,""    ,""    ,""    );
      
$lien str_replace($img_ext,$ext_supr,$liste[$i]);
    
$lien str_replace("_"," ",$lien)."<br>".Image_Size("$dir$liste[$i]");
    
$vignette str_replace(".jpg","_t.jpg","$dir$liste[$i]");
    if (
file_exists($vignette))
    { 
      
$lien "<div class=\"image\"><img src=\"$vignette\"></div>".$lien
    }
    else
    { 
      
$lien "<p>Pas<br>d'aperçu<br>pour<br>".$lien;
    }
    echo 
"<td align=\"center\">";
    echo 
Lien_Pop_Up_Image("$dir$liste[$i]","$lien",$liste[i]);
    echo 
"</td>";
    
/* On retourne à la ligne toutes les quatres images */
    
if (fmod($i-$im_debut+1,4) == 0)
    {
      echo 
"</tr><tr>";
    }
  }
  echo 
"</tr></table>";
 
};


Function 
Image_Size($file_name) {
 
$bytes filesize($file_name);
 
$types = Array("b","k","M","G","T");
 
$current 0;
 while (
$bytes 1024
 {
  
$current++;
  
$bytes /= 1024;
 }
 return 
round($bytes,0)." ".$types[$current];
};

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 
Lien_Pop_Up_Image($filename,$text_lien,$title)
{
 if (
file_exists($filename))
 {
$img_info getimagesize($filename);
  if (
$img_info != null
  {
    
$h $img_info[1]; $w $img_info[0];
    return 
"<a href=\"#\" title=\"$title\" onclick=\"javascript:window.open('$filename','Image','directories=0, height=$h, location=0, resizable=1, scrollbars=0, toolbar=0, width=$w');\">$text_lien</a>";
  }
  else
  { return 
"image non reconnnue"; }
 } 
 else
  { return 
"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: Bretagne";
 echo 
"<br>?tattoo : non<br>?trous : non plus<br>?photo : ";
 
$image "images/Gilles.jpg";
 echo 
Lien_Pop_Up_Image($image,"ici","moi");
};

Function 
Bas_De_Page($mail)
{   
  echo 
"<h1><p>Ceci est la version 2.0 du WoSiBlog. Il s'agit d'un projet 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
"<br>Vous pouvez <a href=\"image.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</p></h1>";
};
?>


Retour au site