Webform

Information importante

En raison d'un grand nombre d'inscriptions de spammers sur notre site, polluant sans relache notre forum, nous suspendons la création de compte via le formulaire de "sign up".

Il est néanmoins toujours possible de devenir adhérent•e en faisant la demande sur cette page, rubrique "Inscription" : https://www.drupal.fr/contact


De plus, le forum est désormais "interdit en écriture". Il n'est plus autorisé d'y écrire un sujet/billet/commentaire.

Pour contacter la communauté, merci de rejoindre le slack "drupalfrance".

Si vous voulez contacter le bureau de l'association, utilisez le formulaire disponible ici, ou envoyez-nous un DM sur twitter.

Bonjour,
J'ai réalisé un formulaire tout bête avec webform. Il permet de s'abonner à une newsletter et demande le nom et prenom de l'utilisateur ainsi que son adresse e-mail.
Dans e-mail settings j'ai mis mon adresse pour recevoir les resultats. J'ai fait des tests et je ne recois rien....
Est-ce normal?
Merci d'avance et bonne journée

Forum : 
Version de Drupal : 

Hello,

Pour afficher un noeud (en l'occurrence, un webform) dans un bloc, il faut utiliser le module http://drupal.org/project/nodeasblock.

Quant à l'envoi d'email, peut-être qu'il y a un problème de configuration de ton serveur SMTP. Est-ce que tu reçois bien les emails automatiques envoyés par Drupal (à la création d'un nouveau compte utilisateur par exemple) ?

Si quand tu crées un nouveau compte utilisateur (avec un email que tu possèdes), tu ne reçois rien à l'adresse email indiquée, en effet il y a un problème. Drupal envoie automatiquement un email de confirmation à chaque nouvel utilisateur.

Soit il n'y a pas de serveur email sur ton hébergement (rare), soit le SMTP est mal configurée dans php.ini.

Ok, dans ce cas, le fichier php.ini devrait se trouver à un emplacement qui ressemble à ça (ça peut varier en fonction de ta version de PHP, Apache...) :

/etc/php5/apache2/php.ini

Le mieux est de te connecter via SSH à ton serveur et de lancer la commande locate php.ini qui te permettra de localiser le fichier en question.

Merci j'ai trouvé le fichier et quand je l'édite il me vient le fichier php suivant. Comme je n'aimerais pas faire de bêtise où dois-je configurer pour recevoir les mails de Drupal?
Merci encore pour tout et désolé de la longueur du script

<?
#
# phpini,php
#
# php.ini customization/control script
#
# This script will let you customize php.ini
# in 'Easy setup menu' or 'Detailed setup menu'.
#
# It will setup daily cronjob to refresh php.ini from
# PowWeb's default copy, if you tell so.
#
# It will setup automatically session.save_path
# and session cleanup cronjob, if you choose.
#
# It will take care of 'Easy method' subdomains, too, if you have any.
#
# No Editing is required, as usuall.
#
#
# Also, it can download and install powerfull crontab editor/checker/tester,
# 'CronAid (cronaid.php)' totally automatically, by clicking the link.
#
#
# WARNING (and rant and background):
#
# As this script IS very flexible, it can be exploited by bad people
# if not protected prooperly.
#
# Please at leas password protect the directory or this script.
# I recommend using IP (range) protection on top of it.
#
# Use https secure connection if you feel like.
#
# Also, keep a copy of php.ini(s) and crontab, just in case.
#
# Although I've done enough test to feel confortable with it,
# this software is still in TESTING stage, and it may contain
# bugs, typos, and any other common mistake of mine.
#
# This is my 2nd PHP program and probably the last.
# So, it's not a good coding example for PHP.
# If you want to learn programming, learn something other than PHP.
# PHP isn't good language. It's not "normal" general language either.
#
# Actually, I'm not so sure why the heck I wrote it.
# As you can clearly see, I'm not a fan of PHP.
# I don't like it at all. I don't use it. I wish everyone dump this junk.
#
# But undeniably, naive newbies are drawn to it,
# and suffer because of its poor design ....
# And a part of suffering is caused by php.ini customizations,
# including crontab setup to go with it.
#
# So, I decided to write a small automatic script to setup
# at least session.save_path related things,
# and somehow ended up writing this.
#
# Well, it's done (other than more testing/debugging/tweaking).
# Now, you can enjoy the fruits of my pain, learning retarded language,
# and the pain of many naive PHP users.
#
# I'll be very happy if it helps you to reduce the stress level,
# or if you decide to use something better than PHP and it's applications.
#
# This is the latest addition of 'useful joke soft' series.
#
# v0.50 initial alpha
# v0.51 Fixed a few typos

