Index: lsrc.helper.php =================================================================== --- lsrc.helper.php (revision 8411) +++ lsrc.helper.php (working copy) @@ -4211,7 +4225,8 @@ { $asDatafield = explode($sDatafieldSeperator, $sData); $checkCnt=1; - + + //Null out any field that is an empty string. $iDataLength = count($asDatafield); for($n=0;$n>=$iDataLength;++$n) { @@ -4223,7 +4238,7 @@ // token generieren - + //Generate a random token. while($checkCnt>0) { $value = randomkey(10); //change randomkey value for different tokenlength (up to 36 chars max.) @@ -4231,25 +4246,36 @@ $result = db_execute_assoc($cQuery); $checkCnt = $result->RecordCount(); } + + //If we weren't supplied with a token for this participant, then set it to the one we just created. if(!isset($asDatafield[4]) || $asDatafield[4]=='') { $asDatafield[4]= $value; } + //set session language if no language is set if(!isset($asDatafield[3]) || $asDatafield[3]=='') { $asDatafield[3] = $_SESSION['lang']; } + //Begin to prepare our statement here. One array for the columns to insert and a parallel array with the values. + $insertColumns = array('firstname', 'lastname', 'email', 'language', 'token'); + $insertValues = array($asDatafield[0], $asDatafield[1], $asDatafield[2], $asDatafield[3], $asDatafield[4]); + if(isset($asDatafield[5]) && $asDatafield[5]!=null) { - $validity .= ',validfrom'; - $validityData .=",'$asDatafield[5]'"; + //$validity .= ',validfrom'; + //$validityData .=",'$asDatafield[5]'"; + $insertColumns[] = 'validfrom'; + $insertValues[] = $asDatafield[5]; } if(isset($asDatafield[6]) && $asDatafield[5]!=null) { - $validity .= ',validuntil'; - $validityData .=",'$asDatafield[6]'"; + //$validity .= ',validuntil'; + //$validityData .=",'$asDatafield[6]'"; + $insertColumns[] = 'validuntil'; + $insertValues[] = $asDatafield[6]; } if(isset($asDatafield[7]) && $asDatafield[7]!='') @@ -4263,8 +4289,10 @@ //$check = "SELECT attribute_$n FROM {$dbprefix}_tokens_$iVid "; $sql = "ALTER TABLE {$dbprefix}tokens_$iVid ADD COLUMN attribute_$n VARCHAR(255); "; - $attributes.=",attribute_$n"; - $attributesData.= ",'$attribute'"; + //$attributes.=",attribute_$n"; + //$attributesData.= ",'$attribute'"; + $insertColumns[] = "attribute_$n"; + $insertValues[] = $attribute; $this->debugLsrc("wir sind in ".__FUNCTION__." Line ".__LINE__.", Attribute_$n mit $attribute anlegen ,sql: $sql"); //modify_database("","$sql"); @@ -4274,12 +4302,16 @@ } - $sInsertParti = "INSERT INTO ".$dbprefix."tokens_".$iVid + /*$sInsertParti = "INSERT INTO ".$dbprefix."tokens_".$iVid ."(firstname,lastname,email,token," ."language $validity $attributes) " ."VALUES ('{$asDatafield[0]}', '{$asDatafield[1]}' , '{$asDatafield[2]}', '{$asDatafield[4]}' , " - ."'{$asDatafield[3]}' $validityData $attributesData) "; + ."'{$asDatafield[3]}' $validityData $attributesData) ";*/ + $sInsertParti = "INSERT INTO {$dbprefix}tokens_$iVid (".implode(',', $insertColumns).") VALUES (".trim(str_repeat('?,', count($insertColumns)), ',').");"; + + + $this->debugLsrc("$sInsertParti"); @@ -4290,7 +4322,7 @@ // '".$asDatafield[1]."' , '".$asDatafield[2]."' , 'OK' , '".$asDatafield[5]."', // '".$_SESSION['lang']."', 'N', 'N', '".$asDatafield[3]."' , '".$asDatafield[4]."' , NULL); "; // - if($connect->Execute($sInsertParti)) + if($connect->Execute($sInsertParti, $insertValues)) { ++$iInsertedParticipants; // check participants eMail status and set it