]> git.agnieray.net Git - galette.git/blob - galette/post_contribution_test.php
Merge branch 'hotfix/1.0.4'
[galette.git] / galette / post_contribution_test.php
1 #!/usr/bin/php
2 <?php
3
4 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
5
6 /**
7 * Post configuration script test
8 *
9 * PHP version 5
10 *
11 * Copyright © 2013-2014 The Galette Team
12 *
13 * This file is part of Galette (http://galette.tuxfamily.org).
14 *
15 * Galette is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation, either version 3 of the License, or
18 * (at your option) any later version.
19 *
20 * Galette is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
27 *
28 * @category Core
29 * @package Galette
30 *
31 * @author Johan Cwiklinski <johan@x-tnd.be>
32 * @copyright 2013-2014 The Galette Team
33 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.7.5dev - 2013-06-10
36 */
37
38 $args = array();
39 $internal = false;
40
41 if (defined('STDIN')) {
42 //we're called from command line
43 $args = stream_get_contents(STDIN);
44 } else if (count($_POST) > 0) {
45 //we're called from HTTP POST
46 $args = $_POST;
47 //check if we're called from galette internal
48 if (isset($_POST['galette_internal'])) {
49 $internal = true;
50 include_once 'includes/galette.inc.php';
51 unset($_POST['galette_internal']);
52 Analog\Analog::info(
53 'Requested as Galette HTTP POST with parameters:' . "\n" .
54 print_r($args, true)
55 );
56 } else {
57 echo 'Requested as HTTP POST with parameters:<br/>';
58 }
59 } else if (count($_GET) > 0) {
60 //we're called from HTTP GET
61 echo 'Requested as HTTP GET with parameters:<br/>';
62 $args = $_GET;
63 }
64
65 if (count($args) == 0) {
66 //we're called without arguments => exit.
67 die('No arguments.');
68 }
69
70 if (defined('STDIN')) {
71 //a successfull script returns 0, we do not output anything
72 $fp = fopen(__DIR__ . '/cache/galette_post_contrib_file.txt', 'w');
73 fwrite($fp, $args);
74 fclose($fp);
75 } else {
76 $json_args = json_decode($args);
77 foreach ($json_args as $k => $v) {
78 echo 'key: ' . $k . ' | value: ' . $v;
79 }
80 }