Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

show public statics register users limesurvey

  • Vanhels
  • Vanhels's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 6 months ago - 5 years 6 months ago #175432 by Vanhels
How can I obtain the registration of the participant's ip, to validate that only those who responded to the survey can view the public statistics, since anyone with the url can view them, I know yii, php, but I do not see how to return the model in the driver the value of ipaddr.

I got a half solution since I have to manually add in a txt file the ip addresses, some comments my code:


My code:

$whitelist = explode("\n", file_get_contents('/home/domain/subdomain/whitelist.txt'));

if ($surveyinfo != 'Y' || (!in_array($_SERVER, $whitelist))) {
throw new CHttpException(404, 'Las estadisticas para esta Encuesta no son públicas.');
}
Last edit: 5 years 6 months ago by Vanhels.
The topic has been locked.
  • Vanhels
  • Vanhels's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 6 months ago - 5 years 6 months ago #175444 by Vanhels
Replied by Vanhels on topic show public statics register users limesurvey
I got a solution I share with you.

Code:
My Code: /application/controllers/Statistics_userController.php:
 
$whitelist =  SurveyDynamic::model($iSurveyID)->findByAttributes(array("ipaddr"=>$_SERVER['REMOTE_ADDR']));
 
if ($surveyinfo['publicstatistics'] != 'Y' || (!$whitelist)) {
    throw new CHttpException(404, 'Las estadisticas para esta Encuesta no son públicas.');
}

In this way, the results of the survey can only be viewed by the participants.
Last edit: 5 years 6 months ago by Vanhels.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 6 months ago #175451 by DenisChenu
Replied by DenisChenu on topic show public statics register users limesurvey
And without hacking limesurvey core :

manual.limesurvey.org/BeforeControllerAction

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: Vanhels
The topic has been locked.
  • Vanhels
  • Vanhels's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 6 months ago #175456 by Vanhels
Replied by Vanhels on topic show public statics register users limesurvey
I know that there is that function so I asked the question which would be the best way, as an improvement could be offered that the public statistics will be shown by ip or token would be great.

You could show us how to use the BeforeControllerAction in LimeSurvey.

Thank you,
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 6 months ago #175457 by DenisChenu
Replied by DenisChenu on topic show public statics register users limesurvey
Example here : gitlab.com/SondagesPro/ExportAndStats/pd...r/pdfReport.php#L291

All (or near all) my code are public

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 6 months ago #175459 by tpartner
Replied by tpartner on topic show public statics register users limesurvey

All (or near all) my code are public

You da man! :)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose