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'"); |
---|
18 | while ($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 | /* |
---|
28 | Cria e configura o arquivo REST.ini |
---|
29 | */ |
---|
30 | require_once dirname(__FILE__) . '/../../prototype/api/config.php'; |
---|
31 | |
---|
32 | use 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 | Config::writeIniFile($config , dirname(__FILE__) . '/../../prototype/config/REST.ini', true); |
---|
41 | |
---|
42 | |
---|
43 | ?> |
---|