$ver = '0.51';

# General setups.
#
# You don't need to modify these
# unless you are trying to use it on non-PowWeb server
# or PowWeb has modified some settings .....
#
$user = get_current_user();
$home = "/www/".substr($user,0,1)."/$user";
$myini = "$home/etc/myphpini.txt";
$inipath = '/usr/local/lib/php.ini';
$custompath = $_SERVER['DOCUMENT_ROOT']."/php.ini";
$tmpdir = "'$home/tmp'";
$sessdir = "'$home/sessions'";
$etc = "$home/etc";
$ctab = "$etc/crontab";

$baseself = basename($_SERVER['PHP_SELF']);
?>

php.ini control center (<?=$baseself?>)

php.ini control center (<?=$baseself?>) ver. <?=$ver?>

<?
if(!isset($_SERVER['REMOTE_USER'])){
echo "Security Warning: no password protection detected\nYou must protect this script by password, IP (or IP range), and/or other valid methods.
\n";
}
ob_flush(); # This may avoid 500 error caused by the time out
#print_r($_POST);

# These correct stupid PHP feature, but only partially...
# Taken from PHP manual page and modified for the line ending.
function stripslashes_deep($value)
{
return (is_array($value) ? array_map('stripslashes_deep', $value) : str_replace("\r", "\n", str_replace("\r\n", "\n", stripslashes($value) ) ));
}

