[augeas-devel] [PATCH] Add PHP module and associated (basic) test file

raphink at gmail.com raphink at gmail.com
Fri Jul 25 11:22:46 UTC 2008


# HG changeset patch
# User Raphael Pinson <raphink at gmail.com>
# Date 1216984947 -7200
# Node ID 86411abff2eec6aa4364b7d3f43fe2e94e3ab31c
# Parent  a7d566eaab75da9bb533f9c0bc0bd00c4a89caee
Add PHP module and associated (basic) test file

diff -r a7d566eaab75 -r 86411abff2ee lenses/php.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/php.aug	Fri Jul 25 13:22:27 2008 +0200
@@ -0,0 +1,129 @@
+(* PHP module for Augeas                      *)
+(* Author: Raphael Pinson <raphink at gmail.com> *)
+(*                                            *)
+
+module PHP =
+
+    autoload xfm
+
+    (* Define a special entry when spaces are allowed in values *)
+    (* This is the case for error_reporting for example         *)
+    let comment_nospace  = IniFile.comment_generic /(#|;)/
+    let value_allowspace = del /[ \t]*/ " " . store /[^;# \t\n][^;#\n]*[^;# \t\n]|[^;# \t\n]/
+    let entry_allowspace (kw:regexp) = [ key kw . IniFile.value_sepwithcolon . value_allowspace? . (comment_nospace|IniFile.eol) ]
+
+    (* PHP is a standard INI file *)
+    let setting = IniFile.entry "always_populate_raw_post_data"
+                | IniFile.entry "asp_tags"
+                | IniFile.entry "browscap"
+                | IniFile.entry "child_terminate"
+                | IniFile.entry "define_syslog_variables"
+                | IniFile.entry "doc_root"
+                | IniFile.entry "enable_dl"
+                | IniFile.entry "engine"
+                | IniFile.entry "expose_php"
+                | IniFile.entry "extension_dir"
+                | IniFile.entry "file_uploads"
+		| IniFile.entry "gpc_order"
+                | IniFile.entry "html_errors"
+                | IniFile.entry "implicit_flush"
+                | IniFile.entry "include_path"
+                | IniFile.entry "last_modified"
+                | IniFile.entry "memory_limit"
+                | IniFile.entry "open_basedir"
+                | IniFile.entry "post_max_size"
+                | IniFile.entry "precision"
+                | IniFile.entry "serialize_precision"
+                | IniFile.entry "short_open_tag"
+                | IniFile.entry "SMTP"
+                | IniFile.entry "smtp_port"
+                | IniFile.entry "track_errors"
+                | IniFile.entry "unserialize_callback_func"
+                | IniFile.entry "variables_order"
+                | IniFile.entry "xbithack"
+                | IniFile.entry "y2k_compliance"
+                | IniFile.entry /apc\.(cache_by_default|enabled|filters|gc_ttl|mmap_file_mask|num_files_hint|optimization|shm_segments|shm_size|slam_defense|ttl|user_entries_hint|user_ttl)/
+                | IniFile.entry /apd\.(dumpdir|statement_tracing)/
+                | IniFile.entry /arg_separator\.(input|output)/
+                | IniFile.entry /assert\.(active|bail|callback|quiet_eval|warning)/
+                | IniFile.entry /bcmath\.(scale)/
+                | IniFile.entry /blenc\.(key_file)/
+                | IniFile.entry /com\.(allow_dcom|autoregister_casesensitive|autoregister_typelib|autoregister_verbose|code_page|typelib_file)/
+                | IniFile.entry /crack\.(default_dictionary)/
+                | IniFile.entry /daffodildb\.(default_host|default_password|default_socket|default_user|port)/
+                | IniFile.entry /date\.(default_latitude|default_longitude|sunrise_zenith|sunset_zenith)/
+                | IniFile.entry /dba\.(default_handler)/
+                | IniFile.entry /dbx\.(colnames_case)/
+                | IniFile.entry /exif\.(decode_jis_intel|decode_jis_motorola|decode_unicode_intel|decode_unicode_motorola|encode_jis|encode_unicode)/
+                | IniFile.entry /fbsql\.(allow_persistent|autocommit|batchsize|default_database|default_database_password|default_host|default_password|default_user|generate_warnings|max_connections|max_links|max_persistent|max_results)/
+                | IniFile.entry /highlight\.(bg|comment|default|html|keyword|string)/
+                | IniFile.entry /hyperwave\.(allow_persistent|default_port)/
+                | IniFile.entry /ibase\.(allow_persistent|dateformat|default_charset|default_db|default_password|default_user|max_links|max_persistent|timeformat|timestampformat)/
+                | IniFile.entry /iconv\.(input_encoding|internal_encoding|output_encoding)/
+                | IniFile.entry /ifx\.(allow_persistent|blobinfile|byteasvarchar|charasvarchar|default_host|default_password|default_user|max_links|max_persistent|nullformat|textasvarchar)/
+                | IniFile.entry /ingres\.(allow_persistent|default_database|default_password|default_user|max_links|max_persistent)/
+                | IniFile.entry /ircg\.(control_user|keep_alive_interval|max_format_message_sets|shared_mem_size|work_dir)/
+                | IniFile.entry /ldap\.(max_links)/
+                | IniFile.entry /mail\.(force_extra_parameters)/
+                | IniFile.entry /mailparse\.(def_charset)/
+                | IniFile.entry /maxdb\.(default_db|default_host|default_pw|default_user|long_readlen)/
+                | IniFile.entry /mbstring\.(detect_order|encoding_translation|func_overload|http_input|http_output|internal_encoding|language|script_encoding|substitute_character)/
+                | IniFile.entry /mcrypt\.(algorithms_dir|modes_dir)/
+                | IniFile.entry /mime_magic\.(debug|magicfile)/
+                | IniFile.entry /mssql\.(allow_persistent|batchsize|compatability_mode|connect_timeout|datetimeconvert|max_links|max_persistent|max_procs|min_error_severity|min_message_severity|secure_connection|textlimit|textsize|timeout)/
+                | IniFile.entry /msql\.(allow_persistent|max_links|max_persistent)/
+                | IniFile.entry /mysql\.(allow_persistent|connect_timeout|default_host|default_password|default_port|default_socket|default_user|max_links|max_persistent|trace_mode)/
+                | IniFile.entry /mysqli\.(default_host|default_port|default_pw|default_socket|default_user|max_links|reconnect)/
+                | IniFile.entry /namazu\.(debugmode|lang|loggingmode|sortmethod|sortorder)/
+                | IniFile.entry /nsapi\.(read_timeout)/
+                | IniFile.entry /odbc\.(allow_persistent|check_persistent|defaultbinmode|defaultlrl|default_db|default_pw|default_user|max_links|max_persistent)/
+                | IniFile.entry /opendirectory\.(max_refs|separator)/
+                | IniFile.entry /pdo\.(global_value)/
+                | IniFile.entry /pfpro\.(defaulthost|defaultport|defaulttimeout|proxyaddress|proxylogon|proxypassword|proxyport)/
+                | IniFile.entry /pgsql\.(allow_persistent|auto_reset_persistent|ignore_notice|log_notice|max_links|max_persistent)/
+                | IniFile.entry /printer\.(default_printer)/
+                | IniFile.entry /session\.(auto_start|bug_compat_42|bug_compat_warn|cache_expire|cache_limiter|cookie_(domain|httponly|lifetime|path|secure)|entropy_file|entropy_length|gc_divisor|gc_maxlifetime|gc_probability|hash_bits_per_character|hash_function|name|referer_check|save_handler|save_path|serialize_handler|use_cookies|use_only_cookies|use_trans_sid)/
+                | IniFile.entry /session_pgsql\.(create_table|db|disable|failover_mode|gc_interval|keep_expired|sem_file_name|serializable|short_circuit|use_app_vars|vacuum_interval)/
+                | IniFile.entry /simple_cvs\.(authMethod|compressionLevel|cvsRoot|host|moduleName|userName|workingDir)/
+                | IniFile.entry /soap\.(wsdl_cache_dir|wsdl_cache_enabled|wsdl_cache_ttl)/
+                | IniFile.entry /sql\.(safe_mode)/
+                | IniFile.entry /sqlite\.(assoc_case)/
+		| IniFile.entry /sybase\.(allow_persistent|max_(persistent|links)|interface_file|min_(error|message)_severity|compatability_mode)/
+                | IniFile.entry /sybct\.(allow_persistent|deadlock_retry_count|hostname|login_timeout|max_links|max_persistent|min_client_severity|min_server_severity)/
+                | IniFile.entry /tidy\.(clean_output|default_config)/
+                | IniFile.entry /url_rewriter\.(tags)/
+                | IniFile.entry /valkyrie\.(auto_validate|config_path)/
+                | IniFile.entry /xmms\.(path|session)/
+                | IniFile.entry /yaz\.(keepalive|log_file|max_links)/
+                | IniFile.entry /zend\.(ze1_compatibility_mode)/
+                | IniFile.entry /zlib\.(output_compression|output_compression_level|output_handler)/
+                | IniFile.entry /allow_(call_time_pass_reference|url_fopen|url_include)/
+                | IniFile.entry /auto_(append_file|detect_line_endings|globals_jit|prepend_file)/
+                | IniFile.entry /default_(charset|mimetype|socket_timeout)/
+		| IniFile.entry /display(_startup)?_errors/
+                | IniFile.entry /disable_(classes|functions)/
+                | IniFile.entry /docref_(ext|root)/
+                | IniFile.entry /error_(append_string|log|prepend_string)/
+                | IniFile.entry /ignore_(repeated_errors|repeated_source|user_abort)/
+                | IniFile.entry /log_errors(_max_len)?/
+                | IniFile.entry /magic_quotes_(gpc|runtime|sybase)/
+                | IniFile.entry /max_(execution_time|input_time)/
+                | IniFile.entry /output_(buffering|handler)/
+                | IniFile.entry /realpath_(cache_size|cache_ttl)/
+                | IniFile.entry /register_(argc_argv|globals|long_arrays)/
+                | IniFile.entry /report_(memleaks|zend_debug)/
+                | IniFile.entry /safe_mode(_(allowed_env_vars|exec_dir|gid|include_dir|protected_env_vars))?/
+                | IniFile.entry /sendmail_(from|path)/
+                | IniFile.entry /upload_(max_filesize|tmp_dir)/
+                | IniFile.entry /user_(agent|dir)/
+                | IniFile.entry /xmlrpc_error(s|_number)/
+		| entry_allowspace "error_reporting"
+
+	let record = IniFile.record "section" setting
+	let lns    = IniFile.lns record
+
+	let filter = (incl "/etc/php*/*/php.ini")
+	           . Util.stdexcl
+
+	let xfm = transform lns filter
+
diff -r a7d566eaab75 -r 86411abff2ee lenses/tests/test_php.aug
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lenses/tests/test_php.aug	Fri Jul 25 13:22:27 2008 +0200
@@ -0,0 +1,120 @@
+module Test_php =
+
+   let conf = "[PHP]
+
+;;;;;;;;;;;;;;;;;;;;
+; Language Options ;
+;;;;;;;;;;;;;;;;;;;;
+
+; Enable the PHP scripting language engine under Apache.
+engine = On
+
+; Enable compatibility mode with Zend Engine 1 (PHP 4.x)
+zend.ze1_compatibility_mode = Off
+
+; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
+; NOTE: Using short tags should be avoided when developing applications or
+; libraries that are meant for redistribution, or deployment on PHP
+; servers which are not under your control, because short tags may not
+; be supported on the target server. For portable, redistributable code,
+; be sure not to use short tags.
+short_open_tag = On
+
+; Allow ASP-style <% %> tags.
+asp_tags = Off
+
+; The number of significant digits displayed in floating point numbers.
+precision    =  12
+
+; Enforce year 2000 compliance (will cause problems with non-compliant browsers)
+y2k_compliance = On
+
+; Output buffering allows you to send header lines (including cookies) even
+; after you send body content, at the price of slowing PHP's output layer a
+; bit.  You can enable output buffering during runtime by calling the output
+; buffering functions.  You can also enable output buffering for all files by
+; setting this directive to On.  If you wish to limit the size of the buffer
+; to a certain size - you can use a maximum number of bytes instead of 'On', as
+; a value for this directive (e.g., output_buffering=4096).
+output_buffering = Off
+; You can redirect all of the output of your scripts to a function.  For
+; example, if you set output_handler to \"mb_output_handler\", character
+; encoding will be transparently converted to the specified encoding.
+; Setting any output handler automatically turns on output buffering.
+; Note: People who wrote portable scripts should not depend on this ini
+;       directive. Instead, explicitly set the output handler using ob_start().
+;       Using this ini directive may cause problems unless you know what script
+;       is doing.
+; Note: You cannot use both \"mb_output_handler\" with \"ob_iconv_handler\"
+;       and you cannot use both \"ob_gzhandler\" and \"zlib.output_compression\".
+; Note: output_handler must be empty if this is set 'On' !!!!
+;       Instead you must use zlib.output_handler.
+;output_handler =
+
+; Transparent output compression using the zlib library
+; Valid values for this option are 'off', 'on', or a specific buffer size
+; to be used for compression (default is 4KB)
+; Note: Resulting chunk size may vary due to nature of compression. PHP
+;       outputs chunks that are few hundreds bytes each as a result of
+;       compression. If you prefer a larger chunk size for better
+;       performance, enable output_buffering in addition.
+; Note: You need to use zlib.output_handler instead of the standard
+;       output_handler, or otherwise the output will be corrupted.
+zlib.output_compression = Off
+;zlib.output_compression_level = -1
+
+; You cannot specify additional output handlers if zlib.output_compression
+; is activated here. This setting does the same as output_handler but in
+; a different order.
+;zlib.output_handler =
+
+; Implicit flush tells PHP to tell the output layer to flush itself
+; automatically after every output block.  This is equivalent to calling the
+; PHP function flush() after each and every call to print() or echo() and each
+; and every HTML block.  Turning this option on has serious performance
+; implications and is generally recommended for debugging purposes only.
+implicit_flush = Off
+
+; The unserialize callback function will be called (with the undefined class'
+; name as parameter), if the unserializer finds an undefined class
+; which should be instantiated.
+; A warning appears if the specified function is not defined, or if the
+; function doesn't include/implement the missing class.
+; So only set this entry, if you really want to implement such a
+; callback-function.
+unserialize_callback_func=
+
+;extension=mysql.so
+;extension=gd.so
+
+;;;;;;;;;;;;;;;;;;;
+; Module Settings ;
+;;;;;;;;;;;;;;;;;;;
+
+[Date]
+; Defines the default timezone used by the date functions
+;date.timezone =
+
+;date.default_latitude = 31.7667
+;date.default_longitude = 35.2333
+
+;date.sunrise_zenith = 90.583333
+;date.sunset_zenith = 90.583333
+
+[filter]
+;filter.default = unsafe_raw
+;filter.default_flags =
+
+[iconv]
+;iconv.input_encoding = ISO-8859-1
+;iconv.internal_encoding = ISO-8859-1
+;iconv.output_encoding = ISO-8859-1
+
+[sqlite]
+;sqlite.assoc_case = 0
+
+
+"
+
+
+   test PHP.lns get conf = ?




More information about the augeas-devel mailing list