[6368] | 1 | <?php |
---|
| 2 | |
---|
[6468] | 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 | |
---|
[6368] | 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(); |
---|
[7342] | 17 | $oProc->query("SELECT * FROM phpgw_config WHERE config_app='phpgwapi'"); |
---|
[6368] | 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 | |
---|
[7342] | 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 | |
---|
[6368] | 48 | Config::writeIniFile($config , dirname(__FILE__) . '/../../prototype/config/REST.ini', true); |
---|
| 49 | |
---|
[7342] | 50 | ?> |
---|