source: branches/2.4/rest/setup/default_records.inc.php @ 7442

Revision 7442, 2.1 KB checked in by eduardow, 7 years ago (diff)

Ticket #3093 - Integrando API Rest (CELEPAR) - commit para o branches.

Line 
1<?php
2
3  /**************************************************************************\
4  * eGroupWare - Setup                                                       *
5  * http://www.egroupware.org                                                *
6  * --------------------------------------------                             *
7  *  This program is free software; you can redistribute it and/or modify it *
8  *  under the terms of the GNU General Public License as published by the   *
9  *  Free Software Foundation; either version 2 of the License, or (at your  *
10  *  option) any later version.                                              *
11  \**************************************************************************/
12
13$secret = substr(md5(rand().rand()), 0, 16); //Gera senha aleatoria
14
15$oProc->query("INSERT INTO rest_client (client_id, client_secret) values (1, '$secret');");
16$dados = array();
17$oProc->query("SELECT * FROM phpgw_config WHERE config_app='phpgwapi'");
18while ($oProc->next_record())
19{
20    $test = @unserialize($oProc->f('config_value'));
21    if($test)
22        $dados[$oProc->f('config_name')] = $test;
23    else
24        $dados[$oProc->f('config_name')] = $oProc->f('config_value');
25}
26
27/*
28Cria e configura o arquivo REST.ini
29*/
30require_once dirname(__FILE__) . '/../../prototype/api/config.php';
31
32use prototype\api\Config as Config;
33
34$config = array();
35$config['baseUri'] = $dados['webserver_url'].'/rest';
36$config['oauth']['url_token'] = 'http://' . $_SERVER['HTTP_HOST'] . $dados['webserver_url'].'/rest/token';
37$config['oauth']['client_id'] = 1;
38$config['oauth']['client_secret'] = $secret;
39
40$serverID = "001";
41$config['ServersRest-'.$serverID]['serverID'] = $serverID;
42$config['ServersRest-'.$serverID]['serverName'] = $_SERVER['HTTP_HOST'];
43$config['ServersRest-'.$serverID]['serverDescription'] = 'Expresso - ' . $_SERVER['HTTP_HOST'];
44$config['ServersRest-'.$serverID]['serverUrl'] = 'http://' . $_SERVER['HTTP_HOST'] . $dados['webserver_url'];
45$config['ServersRest-'.$serverID]['serverContext'] = '/rest/';
46$config['ServersRest-'.$serverID]['serverStatus'] = 'true';
47
48Config::writeIniFile($config , dirname(__FILE__) . '/../../prototype/config/REST.ini', true);
49
50?>
Note: See TracBrowser for help on using the repository browser.