From c56e3b3b4da3b311e9dfebb836cadfab10d29e0b Mon Sep 17 00:00:00 2001 From: Simon Leblanc Date: Fri, 20 May 2011 02:52:22 +0200 Subject: [PATCH] Clean URL and add title of poll in head --- admin/index.php | 2 +- adminstuds.php | 10 +++++----- bandeaux.php | 4 ++-- creation_sondage.php | 19 ++++++++++++++----- fonctions.php | 43 ++++++++++++++++++++++++++++++++++++++----- studs.php | 2 +- 6 files changed, 61 insertions(+), 19 deletions(-) diff --git a/admin/index.php b/admin/index.php index e98749f..dc4a77e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -124,7 +124,7 @@ while($dsondage = $sondage->FetchNextObject(false)) { echo''.$nbuser.''."\n"; echo ''. _("See the poll") .''."\n"; - echo ''. _("Change the poll") .''."\n"; + echo ''. _("Change the poll") .''."\n"; echo ''."\n"; echo ''."\n"; diff --git a/adminstuds.php b/adminstuds.php index 1f0dd94..f806f72 100644 --- a/adminstuds.php +++ b/adminstuds.php @@ -117,7 +117,7 @@ if (isset($_POST["boutonnouveautitre"])) { mail ($adresseadmin, _("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION, _("You have changed the title of your poll. \nYou can modify this poll with this link") . - " :\n\n".get_server_name()."/adminstuds.php?sondage=$numsondageadmin\n\n" . + " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, $headers); @@ -135,7 +135,7 @@ if (isset($_POST["boutonnouveauxcommentaires"])) { mail ($adresseadmin, _("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION, _("You have changed the comments of your poll. \nYou can modify this poll with this link") . - " :\n\n".get_server_name()."/adminstuds.php?sondage=$numsondageadmin \n\n" . + " :\n\n".getUrlSondage($numsondageadmin, true)." \n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, $headers); @@ -154,7 +154,7 @@ if (isset($_POST["boutonnouvelleadresse"])){ mail ($_POST['nouvelleadresse'], _("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION, _("You have changed your email address in your poll. \nYou can modify this poll with this link") . - " :\n\n".get_server_name()."/adminstuds.php?sondage=$numsondageadmin\n\n" . + " :\n\n".getUrlSondage($numsondageadmin, true)."\n\n" . _("Thanks for your confidence.") . "\n" . NOMAPPLICATION, $headers); @@ -177,7 +177,7 @@ if ($_POST["ajoutsujet_x"]){ sous_bandeau(); //on recupere les données et les sujets du sondage - echo '
'."\n"; + echo ''."\n"; echo '
'."\n"; echo "

" . _("Column's adding") . "



"."\n"; @@ -639,7 +639,7 @@ $toutsujet=str_replace("@","
",$toutsujet); $toutsujet=str_replace("°","'",$toutsujet); $nbcolonnes=substr_count($dsujet->sujet,',')+1; -echo ''."\n"; +echo ''."\n"; echo '
'."\n"; echo _('As poll administrator, you can change all the lines of this poll with infos.
You can, as well, remove a column or a line with Cancel.
You can also add a new column with Add column.
Finally, you can change the informations of this poll like the title, the comments or your email address.') ."\n"; echo '

'."\n"; diff --git a/bandeaux.php b/bandeaux.php index f6d9a30..78431b4 100644 --- a/bandeaux.php +++ b/bandeaux.php @@ -44,7 +44,7 @@ include_once('fonctions.php'); function logo () { if(defined('LOGOBANDEAU')) { - echo ''."\n"; + echo ''."\n"; } } @@ -81,7 +81,7 @@ function sous_bandeau() { echo '
' . ''. _("Home") .'' . - ''. _("Example") .'' . + ''. _("Example") .'' . ''. _("Contact") .'' . //''. _("Sources") .'' . //not implemented ''. _("About") .'' . diff --git a/creation_sondage.php b/creation_sondage.php index bf39078..ffdc5fd 100644 --- a/creation_sondage.php +++ b/creation_sondage.php @@ -88,14 +88,23 @@ function ajouter_sondage() "('$sondage','$_SESSION[commentaires]', '$_SESSION[adresse]', '$_SESSION[nom]', '$_SESSION[titre]','$sondage_admin', FROM_UNIXTIME('$date_fin'), '$_SESSION[formatsondage]','$_SESSION[mailsonde]' )"); $connect->Execute("insert into sujet_studs values ('$sondage', '$_SESSION[toutchoix]' )"); - mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes($_SESSION["titre"]), "" . _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll.") . "\n\n".stripslashes($_SESSION["nom"])." " . _("hast just created a poll called") . " : \"".stripslashes($_SESSION["titre"])."\".\n" . _("Thanks for filling the poll at the link above") . " :\n\n".get_server_name()."studs.php?sondage=$sondage \n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION,$headers); - mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes($_SESSION["titre"]), - _("This message should NOT be sended to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above") . - " :\n\n".get_server_name()."adminstuds.php?sondage=$sondage_admin \n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION,$headers); + $message = _("This is the message you have to send to the people you want to poll. \nNow, you have to send this message to everyone you want to poll."); + $message .= "\n\n"; + $message .= stripslashes($_SESSION["nom"])." " . _("hast just created a poll called") . " : \"".stripslashes($_SESSION["titre"])."\".\n"; + $message .= _("Thanks for filling the poll at the link above") . " :\n\n%s\n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION; + + $message_admin = _("This message should NOT be sended to the polled people. It is private for the poll's creator.\n\nYou can now modify it at the link above"); + $message_admin .= " :\n\n"."%s \n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION; + + $message = sprintf($message, getUrlSondage($sondage)); + $message_admin = sprintf($message_admin, getUrlSondage($sondage_admin, true)); + + mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("For sending to the polled users") . "] " . _("Poll") . " : ".stripslashes($_SESSION["titre"]), $message, $headers); + mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes($_SESSION["titre"]), $message, $headers); $date=date('H:i:s d/m/Y:'); error_log($date . " CREATION: $sondage\t$_SESSION[formatsondage]\t$_SESSION[nom]\t$_SESSION[adresse]\t \t$_SESSION[toutchoix]\n", 3, 'admin/logs_studs.txt'); - header("Location:studs.php?sondage=$sondage"); + header("Location:".getUrlSondage($sondage)); exit(); session_unset(); } \ No newline at end of file diff --git a/fonctions.php b/fonctions.php index 77c9f80..8a8cfdc 100644 --- a/fonctions.php +++ b/fonctions.php @@ -110,17 +110,24 @@ function is_user() } -function print_header($js = false) +function print_header($js = false, $nom_sondage = '') { echo ' - - '.NOMAPPLICATION.' - '; + '; + if (empty($nom_sondage) === false) { + echo ' + '.$nom_sondage.' - '.NOMAPPLICATION.''; + } else { + echo ' + '.NOMAPPLICATION.''; + } + echo ' + '; if($js) { - echo ''; + echo ''; } echo ''; @@ -169,6 +176,32 @@ function issetAndNoEmpty($name, $tableau = null) } +/** + * Fonction permettant de générer les URL pour les sondage + * @param string $id L'identifiant du sondage + * @param bool $admin True pour générer une URL pour l'administration d'un sondage, False pour un URL publique + * @return string L'url pour le sondage + */ +function getUrlSondage($id, $admin = false) +{ + if (URL_PROPRE === true) { + if ($admin === true) { + $url = get_server_name().$id.'/admin'; + } else { + $url = get_server_name().$id; + } + } else { + if ($admin === true) { + $url = get_server_name().'adminstuds.php?sondage='.$id; + } else { + $url = get_server_name().'studs.php?sondage='.$id; + } + } + + return $url; +} + + $connect=connexion_base(); define('COMMENT_EMPTY', 0x0000000001); diff --git a/studs.php b/studs.php index e940f79..93e8ac0 100644 --- a/studs.php +++ b/studs.php @@ -166,7 +166,7 @@ if (!is_error(NO_POLL) && isset($_POST["boutonp"])) { } } -print_header(true); +print_header(true, $dsondage->titre); echo ''."\n"; logo(); bandeau_tete();