Commit 26be976b authored by Esteban Choque's avatar Esteban Choque

Se añadió AuthLDAP a la función get_session_key

parents
Pipeline #1504 canceled with stages
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0f24921a1fd201137775f28332fc91b7",
"packages": [
{
"name": "weberhofer/jsonrpcphp",
"version": "2.2.1",
"source": {
"type": "git",
"url": "https://github.com/weberhofer/jsonrpcphp.git",
"reference": "e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/weberhofer/jsonrpcphp/zipball/e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2",
"reference": "e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"autoload": {
"psr-0": {
"org\\jsonrpcphp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "Johannes Weberhofer",
"email": "jweberhofer@weberhofer.at",
"homepage": "http://www.weberhofer.at",
"role": "Developer"
},
{
"name": "Sergio Vaccaro",
"email": "info@jsonrpcphp.org",
"homepage": "http://jsonrpcphp.org/",
"role": "Developer"
}
],
"description": "JSON-RPC for PHP 5.3+",
"homepage": "https://github.com/weberhofer/jsonrpcphp",
"keywords": [
"json",
"rpc"
],
"time": "2015-07-08T05:49:59+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
<?php
require_once 'jsonRPCClient.php';
define( 'LS_BASEURL', 'https://ctic.gob.bo/formularios/index.php');
define( 'LS_USER', 'esteban.choque' );
define( 'LS_PASSWORD', 'gus2A3iYCgZUwiRjx8JBg8FgRuTWi2Pu' );
$iSurveyID_org = 13127;
$sNewname = 'Copy of survey 13127';
if(ctype_alnum($iSurveyID_org) && strlen($iSurveyID_org == 6)) { // Valid SID format
// 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 );
if(is_array($sSessionKey)) { // Invalid session
echo $sSessionKey['status'];
}
else if($sSessionKey) { // Valid session
// Copy survey
$newSurvey = $myJSONRPCClient->copy_survey($sSessionKey, $iSurveyID_org, $sNewname);
// Print results
print_r($newSurvey);
}
// Release the session key
$myJSONRPCClient->release_session_key( $sSessionKey );
}
else { // Invalid SID format
die( 'Invalid format!' );
}
?>
\ No newline at end of file
<?php
// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
include_once 'vendor/autoload.php';
define( 'LS_BASEURL', 'https://ctic.gob.bo/formularios/index.php'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'esteban.choque' );
define( 'LS_PASSWORD', 'gus2A3iYCgZUwiRjx8JBg8FgRuTWi2Pu' );
echo "<h1>Conectando a limesurvey ctic</h1>";
// the survey to process
$survey_id = 415179;
$group_id = 133;
$question_id = 1760;
$id_participante = $_GET["id_participante"];
$value = $_GET["value"];
// Array para una determinada respuesta
$aResponseData = array(
/*"id" => "2",
"425829X2X4" => "Cristian",
"425829X2X5" => "Salas Espinal",
"425829X2X6" => "852147",
"425829X2X7" => "0",
"425829X2X8" => "1",*/
"id" => $id_participante,
$survey_id."X".$group_id."X".$question_id => $value,
);
// instantiate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD, 'AuthLDAP' );
echo "Preguntas</br></br>";
$quest = $myJSONRPCClient->list_questions( $sessionKey, $survey_id );
print_r($quest, null );
echo "</br></br>Actualizar response </br></br>";
//Actualizar response
$response = $myJSONRPCClient->update_response( $sessionKey, $survey_id, $aResponseData);
print_r($response, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
<?php
// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
include_once 'vendor/autoload.php';
/*define( 'LS_BASEURL', 'https://ctic.gob.bo/formularios/index.php/admin/remotecontrol'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'bladimir.morales' );
define( 'LS_PASSWORD', 'BLMorales1208' );*/
define( 'LS_BASEURL', 'http://localhost/limesurvey/index.php'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'password' );
// the survey to process
$survey_id = 653791;
$group_id = 3;
$question_id = 14;
$id_participante = "1";
$value = "1";
// Array para una determinada respuesta
$aResponseData = array(
/*"id" => "2",
"425829X2X4" => "Cristian",
"425829X2X5" => "Salas Espinal",
"425829X2X6" => "852147",
"425829X2X7" => "0",
"425829X2X8" => "1",*/
"id" => $id_participante,
$survey_id."X".$group_id."X".$question_id => $value,
);
// instantiate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
echo "Preguntas</br></br>";
$quest = $myJSONRPCClient->list_questions( $sessionKey, $survey_id );
print_r($quest, null );
echo "</br></br>Actualizar response </br></br>";
//Actualizar response
$response = $myJSONRPCClient->update_response( $sessionKey, $survey_id, $aResponseData);
print_r($response, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
<?php
// without composer this line can be used
// require_once 'path/to/your/rpcclient/jsonRPCClient.php';
// with composer support just add the autoloader
include_once 'vendor/autoload.php';
/*define( 'LS_BASEURL', 'https://ctic.gob.bo/formularios/index.php/admin/remotecontrol'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'bladimir.morales' );
define( 'LS_PASSWORD', 'BLMorales1208' );*/
define( 'LS_BASEURL', 'http://172.29.1.4/limesurvey/index.php'); // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'admin' );
define( 'LS_PASSWORD', 'password' );
echo "<strong>Conectando a limesurvey del server test</strong></br></br>";
// the survey to process
/*$survey_id = 896315;
$group_id = 1;
$question_id = 6;
$id_participante = "1";
$value = "1";*/
$survey_id = 896315;
$group_id = 1;
$question_id = 6;
$id_participante = $_GET["id_participante"];
$value = $_GET["value"];
// Array para una determinada respuesta
$aResponseData = array(
/*"id" => "2",
"425829X2X4" => "Cristian",
"425829X2X5" => "Salas Espinal",
"425829X2X6" => "852147",
"425829X2X7" => "0",
"425829X2X8" => "1",*/
"id" => $id_participante,
$survey_id."X".$group_id."X".$question_id => $value,
);
// instantiate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'?r=admin/remotecontrol' );
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
echo "Preguntas</br></br>";
$quest = $myJSONRPCClient->list_questions( $sessionKey, $survey_id );
print_r($quest, null );
echo "</br></br>Actualizar response </br></br>";
//Actualizar response
$response = $myJSONRPCClient->update_response( $sessionKey, $survey_id, $aResponseData);
print_r($response, null );
// release the session key
$myJSONRPCClient->release_session_key( $sessionKey );
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitd389c84cd7135e1d595a0b5d7cc53826::getLoader();
This diff is collapsed.
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'org\\jsonrpcphp\\' => array($vendorDir . '/weberhofer/jsonrpcphp/src'),
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInitd389c84cd7135e1d595a0b5d7cc53826
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInitd389c84cd7135e1d595a0b5d7cc53826', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd389c84cd7135e1d595a0b5d7cc53826', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitd389c84cd7135e1d595a0b5d7cc53826::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInitd389c84cd7135e1d595a0b5d7cc53826
{
public static $prefixesPsr0 = array (
'o' =>
array (
'org\\jsonrpcphp\\' =>
array (
0 => __DIR__ . '/..' . '/weberhofer/jsonrpcphp/src',
),
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixesPsr0 = ComposerStaticInitd389c84cd7135e1d595a0b5d7cc53826::$prefixesPsr0;
}, null, ClassLoader::class);
}
}
[
{
"name": "weberhofer/jsonrpcphp",
"version": "2.2.1",
"version_normalized": "2.2.1.0",
"source": {
"type": "git",
"url": "https://github.com/weberhofer/jsonrpcphp.git",
"reference": "e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/weberhofer/jsonrpcphp/zipball/e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2",
"reference": "e1a79bb3f08e20ae04e1e32deaff6a32eed4dad2",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"time": "2015-07-08T05:49:59+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"org\\jsonrpcphp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "Johannes Weberhofer",
"email": "jweberhofer@weberhofer.at",
"homepage": "http://www.weberhofer.at",
"role": "Developer"
},
{
"name": "Sergio Vaccaro",
"email": "info@jsonrpcphp.org",
"homepage": "http://jsonrpcphp.org/",
"role": "Developer"
}
],
"description": "JSON-RPC for PHP 5.3+",
"homepage": "https://github.com/weberhofer/jsonrpcphp",
"keywords": [
"json",
"rpc"
]
}
]
*.php text
*.md text
*.json text
.gitattributes text
.gitignore text
composer.phar
vendor/
.project
.settings
.buildpath
This diff is collapsed.
JSON-RPC PHP
============
JSON-RPC PHP is a couple of classes written in PHP implementing respectively
client and server functionalities of the JSON-RPC protocol.
This software has originally been developed at http://jsonrpcphp.org/ and has
been modified to support newer PHP versions and name-spaces; some bugs have
been fixed.
To install
```bash
composer require weberhofer/jsonrpcphp
```
or add this to your composer.json, and ```composer update```
```JSON
{
"require": {
"weberhofer/jsonrpcphp": "~2"
}
}
```
{
"name": "weberhofer/jsonrpcphp",
"type": "library",
"description": "JSON-RPC for PHP 5.3+",
"keywords": ["json","rpc"],
"homepage": "https://github.com/weberhofer/jsonrpcphp",
"license": "GPL-2.0+",
"authors": [
{
"name": "Johannes Weberhofer",
"email": "jweberhofer@weberhofer.at",
"homepage": "http://www.weberhofer.at",
"role": "Developer"
},
{
"name": "Sergio Vaccaro",
"email": "info@jsonrpcphp.org",
"homepage": "http://jsonrpcphp.org/",
"role": "Developer"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/weberhofer/jsonrpcphp"
}
],
"support": {
"issues": "https://github.com/weberhofer/jsonrpcphp/issues"
},
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
"org\\jsonrpcphp\\": "src/"
}
}
}
<?php
/*
* Copyright 2007 Sergio Vaccaro <sergio@inservibile.org>
* Copyright 2012, 2015 Johannes Weberhofer <jweberhofer@weberhofer.at>
*
* This file is part of JSON-RPC PHP.
*
* JSON-RPC PHP is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* JSON-RPC PHP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with JSON-RPC PHP; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* The object of this class are generic jsonRPC 1.0 clients
*
* @see http://json-rpc.org/wiki/specification
* @license GPLv2+
* @author sergio <jsonrpcphp@inservibile.org>
* @author Johannes Weberhofer <jweberhofer@weberhofer.at>
*/
namespace org\jsonrpcphp;
class JsonRPCClient
{
/**
* Debug state
*
* @var boolean
*/
private $debug;
/**
* The server URL
*
* @var string
*/
private $url;
/**
* The request id
*
* @var integer
*/
private $id;
/**
* If true, notifications are performed instead of requests
*
* @var boolean
*/
private $notification = false;
/**
* If false, requests will be forced to use fopen() instead.
* This option is specific in case of cURL is callable but may not practically unsable.
*
* @var boolean
*/
private $enableCurl = true;
/**
* Takes the connection parameters
*
* @param string $url
* @param boolean $debug
*/
public function __construct($url, $debug = false)
{
// server URL
$this->url = $url;
// proxy
empty($proxy) ? $this->proxy = '' : $this->proxy = $proxy;
// debug state
empty($debug) ? $this->debug = false : $this->debug = true;
// message id
$this->id = 1;
}
/**
* Sets the notification state of the object.
* In this state, notifications are performed, instead of requests.
*
* @param boolean $notification
*/
public function setRPCNotification($notification)
{
empty($notification) ? $this->notification = false : $this->notification = true;
}
/**
* Performs a jsonRCP request and gets the results as an array
*
* @param string $method
* @param array $params
* @return array
*/
public function __call($method, $params)
{
// check
if (! is_scalar($method)) {
throw new \Exception('Method name has no scalar value');
}
// check
if (is_array($params)) {
// no keys
$params = array_values($params);
} else {
throw new \Exception('Params must be given as array');
}
// sets notification or request task
if ($this->notification) {
$currentId = null;
} else {
$currentId = $this->id;
}
// prepares the request
$request = array(
'method' => $method,
'params' => $params,
'id' => $currentId
);
$request = json_encode($request);
if ($this->debug) {
echo '***** Request *****' . "\n" . $request . "\n";
}
// performs the HTTP POST
if ($this->enableCurl && is_callable('curl_init')) {
// use curl when available; solves problems with allow_url_fopen
$ch = curl_init($this->url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
if ($response === false) {