Clean URL and add title of poll in head

This commit is contained in:
Simon Leblanc 2011-05-20 02:52:22 +02:00
parent fbbb6c6b7d
commit c56e3b3b4d
6 changed files with 61 additions and 19 deletions

View File

@ -124,7 +124,7 @@ while($dsondage = $sondage->FetchNextObject(false)) {
echo'<td>'.$nbuser.'</td>'."\n"; echo'<td>'.$nbuser.'</td>'."\n";
echo '<td><a href="../studs.php?sondage='.$dsondage->id_sondage.'">'. _("See the poll") .'</a></td>'."\n"; echo '<td><a href="../studs.php?sondage='.$dsondage->id_sondage.'">'. _("See the poll") .'</a></td>'."\n";
echo '<td><a href="../adminstuds.php?sondage='.$dsondage->id_sondage_admin.'">'. _("Change the poll") .'</a></td>'."\n"; echo '<td><a href="'.getUrlSondage($dsondage->id_sondage_admin, true).'">'. _("Change the poll") .'</a></td>'."\n";
echo '<td><input type="submit" name="supprimersondage'.$i.'" value="'. _("Remove the poll") .'"></td>'."\n"; echo '<td><input type="submit" name="supprimersondage'.$i.'" value="'. _("Remove the poll") .'"></td>'."\n";
echo '</tr>'."\n"; echo '</tr>'."\n";

View File

@ -117,7 +117,7 @@ if (isset($_POST["boutonnouveautitre"])) {
mail ($adresseadmin, mail ($adresseadmin,
_("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION, _("[ADMINISTRATOR] New title for your poll") . ' ' . NOMAPPLICATION,
_("You have changed the title of your poll. \nYou can modify this poll with this link") . _("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, _("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers); $headers);
@ -135,7 +135,7 @@ if (isset($_POST["boutonnouveauxcommentaires"])) {
mail ($adresseadmin, mail ($adresseadmin,
_("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION, _("[ADMINISTRATOR] New comments for your poll") . ' ' . NOMAPPLICATION,
_("You have changed the comments of your poll. \nYou can modify this poll with this link") . _("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, _("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers); $headers);
@ -154,7 +154,7 @@ if (isset($_POST["boutonnouvelleadresse"])){
mail ($_POST['nouvelleadresse'], mail ($_POST['nouvelleadresse'],
_("[ADMINISTRATOR] New email address for your poll") . ' ' . NOMAPPLICATION, _("[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") . _("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, _("Thanks for your confidence.") . "\n" . NOMAPPLICATION,
$headers); $headers);
@ -177,7 +177,7 @@ if ($_POST["ajoutsujet_x"]){
sous_bandeau(); sous_bandeau();
//on recupere les données et les sujets du sondage //on recupere les données et les sujets du sondage
echo '<form name="formulaire" action="adminstuds.php?sondage='.$numsondageadmin.'" method="POST" onkeypress="javascript:process_keypress(event)">'."\n"; echo '<form name="formulaire" action="'.getUrlSondage($numsondageadmin, true).'" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
echo '<div class="corpscentre">'."\n"; echo '<div class="corpscentre">'."\n";
echo "<H2>" . _("Column's adding") . "</H2><br><br>"."\n"; echo "<H2>" . _("Column's adding") . "</H2><br><br>"."\n";
@ -639,7 +639,7 @@ $toutsujet=str_replace("@","<br>",$toutsujet);
$toutsujet=str_replace("°","'",$toutsujet); $toutsujet=str_replace("°","'",$toutsujet);
$nbcolonnes=substr_count($dsujet->sujet,',')+1; $nbcolonnes=substr_count($dsujet->sujet,',')+1;
echo '<form name="formulaire" action="adminstuds.php?sondage='.$numsondageadmin.'" method="POST" onkeypress="javascript:process_keypress(event)">'."\n"; echo '<form name="formulaire" action="'.getUrlSondage($numsondageadmin, true).'" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
echo '<div class="cadre"> '."\n"; echo '<div class="cadre"> '."\n";
echo _('As poll administrator, you can change all the lines of this poll with <img src="images/info.png" alt="infos">.<br> You can, as well, remove a column or a line with <img src="images/cancel.png" alt="Cancel">. <br>You can also add a new column with <img src="images/add-16.png" alt="Add column">.<br> Finally, you can change the informations of this poll like the title, the comments or your email address.') ."\n"; echo _('As poll administrator, you can change all the lines of this poll with <img src="images/info.png" alt="infos">.<br> You can, as well, remove a column or a line with <img src="images/cancel.png" alt="Cancel">. <br>You can also add a new column with <img src="images/add-16.png" alt="Add column">.<br> Finally, you can change the informations of this poll like the title, the comments or your email address.') ."\n";
echo '<br><br>'."\n"; echo '<br><br>'."\n";

View File

@ -44,7 +44,7 @@ include_once('fonctions.php');
function logo () function logo ()
{ {
if(defined('LOGOBANDEAU')) { if(defined('LOGOBANDEAU')) {
echo '<div class="logo"><img src="./'. LOGOBANDEAU .'" height="74" alt="logo"></div>'."\n"; echo '<div class="logo"><img src="'.get_server_name().LOGOBANDEAU.'" height="74" alt="logo"></div>'."\n";
} }
} }
@ -81,7 +81,7 @@ function sous_bandeau()
{ {
echo '<div class="sousbandeau">' . echo '<div class="sousbandeau">' .
'<a href="' . get_server_name() . 'index.php">'. _("Home") .'</a>' . '<a href="' . get_server_name() . 'index.php">'. _("Home") .'</a>' .
'<a href="' . get_server_name() . 'studs.php?sondage=aqg259dth55iuhwm">'. _("Example") .'</a>' . '<a href="' . getUrlSondage('aqg259dth55iuhwm').'">'. _("Example") .'</a>' .
'<a href="' . get_server_name() . 'contacts.php">'. _("Contact") .'</a>' . '<a href="' . get_server_name() . 'contacts.php">'. _("Contact") .'</a>' .
//'<a href="' . get_server_name() . 'sources/sources.php">'. _("Sources") .'</a>' . //not implemented //'<a href="' . get_server_name() . 'sources/sources.php">'. _("Sources") .'</a>' . //not implemented
'<a href="' . get_server_name() . 'apropos.php">'. _("About") .'</a>' . '<a href="' . get_server_name() . 'apropos.php">'. _("About") .'</a>' .

View File

@ -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]' )"); "('$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]' )"); $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); $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.");
mail ("$_SESSION[adresse]", "[".NOMAPPLICATION."][" . _("Author's message") . "] " . _("Poll") . " : ".stripslashes($_SESSION["titre"]), $message .= "\n\n";
_("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 .= stripslashes($_SESSION["nom"])." " . _("hast just created a poll called") . " : \"".stripslashes($_SESSION["titre"])."\".\n";
" :\n\n".get_server_name()."adminstuds.php?sondage=$sondage_admin \n\n" . _("Thanks for your confidence") . ",\n".NOMAPPLICATION,$headers); $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:'); $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'); 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(); exit();
session_unset(); session_unset();
} }

View File

@ -110,17 +110,24 @@ function is_user()
} }
function print_header($js = false) function print_header($js = false, $nom_sondage = '')
{ {
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
<title>'.NOMAPPLICATION.'</title> if (empty($nom_sondage) === false) {
<link rel="stylesheet" type="text/css" href="style.css">'; echo '
<title>'.$nom_sondage.' - '.NOMAPPLICATION.'</title>';
} else {
echo '
<title>'.NOMAPPLICATION.'</title>';
}
echo '
<link rel="stylesheet" type="text/css" href="'.get_server_name().'style.css">';
if($js) { if($js) {
echo '<script type="text/javascript" src="block_enter.js"></script>'; echo '<script type="text/javascript" src="'.get_server_name().'block_enter.js"></script>';
} }
echo '</head>'; echo '</head>';
@ -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(); $connect=connexion_base();
define('COMMENT_EMPTY', 0x0000000001); define('COMMENT_EMPTY', 0x0000000001);

View File

@ -166,7 +166,7 @@ if (!is_error(NO_POLL) && isset($_POST["boutonp"])) {
} }
} }
print_header(true); print_header(true, $dsondage->titre);
echo '<body>'."\n"; echo '<body>'."\n";
logo(); logo();
bandeau_tete(); bandeau_tete();