» Liens

Rédigé par : Guillaume
Le : 20/03/2003 à 15:55
Hits : 6383
TéléchargerImprimer
Ceci vous permet d'afficher vos liens par exemple dans un popup. Sans base de donnée, les liens sont directement inscrits dans un fichier texte.

article_3.php
<?php
// ------------------------------------------------------------------------- //
// Liens                                                                     //
// ------------------------------------------------------------------------- //
// Le 20/03/2003 à 15h55 par Guillaume JIGUEL (guillaume@gphp.net)           //
// ------------------------------------------------------------------------- //
// http://www.gphp.net/articles,3.php                                        //
// ------------------------------------------------------------------------- //

// Configuration 
$title "Liens"
$fichier "liens.txt"

// Variables Globales + date 
$date date("d-m-Y"); 
$titre $_POST['Titre']; 
$nom $_POST['Nom']; 
$url $_POST['Url']; 
if ( !
ereg("^http://(.*)",$url) ) $url "http://".$url

// Entête HTML 
$html_on "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
$html_on .= "<html>\n"
$html_on .= "<head>\n"
$html_on .= "<title>$title</title>\n"
$html_on .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"

// Feuille de style 
$css .= "<style type=\"text/css\">\n"
$css .= ".liens {font:12px Arial;color:#000080;text-decoration:none}\n"
$css .= ".liens:hover {font:12px Arial;color:#FF0000;text-decoration:underline}\n"
$css .= ".nom {background-color:#CCCCCC;font:12px Arial;color:#000080}\n"
$css .= ".titre {background-color:#EEEEEE;font:bold 12px Arial;color:#000000}\n"
$css .= ".date {background-color:#CCCCCC;font:10px Arial;color:#000080}\n"
$css .= ".texte {background-color:#CCCCCC;font:bold 12px Arial;color:#000080}\n"
$css .= "</style>\n"

// Fin head 
$html_mi .= "</head>\n"
$html_mi .= "<body>\n"

// Fin HTML 
$html_off "</body>\n"
$html_off .= "</html>\n"

// Définition de la table contenant les titres de rubriques 
$table_on "<table border=\"0\" id=\"Liens\">\n"
$table_on .= "<tr bgcolor=\"#EEEEEE\"><td class=\"titre\">Date</td><td class=\"titre\">Nom</td><td class=\"titre\">Titre</td><td class=\"titre\">Url</td></tr>\n"
$table_off "</table><br />\n"

// Définition du lien 
$lien "<tr bgcolor=\"#cccccc\">"
$lien .= "<td class=\"date\">[$date]</td>"
$lien .= "<td class=\"nom\">$nom</td>"
$lien .= "<td class=\"texte\">$titre</td>"
$lien .= "<td class=\"texte\"><a href=\"$url\" target=\"_blank\" class=\"liens\">$url</a></td>"
$lien .= "</tr>"

// Définition du formulaire 
$form "<form name=\"Form\" method=\"POST\" action=\"$PHP_SELF\"><font color=\"#999999\" size=\"1\" face=\"Arial, Helvetica, sans-serif\">\n"
$form .= "<input type=\"text\" name=\"Nom\"><-- nom<br>\n"
$form .= "<input type=\"text\" name=\"Titre\"><-- titre<br>\n"
$form .= "<input type=\"text\" name=\"Url\"><-- url<br>\n"
$form .= "<input type=\"hidden\" name=\"Envoi\" value=\"OK\">\n"
$form .= "<input type=\"submit\" name=\"Submit\" value=\"Envoyer\">\n"
$form .= "</font></form>\n"

// Traitement du formulaire si la $var Envoi par POST est égale à OK alors on écris dans le fichier.txt 
if ($_POST['Envoi'] == "OK"){ 
$ouverture fopen("$fichier","a+"); 
fwrite($ouverture$lien); 
fclose($ouverture); 


// Affichage title + entête html/css, on require le fichier.txt, introduit le formulaire et on ferme le html 
echo "<a style=\"font:bold 30px Arial\">$title</a><br />"
echo 
$html_on.$css.$html_mi.$table_on
require 
$fichier
echo 
$table_off.$form.$html_off
?> 

» Commentaires

Pas de commentaires.

Vous devez être connecté en tant que Membre pour pouvoir poster un commentaire, Inscrivez vous ici !