View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 05432 | Bug reports | Import/Export | public | 2011-08-29 21:56 | 2012-03-14 21:08 |
| Reporter | kolmen1 | Assigned To | c_schmitz | ||
| Priority | urgent | Severity | partial_block | ||
| Status | closed | Resolution | fixed | ||
| Product Version | 1.91+ | ||||
| Fixed in Version | 1.91+ | ||||
| Summary | 05432: Export answers to PDF fails when using IE, FF works well | ||||
| Description | I found the same issue was fixed some time ago see: It's quite urgent for me :) | ||||
| Tags | No tags attached. | ||||
| Attached Files | printanswers.php (9,247 bytes)
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: printanswers.php 9858 2011-03-08 12:50:47Z c_schmitz $
*
*/
//Security Checked: POST, GET, SESSION, REQUEST, returnglobal, DB
require_once(dirname(__FILE__).'/classes/core/startup.php');
require_once(dirname(__FILE__).'/config-defaults.php');
require_once(dirname(__FILE__).'/common.php');
if(isset($usepdfexport) && $usepdfexport == 1)
{
require_once($pdfexportdir."/extensiontcpdf.php");
}
if (!isset($surveyid)) {$surveyid=returnglobal('sid');}
else {
//This next line ensures that the $surveyid value is never anything but a number.
$surveyid=sanitize_int($surveyid);
}
// Compute the Session name
// Session name is based:
// * on this specific limesurvey installation (Value SessionName in DB)
// * on the surveyid (from Get or Post param). If no surveyid is given we are on the public surveys portal
$usquery = "SELECT stg_value FROM ".db_table_name("settings_global")." where stg_name='SessionName'";
$usresult = db_execute_assoc($usquery,'',true); //Checked
if ($usresult)
{
$usrow = $usresult->FetchRow();
$stg_SessionName=$usrow['stg_value'];
if ($surveyid)
{
@session_name($stg_SessionName.'-runtime-'.$surveyid);
}
else
{
@session_name($stg_SessionName.'-runtime-publicportal');
}
}
else
{
session_name("LimeSurveyRuntime-$surveyid");
}
session_set_cookie_params(0,$relativeurl.'/');
@session_start();
if (isset($_SESSION['sid'])) {$surveyid=$_SESSION['sid'];} else die('Invalid survey/session');
//Debut session time out
if (!isset($_SESSION['finished']) || !isset($_SESSION['srid']))
// Argh ... a session time out! RUN!
//display "sorry but your session has expired"
{
require_once($rootdir.'/classes/core/language.php');
$baselang = GetBaseLanguageFromSurveyID($surveyid);
$clang = new limesurvey_lang($baselang);
//A nice exit
sendcacheheaders();
doHeader();
echo templatereplace(file_get_contents(sGetTemplatePath(validate_templatedir("default"))."/startpage.pstpl"));
echo "<center><br />\n"
."\t<font color='RED'><strong>".$clang->gT("ERROR")."</strong></font><br />\n"
."\t".$clang->gT("We are sorry but your session has expired.")."<br />".$clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.")."<br />\n"
."\t".sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$siteadminname,$siteadminemail)."\n"
."</center><br />\n";
echo templatereplace(file_get_contents(sGetTemplatePath(validate_templatedir("default"))."/endpage.pstpl"));
doFooter();
exit;
};
//Fin session time out
$id=$_SESSION['srid']; //I want to see the answers with this id
$clang = $_SESSION['s_lang'];
//A little bit of debug to see in the noodles plate
/*if ($debug==2)
{
echo "MonSurveyID $surveyid et ma langue ". $_SESSION['s_lang']. " et SRID = ". $_SESSION['srid'] ."<br />";
echo "session id".session_id()." \n"."<br />";
echo //"secanswer ". $_SESSION['secanswer']
"oldsid ". $_SESSION['oldsid']."<br />"
."step ". $_SESSION['step']."<br />"
."scid ". $_SESSION['scid']
."srid ". $_SESSION['srid']."<br />"
."datestamp ". $_SESSION['datestamp']."<br />"
."insertarray ". $_SESSION['insertarray']."<br />"
."fieldarray ". $_SESSION['fieldarray']."<br />";
."holdname". $_SESSION['holdname'];
print " limit ". $limit."<br />"; //afficher les 50 derniéres réponses par ex. (pas nécessaire)
print " surveyid ".$surveyid."<br />"; //sid
print " id ".$id."<br />"; //identifiant de la réponses
print " order ". $order ."<br />"; //ordre de tri (pas nécessaire)
print " this survey ". $thissurvey['tablename'];
}; */
//Ensure script is not run directly, avoid path disclosure
if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die("browse - Cannot run this script directly");}
// Set the language for dispay
require_once($rootdir.'/classes/core/language.php'); // has been secured
if (isset($_SESSION['s_lang']))
{
$clang = SetSurveyLanguage( $surveyid, $_SESSION['s_lang']);
$language = $_SESSION['s_lang'];
} else {
$language = GetBaseLanguageFromSurveyID($surveyid);
$clang = SetSurveyLanguage( $surveyid, $language);
}
// Get the survey inforamtion
$thissurvey = getSurveyInfo($surveyid,$language);
//SET THE TEMPLATE DIRECTORY
if (!isset($thissurvey['templatedir']) || !$thissurvey['templatedir'])
{
$thistpl=validate_templatedir("default");
}
else
{
$thistpl=validate_templatedir($thissurvey['templatedir']);
}
if ($thissurvey['printanswers']=='N') die(); //Die quietly if print answers is not permitted
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$actquery = "SELECT * FROM ".db_table_name('surveys')." as a inner join ".db_table_name('surveys_languagesettings')." as b on (b.surveyls_survey_id=a.sid and b.surveyls_language=a.language) WHERE a.sid=$surveyid";
$actresult = db_execute_assoc($actquery); //Checked
$actcount = $actresult->RecordCount();
if ($actcount > 0)
{
while ($actrow = $actresult->FetchRow())
{
$surveytable = db_table_name("survey_".$actrow['sid']);
$surveyname = "{$actrow['surveyls_title']}";
}
}
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = '';
if(isset($usepdfexport) && $usepdfexport == 1)
{
$printoutput .= "<form action='printanswers.php?printableexport=pdf&sid=$surveyid' method='post'>\n<center><input type='submit' value='".$clang->gT("PDF Export")."'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
}
if(isset($_POST['printableexport']))
{
$pdf = new PDF($pdforientation);
$pdf->SetFont($pdfdefaultfont,'',$pdffontsize);
$pdf->AddPage();
$pdf->titleintopdf($clang->gT("Survey name (ID)",'unescaped').": {$surveyname} ({$surveyid})");
}
$printoutput .= "\t<div class='printouttitle'><strong>".$clang->gT("Survey name (ID):")."</strong> $surveyname ($surveyid)</div><p> \n";
$aFullResponseTable=aGetFullResponseTable($surveyid,$id,$language);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset ($aFullResponseTable['id']);
unset ($aFullResponseTable['token']);
unset ($aFullResponseTable['lastpage']);
unset ($aFullResponseTable['startlanguage']);
unset ($aFullResponseTable['datestamp']);
unset ($aFullResponseTable['startdate']);
$printoutput .= "<table class='printouttable' >\n";
if(isset($_POST['printableexport']))
{
$pdf->intopdf($clang->gT("Question",'unescaped').": ".$clang->gT("Your answer",'unescaped'));
}
$oldgid = 0;
$oldqid = 0;
foreach ($aFullResponseTable as $sFieldname=>$fname)
{
if (substr($sFieldname,0,4)=='gid_')
{
if(isset($_POST['printableexport']))
{
$pdf->intopdf(FlattenText($fname[0],true));
$pdf->ln(2);
}
else
{
$printoutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
}
}
elseif (substr($sFieldname,0,4)=='qid_')
{
if(isset($_POST['printableexport']))
{
$pdf->intopdf(FlattenText($fname[0].$fname[1],true).": ".$fname[2]);
$pdf->ln(2);
}
else
{
$printoutput .= "\t<tr class='printanswersquestionhead'><td colspan='2'>{$fname[0]}</td></tr>\n";
}
}
else
{
if(isset($_POST['printableexport']))
{
$pdf->intopdf(FlattenText($fname[0].$fname[1],true).": ".$fname[2]);
$pdf->ln(2);
}
else
{
$printoutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
}
}
}
$printoutput .= "</table>\n";
if(isset($_POST['printableexport']))
{
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
$sExportFileName=sanitize_filename($surveyname);
$pdf->Output($sExportFileName."-".$surveyid.".pdf","D");
}
//Display the page with user answers
if(!isset($_POST['printableexport']))
{
sendcacheheaders();
doHeader();
echo templatereplace(file_get_contents(sGetTemplatePath($thistpl).'/startpage.pstpl'));
echo templatereplace(file_get_contents(sGetTemplatePath($thistpl).'/printanswers.pstpl'),array('ANSWERTABLE'=>$printoutput));
echo templatereplace(file_get_contents(sGetTemplatePath($thistpl).'/endpage.pstpl'));
echo "</body></html>";
}
?>
| ||||
| Bug heat | 6 | ||||
| Complete LimeSurvey version number (& build) | 10629 | ||||
| I will donate to the project if issue is resolved | Yes | ||||
| Browser | IE | ||||
| Database type & version | MySQL | ||||
| Server OS (if known) | LINUX - RedHat | ||||
| Webserver software & version (if known) | Apache 2.0 | ||||
| PHP Version | 5.1.6 | ||||
| Git branch / Pull Request URL | |||||
|
Please use attached patch - we are looking forward to your donation! |
|
|
Sorry but the Hot patch doesn't work. |
|
|
I see - I thought you were talking about exporting responses in the admin interface. Actually there have not been any changes since 10377 on that code. Which IE browser are you using? |
|
|
Hi, Maybe it would be easier to update the system from 10629 to 10377, how I get the source code for older build ? ( tar or gzip ) |
|
|
Please try the attached file and give feedback. |
|
|
Feedback please? |
|
|
Hi, regards |
|
|
Is there anything I can do to get this to work? Right now I have an urgent project that the PDF export is working fine with Firefox, Chrome, and all Mac Browsers. However, in IE 8 it fails. I have attached an image of the error for your review. Please let me know if there is anything I can do. I have the latest limesurvey download available on the main site. Thanks! |
|
|
Nevermind. this is working correctly now. This was more user error than anything. Looks like the latest release fixes this problem. |
|
|
Okay, great ;). |
|
|
LimeSurvey: Yii 66a1a342 2011-09-02 09:05 Details Diff |
Fixed issue 05432: Option to export responses to PDF by participant fails when using IE git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@10924 b72ed6b6-b9f8-46b5-92b4-906544132732 |
Affected Issues 05432 |
|
| mod - application/controllers/printanswers.php | Diff File | ||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2011-08-29 21:56 | kolmen1 | New Issue | |
| 2011-08-29 23:21 | c_schmitz | Assigned To | => c_schmitz |
| 2011-08-29 23:21 | c_schmitz | Status | new => assigned |
| 2011-08-29 23:21 | c_schmitz | File Added: exportresults.php | |
| 2011-08-29 23:22 | c_schmitz | Note Added: 16177 | |
| 2011-08-29 23:24 | c_schmitz | Status | assigned => resolved |
| 2011-08-29 23:24 | c_schmitz | Fixed in Version | => 1.91+ |
| 2011-08-29 23:24 | c_schmitz | Resolution | open => fixed |
| 2011-08-30 13:09 | kolmen1 | Note Added: 16179 | |
| 2011-08-30 13:09 | kolmen1 | Status | resolved => feedback |
| 2011-08-30 13:09 | kolmen1 | Resolution | fixed => reopened |
| 2011-08-30 13:33 | c_schmitz | Note Added: 16180 | |
| 2011-08-30 13:35 | c_schmitz | Note Edited: 16180 | |
| 2011-08-30 13:57 | kolmen1 | Note Added: 16181 | |
| 2011-08-30 13:57 | kolmen1 | Status | feedback => assigned |
| 2011-09-02 15:59 | c_schmitz | File Deleted: exportresults.php | |
| 2011-09-02 15:59 | c_schmitz | File Added: printanswers.php | |
| 2011-09-02 16:00 | c_schmitz | Note Added: 16209 | |
| 2011-09-02 16:00 | c_schmitz | Status | assigned => feedback |
| 2011-10-18 17:41 | c_schmitz | Note Added: 16445 | |
| 2011-10-18 19:58 | kolmen1 | Note Added: 16457 | |
| 2011-10-18 19:58 | kolmen1 | Status | feedback => assigned |
| 2011-10-19 07:41 | macphreak | Note Added: 16468 | |
| 2011-10-19 07:41 | macphreak | File Added: Screen Shot 2011-10-19 at 1.40.12 AM.png | |
| 2011-10-19 17:02 | macphreak | Note Added: 16474 | |
| 2011-10-19 19:21 | c_schmitz | Note Added: 16480 | |
| 2011-10-19 19:21 | c_schmitz | Status | assigned => closed |
| 2011-10-19 19:21 | c_schmitz | Resolution | reopened => fixed |
| 2012-03-14 21:08 | c_schmitz | Changeset attached | => Import 2012-03-09 13:30:34 Yii 66a1a342 |