\n";
$the_full_file_path = $tempdir . "/" . $_FILES['the_file']['name'];
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path))
{
$importquestion .= "".$clang->gT("Error")." \n";
$importquestion .= sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."
\n"
."\n"
."
\n";
unlink($the_full_file_path);
return;
}
// validate that we have a SID and GID
if (!returnglobal('sid'))
{
$importquestion .= $clang->gT("No SID (Survey) has been provided. Cannot import question.")."
\n"
."\n"
."
\n";
unlink($the_full_file_path);
return;
}
else
{
$postsid=returnglobal('sid');
}
if (!returnglobal('gid'))
{
$importquestion .= $clang->gT("No GID (Group) has been provided. Cannot import question")."
\n"
."\n";
unlink($the_full_file_path);
return;
}
else
{
$postgid=returnglobal('gid');
}
// IF WE GOT THIS FAR, THEN THE FILE HAS BEEN UPLOADED SUCCESFULLY
$importquestion .= "".$clang->gT("Success")." \n"
.$clang->gT("File upload succeeded.")."
\n"
.$clang->gT("Reading file..")."\n";
$handle = fopen($the_full_file_path, "r");
while (!feof($handle))
{
$buffer = fgets($handle, 10240); //To allow for very long survey welcomes (up to 10k)
$bigarray[] = $buffer;
}
fclose($handle);
// Now we try to determine the dataformat of the survey file.
if ((substr($bigarray[1], 0, 24) == "# SURVEYOR QUESTION DUMP")&& (substr($bigarray[4], 0, 29) == "# http://www.phpsurveyor.org/"))
{
$importversion = 100; // version 1.0 file
}
elseif
((substr($bigarray[1], 0, 24) == "# SURVEYOR QUESTION DUMP")&& (substr($bigarray[4], 0, 37) == "# http://phpsurveyor.sourceforge.net/"))
{
$importversion = 99; // Version 0.99 file or older - carries a different URL
}
elseif
(substr($bigarray[0], 0, 26) == "# LimeSurvey Question Dump" || substr($bigarray[0], 0, 27) == "# PHPSurveyor Question Dump")
{ // Wow.. this seems to be a >1.0 version file - these files carry the version information to read in line two
$importversion=substr($bigarray[1], 12, 3);
}
else // unknown file - show error message
{
$importquestion .= "".$clang->gT("Error")." \n";
$importquestion .= $clang->gT("This file is not a LimeSurvey question file. Import failed.")."