Welcome to the LimeSurvey Community Forum

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

show public statics register users limesurvey

More
6 years 10 months ago - 6 years 10 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: 6 years 10 months ago by Vanhels.
The topic has been locked.
More
6 years 10 months ago - 6 years 10 months ago #175444 by Vanhels
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: 6 years 10 months ago by Vanhels.
The topic has been locked.
More
6 years 10 months ago #175451 by DenisChenu
And without hacking limesurvey core :

www.limesurvey.org/manual/BeforeControllerAction

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: Vanhels
The topic has been locked.
More
6 years 10 months ago #175456 by Vanhels
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.
More
6 years 10 months ago #175457 by DenisChenu
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 support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
6 years 10 months ago #175459 by tpartner

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.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose