- Posts: 23
- Thank you received: 2
Ask the community, share ideas, and connect with other LimeSurvey users!
user#1 https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/newtest/Y/lang/es/token/868 clicked on "Continue Later", and the received url via email https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/loadall/reload/scid/38/lang/es/loadname/user#1/loadpass/PASSWORD/token/868 user#2 https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/newtest/Y/lang/es/token/qvg clicked on "Continue Later", and the received url via email https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/loadall/reload/scid/39/lang/es/loadname/user#2/loadpass/PASSWORD/token/qvg
You can use the API list_surveys() method to list details of all surveys accessible by a given user.The LimeSurvey RPC (api?) seems to provide the functionality that would help here.
Reading up on its documentation, I think it's possible to have the rpc (api) return a list of surveys.
<?php require_once 'jsonRPCClient.php'; define( 'LS_BASEURL', 'https://pathTo/limeSurvey/'); define( 'LS_USER', 'admin' ); define( 'LS_PASSWORD', 'password' ); if(!isset($_GET["username"])) { echo 'No user specified!'; return false; } else { $sUsername = $_GET["username"]; } // NOTE: You could do some more validation and/or conditions regarding the username here // Instantiate a new RPC client $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' ); // Get a session key $sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD ); // Get survey info for all surveys accessible by $sUsername $surveys = $myJSONRPCClient->list_surveys($sSessionKey, $sUsername); if(array_key_exists('status', $surveys) && $surveys['status'] == 'Invalid user') { echo 'Invalid user specified!'; return false; } else { // Sort the results by survey title - https://docs.php.net/manual/en/function.array-multisort.php foreach ($surveys as $key => $row) { $sid[$key] = $row['sid']; $surveyls_title[$key] = $row['surveyls_title']; $startdate[$key] = $row['startdate']; $expires[$key] = $row['expires']; $active[$key] = $row['active']; } array_multisort($surveyls_title, SORT_ASC, $surveys); // Print the results in a table $tableHTML = '<table class="surveys-list" style="border-collapse: collapse;" border=1>'; $tableHTML .= '<tr>'; $tableHTML .= '<th>Title</th>'; $tableHTML .= '<th>SID</th>'; $tableHTML .= '<th>Start Date</th>'; $tableHTML .= '<th>Expires</th>'; $tableHTML .= '<th>Active</th>'; $tableHTML .= '<th>Link</th>'; $tableHTML .= '<tr>'; foreach ($surveys as $surveyInfo) { $tableHTML .= '<tr>'; $tableHTML .= '<td>'.$surveyInfo['surveyls_title'].'</td>'; $tableHTML .= '<td>'.$surveyInfo['sid'].'</td>'; $tableHTML .= '<td>'.$surveyInfo['startdate'].'</td>'; $tableHTML .= '<td>'.$surveyInfo['expires'].'</td>'; $tableHTML .= '<td>'.$surveyInfo['active'].'</td>'; $tableHTML .= '<td>'; if($surveyInfo['active'] == 'Y') { $tableHTML .= '<a href="'.LS_BASEURL.'index.php/'.$surveyInfo['sid'].'?newtest=Y" target="_blank">Survey Link</a>'; } $tableHTML .= '</td>'; $tableHTML .= '<tr>'; } $tableHTML .= '</table>'; echo $tableHTML; } // Release the session key $myJSONRPCClient->release_session_key( $sSessionKey ); ?>
$myJSONRPCClient = new org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'index.php?r=admin/remotecontrol', true);
Bad Request
The CSRF token could not be verified.
The request could not be understood by the server due to malformed syntax. Please do not repeat the request without modifications.
If you think this is a server error, please contact the webmaster.
2017-08-25 16:10:41
***** End of Response *****
/limesurvey/application/config/config.php
// Disable CSRF protection 'request' => array( 'enableCsrfValidation'=>false, ),
***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response *****
CException
Application runtime path "/var/www/html/limesurvey/application/runtime" is not valid. Please make sure it is a directory writable by the Web server process.
***** End of Response *****
/var/www/html/limesurvey/application
/var/www/html/limesurvey/application/runtime
***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response *****
Internal Server Error
Property "LSYii_Application.request" is read only.
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
Thank you.
2017-08-25 16:23:33
***** End of Response *****
/var/www/html/limesurvey/application/runtime
'runtimePath'=>'/var/www/html/limesurvey/application/runtime/'
***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response ***** ***** End of Response *****