You can do ANYTHING with beforeSurveyPage (in a survey) or more :
manual.limesurvey.org/BeforeControllerAction
(everywhere).
If you already have a php code, it can be adapted for LimeSurvey in a plugin.
If you already have a php code, it can be adapted for LimeSurvey in a plugin.