Skip to content

Commit

Permalink
Clean URL and add title of poll in head
Browse files Browse the repository at this point in the history
  • Loading branch information
leblanc-simon committed May 20, 2011
1 parent fbbb6c6 commit c56e3b3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 19 deletions.
2 changes: 1 addition & 1 deletion admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@

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="../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 '</tr>'."\n";
Expand Down
10 changes: 5 additions & 5 deletions adminstuds.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
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);

Expand All @@ -135,7 +135,7 @@
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);

Expand All @@ -154,7 +154,7 @@
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);

Expand All @@ -177,7 +177,7 @@
sous_bandeau();

//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 "<H2>" . _("Column's adding") . "</H2><br><br>"."\n";
Expand Down Expand Up @@ -639,7 +639,7 @@
$toutsujet=str_replace("°","'",$toutsujet);
$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 _('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";
Expand Down
4 changes: 2 additions & 2 deletions bandeaux.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
function logo ()
{
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";
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ function sous_bandeau()
{
echo '<div class="sousbandeau">' .
'<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() . 'sources/sources.php">'. _("Sources") .'</a>' . //not implemented
'<a href="' . get_server_name() . 'apropos.php">'. _("About") .'</a>' .
Expand Down
19 changes: 14 additions & 5 deletions creation_sondage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
43 changes: 38 additions & 5 deletions fonctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>'.NOMAPPLICATION.'</title>
<link rel="stylesheet" type="text/css" href="style.css">';
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
if (empty($nom_sondage) === false) {
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) {
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>';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion studs.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
}
}

print_header(true);
print_header(true, $dsondage->titre);
echo '<body>'."\n";
logo();
bandeau_tete();
Expand Down

0 comments on commit c56e3b3

Please sign in to comment.