if (get_magic_quotes_gpc())
{
$_GET = array_map('stripslashes_deep', $_GET);
$_POST = array_map('stripslashes_deep', $_POST);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
function mywrite($pn, $ct, $mode = 'w'){
if($fh = fopen($pn,$mode)){
if(!fwrite($fh, $ct) ){
echo("Error: Failed to write $pn$pe
\n");
}
fclose($fh);
}else{
echo("Error: Failed to open $pn$pe
\n");
}
}

# automatic tool installer section
if(isset($_GET['install']) ){
$fn = preg_replace('/^(.*?)\.(.*)$/','\1_\2.txt', $_GET['install']);

echo "Installing '".$_GET['install']."' into current directory\n";
echo "  Please, plase. please make sure to well protect this directory
\n";
echo "  Protect at least by password protection. Use IP (range) protection, too, if possible.
\n";
$fl = file_get_contents('http://check-these.info/tools/'.$fn);
if($fl){
mywrite($_GET['install'], $fl);
echo '

Done! Book mark and access this link to use it ==> '.$_GET['install']."

\n";
}
unset($_GET['install']);
echo "\n";
}

$easysetup = 0;
$detaildsetup = 0;
$setup = 0;
if($_SERVER['REQUEST_METHOD'] == "GET" or isset($_POST['easysetup'])){
$easysetup = 1;
$setup = 1;
}elseif(isset($_POST['detailedsetup'])){
$detaildsetup = 1;
$setup = 1;
}
function nullcall($buffer) { return ''; }

if($setup){
#echo "Getting $myini\n";
ob_flush();
$other = "";
$uptmp = "";
$sesspath = "";
$session_life="2";
$act[1] = " checked";
$act[2] = "";
$act[3] = "";
$opt[1] = " checked";
$opt[2] = "";
$opt[3] = "";
$opt[4] = "";
$otheritems = "";
$stripcom = " checked";
$myinidata = @file_get_contents($myini);
if($myinidata){
#echo "Got $myini\n";
#echo "$myinidata\n";
#ob_flush();
if( strstr($myinidata,'stripcomments = off')){
$stripcom = "";
}
if(preg_match('/actions = ([1-3])/', $myinidata, $m)){
$act[1] = "";
$act[$m[1]] = " checked";
}
if(preg_match('/options = ([1-4])/', $myinidata, $m)){
$opt[1] = "";
$opt[$m[1]] = " checked";
}
if(preg_match('/session_life = ([0-9]+[mhd]?)/', $myinidata, $m)){
$session_life = $m[1];
}
$mylines = explode("\n",$myinidata);
foreach($mylines as $line){
if(preg_match('/^ *([a-zA-Z0-9\._]+)\s*=\s*(.*)/', $line, $m)){
$myarray[$m[1]] = $m[2];
}
}
if( isset($myarray['session.save_path'])){
#echo 'sess : ',$myarray['session.save_path'] ,"
\n";
$sesspath = " checked";
}else{
$myarray['session.save_path'] = $sessdir;
}
if( isset($myarray['upload_tmp_dir'])){
#echo 'upt : ',$myarray['upload_tmp_dir'] ,"
\n";
$uptmp = " checked";
}else{
$myarray['upload_tmp_dir'] ="$home/tmp";
}
$da = array('session.save_path'=>1, 'upload_tmp_dir'=>1, 'max_execution_time'=>1, 'upload_max_filesize'=>1, ';Esay_subdomain_option'=>1);
#while(list($k,$v) = each($myarray)){
#echo $k, $v, "
\n";
# $otheritems .= "$k = $v\n";
# }
# echo "OTM=$otheritems
\n";
foreach(array_keys($myarray) as $k){
if(! array_key_exists($k, $da)){
$otheritems .= "$k = ".$myarray[$k]."\n";
}

}
}

# A callback function for cutting unwanted outputs.
ob_flush();
ob_start('nullcall'); # Using html context as HEREDOCUMENT :)
?>

Choose the action you want:

    > Update/create custom php.ini with following changes.(One time only)
       All submitted changes will be saved in <?=$myini?>,
       and merged with fresh "php.ini" of PowWeb from <?=$inipath?>,
       then written into <?=$custompath?>.

    > Update/create custom php.ini and also setup a cronjob for daily update.
       In addition to the above, a cronjob will be setup automatically

    > Remove custom php.ini and crontab for daily update (if any).
       (Customization data in <?=$myini?> will remain there.)

Options for (Easy method) subdomains, if you have any.

   Note: .htaccess method subdomains do NOT need these.
   If you don't have Easy method subdomains, these options will be ignored.

    > Copy updated/created custom php.ini into any Easy method subdmains.

    > Create Symlinks. (creates sort of shortcut, rather than copying actual custom php.ini file)
       Once symlinks created, the changes to the customized php.ini will be
       reflected automatically without any intervention in these Easy method subdomains.

    > Do nothing. (customization may not apply to Easy method subdomains.)

    > Remove symlinks and copies.

Options for session and uploads

  • Setup your own session.save_path (including crontab setup for session file cleanup)
  • Check here to activate ->>

       With this option, it will check the existence of your own session direcotry,
       and create it if not there.
       Then, it'll do all setups for cronjob to cleanup old session files.
       By activating this, any value for 'session.save_path' other than the form below will be ignored.

    Modify the path if you need -> ">
    (Usually, you shouldn't need to modify the default path offered.)

    Default session life offered in this easy setup is minimum 2hours, max. 2 x 2 hours.
    If you want different value, enter here ->">hours minimum, n x 2 hours maximum

    Note: If you want more pricise control of session life span,
    you need to tweak values, manually, using CronAid.
    You can install CronAid tool automatically by clicking This Link.

  • Setup upload_tmp_dir
  • Check here to activate ->>

       By activating this option, any value for 'upload_tmp_dir' other than the form below will be ignored.

    A directory for temporary files will be automatically created.
    If you want it to be in different location than default value, somehow,
    Modify the path here -> ">

Custom php.ini format option

   Uncheck this -> > if you want to keep comment lines.

<?
$actopt = ob_get_contents();
ob_end_flush();

} # end if($setup)

if($easysetup){

?>
Easy setup menu (for common items and what you've already customized):

<

form action="/%3C" method="POST">
   (If you want to see and control all items in php.ini, instead, click here !
)

<

form action="/%3C" method="POST">
<?=$actopt?>

Set desired values

  • Setup upload_max_filesize
  • Enter desired value if you want to modify -> "> Byte

    (Leave it blank if you want to keep PowWeb's default value of 2 MB)

    Note: Maybe, you should be using FTP instead of HTTP uploading for a large file.

  • Modify max_execution_time
  • Enter desired value if you want to modify -> ">seconds
    (Leave it blank if you want to keep PowWeb's default value of 30 sec)

  • Other setups you have saved or you want to save.
  • (ie. whatever = "This value" )
    <?=$otheritems?><? echo htmlentities($other); ?>

php.ini control center (<?=$baseself?>)

<?
exit();
} # end if($easysetup)

$inidata = file_get_contents($inipath);

if($detailedsetup){

$inidata = preg_replace('/(\n;? *([a-zA-Z0-9\._]+) *=.*)/e','\'\1 \'', htmlentities($inidata));

function replf($k,$kk,$v){
global $myarray;
#echo "XXX $k == $kk ==$v
\n";

unset($myarray[$k]);
return "name=\"$kk\" value=\"$v\"";
}
while(list($k,$v) = each($myarray)){
#echo "$k == $v
\n";
$kk = str_replace('.','DOT',$k);
#echo "$k == $kk ==$v
\n";
$myarrayP[$k] = "/name=\"$kk\" value=\"\"/e";
#$myarrayS[$k] = "name=\"$kk\" value=\"$v\"";
$myarrayS[$k] = "replf(\"$k\", \"$kk\", \"$v\")";
}
$inidata = preg_replace($myarrayP, $myarrayS, $inidata);
# print_r($myarray);
$otheritems = "";
#while(list($k,$v) = each($myarray)){
#echo $k, $v, "
\n";
# $otheritems .= "$k = $v\n";
# }
# echo "OTM=$otheritems
\n";
foreach(array_keys($myarray) as $k){
$otheritems .= "$k = ".$myarray[$k]."\n";

}
#echo "OTM=$otheritems
\n";
?>
Detailed setup
If you want to go to Easy setup menu, Click this link !

<?=$actopt?>

Set desired values

Scroll down and enter the value (only values, such as On, Off, and so on)
Leave the field blank to keep default values.

<? echo $inidata; ?>

Use the textarea below to enter any other settings not shown.
(ie. whatever = "desired_value" )
<?echo htmlentities($otheritems); ?>

<?
exit();
} # end if($detailedsetup)

#echo $_POST['stripcomments']," stripcomments
\n";
# custom php.ini format option
($_POST['stripcomments'] =='' ? $withcomments = 1 : $withcomments = 0);
#$_POST[';stripcomments'] = $_POST['stripcomments'];
unset($_POST['stripcomments']);

$easy = 0;
$detail = 0;
if(isset($_POST['submitdetail'])){
#echo "submitdetail
\n";
#ob_flush();
unset($_POST['submitdetail']);
$detail = 1;
}
if( isset($_POST['submiteasy'])){
unset($_POST['submiteasy']);
$easy = 1;
}
#echo "DATA posted
\n";
#ob_flush();
#echo "Comments ?XX>". $_POST['stripcomments']."XX
\n";
if( isset($_POST['actions'])){
$act = $_POST['actions'];
unset($_POST['actions']);
}
if( isset($_POST['options'])){
$opt = $_POST['options'];
unset($_POST['options']);
}

$session_life = 0;
if($_POST['activate_session_save_path']){
unset($_POST['activate_session_save_path']);
$_POST['sessionDOTsave_path'] = $_POST['my_session_save_path'];
$dosession = 1;
}else{
unset($_POST['sessionDOTsave_path']);
}
unset($_POST['my_session_save_path']);
$session_life = $_POST['session_life'];
unset($_POST['session_life']);

if(isset($_POST['activate_upload_tmp_dir'])){
unset($_POST['activate_upload_tmp_dir']);
$_POST['upload_tmp_dir'] = $_POST['my_upload_tmp_dir'];
unset($_POST['my_upload_tmp_dir']);
$douptmp = 1;
}
unset($_POST['my_upload_tmp_dir']);

$inilines = explode("\n",$inidata);
foreach($inilines as $line){
if(preg_match('/^ *([a-zA-Z0-9\._]+)\s*=\s*(.*)/', $line, $m)){
$iniarray[$m[1]] = $m[2];
#echo "->$line
\n";
}elseif($withcomments){
#echo "#->$line
\n";
$iniarray[] = $line;
}elseif(substr($line, 0, 1) == '[' ){
#echo "[]->$line
\n";
$iniarray[] = $line;
}
}
$iniarray[] = '';
$iniarray[] = ';--- added & uncommented values ---';
unset( $inilines);
#echo "iniline loop finished
\n";
#ob_flush();

$mylines = explode("\n",$_POST['otheritems']);
if($mylines){
foreach($mylines as $line){
#echo "->$line
\n";
#ob_flush();
if( preg_match('/^ *([a-zA-Z0-9\._]+)\s*=\s*(.*)/', $line, $m)){
$myarray[$m[1]] = $m[2];
}
}
}
unset($_POST['otheritems']);
unset( $mylines);

while(list($k,$v) = each($_POST)){
if($v !=''){
# PHP IS a stupid language and we cannot get raw post data
# in some cases, and DOT in $_POST keys are transformed to UNDERSCORE ....
# To walk around this damn "feature" of PHP, '.' is replaced by 'DOT'
# in form, and brought back to '.' here.
$k = str_replace('DOT','.',$k);
$myarray[$k] = $v;
#echo "$k --- $v
\n";
#ob_flush();
}
}

#print_r($_POST);
#echo "
\n";
#ob_flush();
$r = array_merge($iniarray, $myarray);

while(list($k,$v) = each($r)){
$rr .= (is_numeric($k) ? "$v\n" :"$k = $v\n");
#echo "==>$k = $v
\n";
}
unset( $r);
unset( $iniarray);

$myarray[';actions'] = $act;
$myarray[';options'] = $opt;

$myarray[';stripcomments'] = ($withcomments ? 'off' : 'on');
if($session_life){ $myarray[';session_life'] = $session_life;}

while(list($k,$v) = each($myarray)){
$myr .="$k = $v\n";
}

if($act != 3){
mywrite($custompath, $rr);

?>
Following custom php.ini is updated/created. Filepath: <?=$custompath?>

<? echo htmlentities($rr); ?>

<?
}
if($myr){ mywrite($myini, $myr);
?>
And following customization is saved in: <?=$myini?>

<? echo htmlentities($myr); ?>
<?

}else{
?>There was no customization.
<?
}
### Do cronjob directory creation here ###
# First, check/create session.save_path, if it's activated.
echo '';
if($dosession){
$sessdir = $myarray['session.save_path'];
if(!is_dir($sessdir)){
#echo `id 2>&1`;
if(mkdir($sessdir,0700)){
echo "$sessdir was not there. It was created and permission set to 0700\n";
}else{
echo "Failed to create $sessdir\n";
}
}
$minb = rand(6,54); # for session deleting
}
if($douptmp){
$tmpdir = $myarray['upload_tmp_dir'];
if(!is_dir($tmpdir)){
if(mkdir($tmpdir,0700)){
echo "$tmpdir was not there. It was created and permission set to 0700\n";
}else{
echo "Failed to create $tmpdir\n";
}
}
}

$ct = file_get_contents($ctab);
if($act == 2){
$min = rand(6,54); # somewhere between 1:06 and 1:54
echo "\nYour php.ini will be refreshed at 1:$min AM everyday\n";
}elseif($act == 3){
# Remove php.ini and crontab entry
if(!unlink($custompath )){
echo "Failed to remove $custompath\n";
}
$ct = preg_replace("#(^|\\n).*?$myini.*#",'',$ct);
$ct = preg_replace("#(^|\\n).*?$sessdir.*#",'',$ct);
$ct = preg_replace("#\\n{3,}#","\n\n",$ct);

$fh = fopen( "$ctab","a") or die("Error: failed to open $ctab (Action 3)\n");
fputs($fh, $ct);
fclose($fh);
}
if($opt != 3){ # 3: Do nothing
$tbd = "";
$globarray = glob("$home/*");
if($globarray){
foreach ( $globarray as $name) {
if(is_dir($name) and is_dir("$name/htdocs")){
if($opt == 1){
$tbd .="cp htdocs/php.ini $name/htdocs/; ";
}elseif($opt == 2){
# make symlink
symlink($cumstompath, "$name/htdocs/php.ini");
}else{
# Delete both symlink AND php.ini
unlink("$name/htdocs/php.ini");
}
}
}
if($tbd != ''){ $tbd ="($tbd) 2>>etc/cronerr.txt";}
}
}
if($act == 2 or $dosession){ # Need etc and crontab setup

if(!is_dir($etc)){
mkdir($etc, 0700) or die( "Failed to create 'etc' directory..."); # make sure /www/U/USER/etc exists.
echo "$etc direcotry was not there. It was created and permission set to 0700\n";
}
if($act == 2){
($withcomments ? $cutcom = "" : $cutcom = "-e '^ *;' -e '^ *$'");
ob_flush();
ob_start('nullcall'); # Using html context as HEREDOCUMENT.
?><?=$min?> 1 * * * for i in cut -d ' ' -d '=' -f 1 <?=$myini?>; do ii=${i# };x="$x -e '${ii%%[!a-zA-Z0-9_-]}'"; done;(eval "grep -h -v <?=$cutcom?> $x /usr/local/lib/php.ini" ;echo ';--- added or customized values ---';grep -v -e '^ *;' <?=$myini?> ;)>htdocs/php.ini 2>>etc/cronerr.txt;<?=$tbd?>

<?
$ctb .= ob_get_contents();
ob_end_flush();
$ct = preg_replace("#(^|\\n).*?$myini.*#",'',$ct);
}
if($dosession){
$ct = preg_replace("#(^|\\n).*?$sessdir.*#",'',$ct);
$ctb .= "$minb */${session_life} * * * find $sessdir/ -mtime ${session_life}h -delete >>etc/cronlog.txt 2>&1\n\n";
}
$ct = preg_replace("#^\\n+#","",$ct);
$ct = preg_replace("#\\n{3,}#","\n\n",$ct);
$fh = fopen( "$ctab","wb") or die("Error: failed to open $ctab\n");
fputs($fh, $ct.$ctb);
fclose($fh);
echo "\nFollowing line(s) generated/added to $ctab \n$ctb";
echo "Currently, your crontab contains following entries;\n---- crontab start -----\n";
readfile("$etc/crontab");
?>----- end -----

To edit/add/check crontab, use <a href=\"http://forum.powweb.com/showthread.php?p=290391#post290391\">CronAid tool</a> !
You can install CronAid tool automatically <a href="/%3C">by clicking This Link</a>.

You can use <a href="https://webftp.powweb.com/?username=<?=$user?>">WebFTP</a> and/or <a href="http://<?=$_SERVER['HTTP_HOST']?>/+sitemanager">sitemanager</a> to mange files and directories and more !

<?
}
?>

<

form action="/%3C" method="POST">
Go to Easy setup menu =>

<

form action="/%3C" method="POST">
Or push this one for Detailed setup =>

php.ini control center (<?=$baseself?>)

Merci encore pour tout

Salut,

Ca n'était pas nécessaire de copier tout le fichier, car les directives qu'il contient sont standard. :)

Je ne suis pas expert dans la configuration SMTP. Si tu n'arrives pas à envoyer de mail depuis PHP (et donc depuis Drupal), il faut te retourner vers ton hébergeur et lui poser la question.

Sinon, tu peux effectuer qq recherches en ligne : l'article PHP: focus sur le fichier de configuration php.ini - 2e partie contient des infos intéressantes sur la config SMTP.