summaryrefslogtreecommitdiffstats
path: root/al_php.c
blob: 2d5e39c4a777dd1d561cc7fcefe23ca88fd1b4d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (C) 2010-2018 Bertrand Jacquin <bertrand@jacquin.bzh>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License, version 2.1, as published by the Free Software Foundation.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 */


#ifdef HAVE_PHP

#include <httpd.h>
#include <http_config.h>

#include <php.h>
#include <php_ini.h>

#include <zend.h>

#if PHP_MAJOR_VERSION < 7
# include <zend_qsort.h>
#else
# include <zend_sort.h>
#endif

#include <zend_API.h>
#include <zend_ini.h>
#include <zend_alloc.h>
#include <zend_operators.h>

#include "mod_virtualvalue.h"
#include "al_php.h"

#if PHP_MAJOR_VERSION < 7
# define MOD_VIRTUALVALUE__ZEND_ALTER_INI_ENTRY__STR(_str) \
    _str, strlen(_str) + 1
#else
# define MOD_VIRTUALVALUE__ZEND_ALTER_INI_ENTRY__STR(_str) \
    zend_string_init(_str, strlen(_str), 1)
#endif

int vv_php_alter_ini(int argc __U__, char **argv, request_rec *r)
{
  char *arg;

  VV_debug("Translating %s %s", argv[0], argv[1]);
  arg = vv_flat_arg(argv[1], r);

  if (zend_alter_ini_entry_ex(MOD_VIRTUALVALUE__ZEND_ALTER_INI_ENTRY__STR(argv[0]),
                           MOD_VIRTUALVALUE__ZEND_ALTER_INI_ENTRY__STR(arg),
                           PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE, 1) == FAILURE)
    VV_error("zend_alter_ini_entry_ex() failed (%s %s)", argv[0], arg);

  VV_debug("Altered to %s %s", argv[0], arg);

  return (OK);
}
#endif /* HAVE_PHP */