Imported Upstream version 0.6.24+dfsg1

This commit is contained in:
Mario Fetka 2017-05-20 15:26:21 +02:00
commit 32a360eca6
705 changed files with 87250 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
autom4te.cache
subst
summary
*Makefile
config.log
config.status
scripts/rc.npcd
scripts/rc.pnp_gearman_worker
scripts/check_pnp_rrds.pl
scripts/process_perfdata.pl
scripts/rrd_modify.pl
src/*.o
src/npcd
include/config.h
*~
sample-config/pnp/config.php
sample-config/pnp/pnp4nagios_release
sample-config/pnp/process_perfdata.cfg-sample
sample-config/pnp/npcd.cfg-sample
sample-config/misccommands.cfg-sample
sample-config/nagios.cfg-sample
share/pnp/application/config/config.php
share/pnp/index.php
share/pnp/install.php
sample-config/httpd.conf
share/pnp/application/logs/*
contrib/ssi/status-header.ssi
helpers/w2h.pl
scripts/verify_pnp_config.pl
sample-config/lighttpd.pnp4nagios.conf
sample-config/nginx.pnp4nagios.conf
share/pnp/media/js/basket.js
scripts/rrd_convert.pl
scripts/rrd_converter.pl
man/npcd.8

3
AUTHORS Normal file
View File

@ -0,0 +1,3 @@
Authors:
Jörg Linge pitchfork@pnp4nagios.org
Hendrik Bäcker andurin@process-zero.de

340
COPYING Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

185
ChangeLog Normal file
View File

@ -0,0 +1,185 @@
**pnp-0.6.?? ??/??/2013**
**pnp-0.6.24 07/30/2013**
* Bugfix: Fixed some more XSS issues
* Bugfix: Fixed PHP issue while running on PHP 5.6 ( Reported by Sven Nierlein )
**pnp-0.6.22 06/04/2014**
* Bugfix: Fixed livestatus socket parsing ( Pekka Panula )
* Bugfix: Update check_mssql_health.php ( Miriam Zenk )
* Feature: Add "version=tiny" to got get a stripped down version of graph ( Ricardo Bartels )
* feature: Add STDIN Mode to process_perfdata.pl ( Robert Steininger )
* Bugfix: XSS issue fixed by Mikael Falkvidd. This issue was detected by Peter Österberg at Hexbit AB in a security assessment of op5 Monitor 6.3 on assignment by op5 AB.
**pnp-0.6.21 03/24/2013**
* Feature: Helper functions rrd::alerter and rrd:alerter_gr both supports treshold detection (Martin Schirrmacher)
* Update: jQuery Mobile update to 1.3.0 ( was broken in 0.6.20 )
**pnp-0.6.20 03/03/2013**
* Feature: Support check_mk Multisite Cookie Auth ( Lars Michelsen )
* Feature: Allow RRD unknown values ( Simon Meggle )
* feature: Interactive delete mode added to check_rrds.pl ( Simon Meggle )
* Bugfix: Allow multiple gearman servers ( Craig Barraclough )
* Bugfix: Fixed Graph Search ( Stefan Triep )
* Update: jQuery update to 1.8.1
* Update: jQueryUI update to 1.8.23
**pnp-0.6.19 09/01/2012**
* Feature: Parameter "width" added to popup controller ( Andreas Doehler )
* Fix: simplify/improve apache rules ( Christoph Anton Mitterer )
* Fix: Check for missing PHP GD functions
* Bugfix: socketDOMAIN changed to AF_INET while using livstatus tcp socket ( Rene Koch )
**pnp-0.6.18 06/28/2012**
* Bugfix: Fixed STORAGE_TYPE and CUSTOM_TEMPLATE vars used in custom templates
* Bugfix: Blank screen on PHP 5.4 fixed
* Feature: Allow multiple gearman job servers
* Feature: New helper function rrd::debug()
* Feature: New templates check_jmx4perl_*.php
**pnp-0.6.17 03/25/2012**
* Bugfix: Fixed rrd_convert.pl while running with --dry-run
* Bugfix: logging.c include missing header files ( Lars Vogdt )
* Bugfix: Check if pnp4nagios/etc/rra.cfg is readable
* Bugfix: rrd_convert.pl use XML tag TEMPLATE instead of CHECKCOMMAND to selects RRDs ( Sven Velt )
* Feature: npcdmod.o increase perfdata buffer and log discarded perfdata ( Birger Schmidt )
* Feature: rrd_modify.pl to change number of data sources of an RRD file
* Feature: New template check_apachestatus_auto.php
* Feature: Implement etc/config.d to place config snippets ( Lars Michelsen )
**pnp-0.6.16 11/21/2011**
* Bugfix: Fixed single quoted check_multi labels (Reported by Matthias Flacke)
* Bugfix: Append missing slash to perfdata_spool_dir ( Reported by Juergen-Michael Radtke )
* Bugfix: Fixed jQuery-ui multisite theme
* Feature: PDF margins are now adjustable via config.php ( Thomas Witzenrath )
* Feature: Support for PDF size 'letter' added ( Robert Becht )
**pnp-0.6.15 09/15/2011**
* Bugfix: Fixed Overview link (reported by Stefan Triep)
* Bugfix: Fixed zoom popup (reported by Rudolf Labuschagne)
* Bugfix: Fixed double urlencode() (reported by Mathias Kettner)
* Feature: "Clear basket" button added (suggested by Stefan Triep)
* Feature: New helper function "rrd::alerter_gr()" ( committed by Stefan Trip )
**pnp-0.6.14 08/05/2011**
* Feature: Webinterface for mobile devices based on jQuery Mobile \\ ( http://jquerymobile.com/ )
* Feature: Zoom based on jQuery plugin imgAreaSelect \\ ( http://odyniec.net/projects/imgareaselect/ )
* Feature: New template check_mssql_health.php
* Bugfix: Fixed popups to work under nginx ( Joram Agten )
* Bugfix: Helper rrd::vdef() fixed
* Update: jQuery update to 1.6.2
* Update: jQuery-ui update to 1.8.14
**pnp-0.6.13 05/19/2011**
* Feature: New option --ignore-hosts added to check_pnp_rrds.pl ( by Jochen Bern )
* Feature: New options zgraph_width and zgraph_height in config.php ( Mike Liebsch )
* Bugfix: rrd_convert.pl: parse_xml_filename() regex fix
* Info: Version used by OMD-0.48 [[http://omdistro.org|OMD]]
**pnp-0.6.12 04/22/2011**
* Feature: mod_gearman support added
* Feature: rrd_convert.pl is now able to convert all RRDs from RRD_STORAGE_TYPE=SINGLE to RRD_STORAGE_TYPE=MULTIPLE
* Feature: New template check_gearman.php
* Feature: Install process_perfdata.cfg and npcd.cfg by default
* Bugfix: rrd_convert.pl is now able to parse xml dumps created by rrdtool 1.4.x
* Bugfix: process_perfdata.pl default timeout value set to 15 seconds
**pnp-0.6.11 01/15/2011**
* Bugfix: urldecoding fixed
* Bugfix: Zoom in/out is working again ( Reported by Thorben Soehl )
* Featue: npcd.cfg - New option perfdata_file_processing_interval used by npcdmod
* Info: Version used by OMD-0.46 [[http://omdistro.org|OMD]]
**pnp-0.6.10 12/15/2010**
* Feature: Add RRDTool Option --only-graph if graph height is below 32px to create thumbnails
* Feature: RRDTool Option --width and --height is now allowed in templates
* Feature: RRDTool DS Type for UOM of "c" changed from COUNTER to DERIVE
* Feature: Pass query string from special controller to image controller ( Matthew Garrett )
* Feature: Authorisation against [[http://mathias-kettner.de/checkmk_livestatus.html|mk_livestatus]] API added
* Feature: Sample nginx webserver config added ( by evax@users.sourceforge.net )
* Feature: Kohana backport to support PHP 5.1.6 ( Kudos to Andreas Ericsson )
* Bugfix: Sort list of special templates
* Bugfix: Urlencode hostname and service description ( Reported by Yannick )
* Bugfix: corrected warning/critical thresholds in ticker/alerter functions
**pnp-0.6.7 09/27/2010**
* Bugfix: Page config parser fix (Beau Gunderson)
* Bugfix: Zoom window size fixed (Report by Rudolf Labuschagne)
* Bugfix: Fixed undefined offset while using 'ds_name' in templates (Reported by Vladimir Bilik)
* Bugfix: Npcdmod respects process_perf_data option used in hosts and services definitions ( Reported by Wolfgang Barth )
* Template: New Template check_nagiostats.php used with check_nagiostats written by Jochen Bern
**pnp-0.6.6 08/07/2010**
* Bugfix: Fixed max amount of graphs per template
* Bugfix: Autodetect PNP base URL
* Bugfix: Too short npcdmod perfdata_template to take perfdata + overhead, increased +1024byte
* Bugfix: Ignore files in var/perfdata and check for empty directories
* Bugfix: Reducing memory usage while parsing page config (Laurent Freval)
**pnp-0.6.5 07/09/2010**
* Feature: Special Templates are back [[tpl_special]]
* Feature: New rrdtool helper functions makes template design easier [[tpl_helper]]
* Feature: config.php -> 'recursive_template_search' is enabled by default
* Feature: config.php -> 'template_dirs' is now an array of directorys to search for PNP templates
**pnp-0.6.4 06/03/2010**
* Update: jQuery Update to 1.4.2
* Update: jQuery-ui Update to 1.8
* Feature: New configure Option --with-base-url
* Template: New template check_ntp_time.php (Mathias Kettner)
* Feature: New i18n files for fr_FR (Yannig Parre)
* Feature: New jQuery Theme 'multisite'
**pnp-0.6.3 03/16/2010**
* Feature: New helper script libexec/rrd_convert.pl -> [[rrd_convert]]
* Bugfix: Ignore old XML files while building the service list
* Template: New template check_hpasm.php
* Bugfix: Installer now checks for json_decode()
* Workaround: Allow "trailing unfilled semicolons". Workaround for nsclient++
* Template: Updates for check_openmanage.php, check_hp_bladecenter.php and check_dell_baldecenter.php ( Trond Hasle Amundsen )"
**pnp-0.6.2 12/23/2009**
* Feature: XML_WRITE_DELAY option added to process_perfdata.cfg as suggested by Mathias Kettner
* Feature: New template integer.php
* Update: FPDI update to 1.3.1
* Feature: PNP will now work with [[http://http://www.lighttpd.net|lighttpd]] and php-cgi
* Template: check_mk-ps.perf.php added ( by Mathias Kettner )
* Feature: PNP will now work without mod_rewrite -> [[webfe]]
* Bugfix: Wrong pdf link used on site 'pages' and 'basket'
* Bugfix: Incorrect group permissions on spool directory
**pnp-0.6.1 11/22/2009**
* Feature: RRD heartbeat per check_command -> [[tpl_custom]]
* Feature: New config.php option pdf_graph_opt
* Feature: Recognize the 'background_pdf' option in page definitions -> [[pages]]
* Feature: Recognize the 'source' option in page definitions -> [[pages]]
* Feature: Array $TIMERANGE now available for templates -> [[timeranges]]
* Bugfix: ./configure --sysconfdir no longer ignored
* Feature: Store internal runtime statistics on a per minute base
* Feature: Added two widgets views/widget_menu.php and views/widget_graph.php
**pnp-0.6.0 10/30/2009**
* Webfrontend based on [[http://www.kohanaphp.com|Kohana]]
* Webfrontend based on [[http://jqueryui.com/themeroller/|jQuery Themes]]
* Javascript-functions using [[http://jquery.com/|jQuery]] plugins
* process_perfdata.pl will be able to use one RRD database per datasource
* improved installer. Specification of directory layouts using --with-layout
* RRDtool errors are now displayed as images. no more missing images
* PNP templates cannot overwrite internal variables anymore
* PNP templates of version 0.4.x can still be used
* PDF functions recoded
* Template default.php optimized
* Export from RRD databases into XML, CSV and JSON format using the RRDtool "xport" function
* Page functions recoded
* Error pages links to online FAQ
* Mouseover Popup in Nagios frontend via jQuery.clueTip plugin
* Full support of rrdcached

236
INSTALL Normal file
View File

@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

183
Makefile.in Normal file
View File

@ -0,0 +1,183 @@
###############################
# Makefile for PNP
#
# Last Modified: 12-10-2006
###############################
# Source code directories
SRC_BASE=@srcdir@/src
SRC_SHARE=@srcdir@/share
SRC_LIB=@srcdir@/lib
SRC_SCRIPTS=@srcdir@/scripts
SRC_CONFIG=@srcdir@/sample-config
SRC_MAN=@srcdir@/man
SRC_CONTRIB=@srcdir@/contrib
SRC_HELPERS=@srcdir@/helpers
CC=@CC@
CFLAGS=@CFLAGS@ @DEFS@
LDFLAGS=@LDFLAGS@ @LIBS@
prefix=@prefix@
exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
LIBEXECDIR=@libexecdir@
LIBDIR=@libdir@
KOHANA=@KOHANA@
CGIDIR=@sbindir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
DATAROOTDIR=@datarootdir@
CP=@CP@
PERL=@PERL@
none:
@echo "Please supply a command line argument (i.e. 'make all'). Other targets are:"
@echo " clean"
@echo " install install-init install-config install-processperfdata install-html fullinstall"
@echo " install-plugins"
all:
cd $(SRC_BASE) && $(MAKE)
cd $(SRC_SHARE) && $(MAKE)
cd $(SRC_SCRIPTS) && $(MAKE)
chmod a+r $(SRC_CONTRIB)/ssi/status-header.ssi
@echo ""
@echo "*** Compile finished ***"
@echo ""
@echo " make install"
@echo " - This installs the main program and HTML files"
@echo ""
@echo " make fullinstall"
@echo " - This installs the main program, runlevel scripts, config and HTML files"
@echo ""
@echo "Enjoy."
@echo ""
scripts:
cd $(SRC_SCRIPTS) && $(MAKE)
share:
cd $(SRC_SHARE) && $(MAKE)
clean:
cd $(SRC_BASE) && $(MAKE) $@
cd $(SRC_MAN) && $(MAKE) $@
cd $(SRC_SHARE) && $(MAKE) $@
cd $(SRC_LIB) && $(MAKE) $@
cd $(SRC_SCRIPTS) && $(MAKE) $@
cd $(SRC_CONFIG) && $(MAKE) $@
-rm -f *.cfg core
-rm -f *~ *.*~ */*~ */*.*~
-rm -f config.log config.status config.cache
distclean:
cd $(SRC_BASE) && $(MAKE) $@
cd $(SRC_MAN) && $(MAKE) $@
cd $(SRC_SHARE) && $(MAKE) $@
cd $(SRC_LIB) && $(MAKE) $@
cd $(SRC_SCRIPTS) && $(MAKE) $@
cd $(SRC_CONFIG) && $(MAKE) $@
-rm -f *.cfg core
-rm -f *~ *.*~ */*~ */*.*~
-rm -f config.log config.status config.cache
rm -f Makefile include/stamp-h1 include/config.h config.status config.log
rm -f subst summary
rm -f $(SRC_CONTRIB)/ssi/status-header.ssi
devclean: distclean
install-html:
cd $(SRC_SHARE) && $(MAKE) install
install-base:
cd $(SRC_BASE) && $(MAKE) install
install-man:
cd $(SRC_MAN) && $(MAKE) install
install-processperfdata:
cd $(SRC_SCRIPTS) && $(MAKE) install
install-init:
cd $(SRC_SCRIPTS) && $(MAKE) $@
install-config:
cd $(SRC_CONFIG) && $(MAKE) $@
@echo ""
@echo "*** PNP4Nagios sample config files installed ***"
@echo ""
@echo "Please run 'make install-init' if you want to use"
@echo "BULK Mode with NPCD"
@echo ""
@echo ""
@echo ""
install-webconf:
cd $(SRC_CONFIG) && $(MAKE) $@
@echo ""
@echo "*** Apache config file installed ***"
@echo ""
@echo "Restart your apache webserver to activete your changes."
@echo ""
@echo "Please run 'make install-config' to install sample"
@echo "configuration files"
@echo ""
@echo "Please run 'make install-init' if you want to use"
@echo "BULK Mode with NPCD"
@echo ""
@echo ""
@echo ""
install-plugins:
cd $(SRC_SCRIPTS) && $(MAKE) $@
install:
cd $(SRC_BASE) && $(MAKE) $@
cd $(SRC_MAN) && $(MAKE) $@
cd $(SRC_SHARE) && $(MAKE) $@
if [ x$(KOHANA) = xyes ]; then \
cd $(SRC_LIB) && $(MAKE) $@; \
fi
cd $(SRC_SCRIPTS) && $(MAKE) $@
cd $(SRC_CONFIG) && $(MAKE) $@
@echo ""
@echo "*** Main program, Scripts and HTML files installed ***"
@echo ""
@echo "Please run 'make install-webconf' to install the"
@echo "web configuration file"
@echo ""
@echo "Please run 'make install-config' to install sample"
@echo "configuration files"
@echo ""
@echo "Please run 'make install-init' if you want to use"
@echo "BULK Mode with NPCD"
@echo ""
@echo ""
@echo ""
install-unstripped:
cd $(SRC_BASE) && $(MAKE) $@
cd $(SRC_SHARE) && $(MAKE) $@
cd $(SRC_SCRIPTS) && $(MAKE) $@
$(MAKE) install-basic
fullinstall: install install-webconf install-config install-init
$(PERL) summary fullinstall
@echo ""
@echo "*** Main program, Scripts and HTML files installed ***"
@echo ""
@echo "Enjoy."
@echo ""

10
README Normal file
View File

@ -0,0 +1,10 @@
#########################
# #
# README #
# #
#########################
See our online documentation at:
http://pnp4nagios.sourceforge.net or:
http://docs.pnp4nagios.org/

85
THANKS Normal file
View File

@ -0,0 +1,85 @@
###########################################
# PNP Thanks #
###########################################
Olivier PLATHEY - For providing FPDF
Sven Nierlein - For providing mod_gearman
Michal Wojciechowski - For providing imgAreaSelect
Hendrik Baecker - Testing, debugging and english Translation
Olaf Reiss - Testing
Andreas Koch - Testing
Christian Mies - check_nwstat Templates, Testing
Sebastian Schubert - Internal Design
Stephan von Gehlen - Testing and Feedback
Geoffrey Walton - Feedback and Translation
Frank J. Heym - process_perfdata.pl Patch for check_nrpe Templates
Rudolf Labuschagne - Testing PNP in distributed setups
Sven Velt - Multigraph Layout
Sonja Scholz - Documentation
Andrea Gabellini -
Matthias Flittener - Bugreport
Ton Kersten - Dutch Language
Matthias Flacke - check_multi development, npcd load patch
Markus Dorfer -
Christian Claus - Debugging 64bit Counter
Herbert Straub
Wolfgang Nieder - English translation, verify-script, nitpicking
Max Schubert -
Wolfgang Barth -
Ethan Galstad - Patches and Feedback
Jan Dreyer - Solaris debugging
Jean-Marie Le Borgne - French Translation
Steffen Waitz - ./configure Patch
Lars Michelsen -
Philipp Deneu -
Thomas Stolle - Debugging and testing
Benjamin Ritcey - Patches
Franky Van Liedekerke - Testing
Simon Meggle - Testing / Patches
Mattias Ryrlén - Patches
Nicolas Graziano - Patches
Joe Precious - Testing
Stefan Priebe - Patches
Carlos de Nova - i18n
Stefan Hoesl - Testing
Trond Hasle Amundsen - Template check_openmanage
Silvan Hunkirchen - Bugreport
Petr Maizner - Bugreport
Steve Finkelstein - Bugreport
Mathias Kettner - xml write delay
Yannig Parre - i18n fr_FR
Laurent Freval - Patches and feedback
Beau Gunderson - Patches and feedback
Thomas Sesselmann - Patches and feedback
Vladimir Bilik - Feedback
Matthew Garrett -
Thomas Charbonnel - nginx webserver config
Richard Allen - Patches and feedback
Falko Koglin - Patches
Jochen Bern - Patches
Mike Liebsch - Patches
Joram Agten - Patches
Juergen-Michael Radtke - Bugreport
Robert Becht - Feedback
Lars Vogdt - Patches
Birger Schmidt - Patches
Andreas Doehler - Patches
Christoph Anton Mitterer - Patches and feedback
Rene Koch - Patches
Craig Barraclough - Patches
Martin Schirrmacher - Patches
Pekka Panula - Bugreport
Dennis Lamers - Bugreport and Patches
Robert Steininger - Patches
Ricardo Bartels - Patches
Miriam Zenk - Patches
###########################################
# NPCD Thanks #
###########################################
Joerg Linge - for giving so much ideas what I have to do ;)
Ethan Galstad - for many useful code to learn from
Carsten Schlosser - for all the time I can disturb him to ask silly pointer questions
My Girlfriend Katrin (without 'h') - for spending so much time without me

1526
config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

1658
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

7104
configure vendored Executable file

File diff suppressed because it is too large Load Diff

313
configure.ac Normal file
View File

@ -0,0 +1,313 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(pnp, 0.6.24, pnp4nagios-devel@lists.sourceforge.net)
AC_CONFIG_SRCDIR(src/)
AC_CONFIG_HEADERS(include/config.h:include/config.h.in)
AC_PREFIX_DEFAULT(/usr/local/pnp4nagios)
AC_DEFINE([DEFAULT_NAGIOS_USER], [nagios], [Default Nagios User])
AC_DEFINE([DEFAULT_NAGIOS_GROUP], [nagios], [Default Nagios Group])
PKG_NAME=pnp4nagios
PKG_VERSION="0.6.24"
PKG_HOME_URL="http://www.pnp4nagios.org/pnp/start"
PKG_REL_DATE="30-07-2014"
AC_SUBST(PKG_NAME)
AC_SUBST(PKG_VERSION)
AC_SUBST(PKG_HOME_URL)
AC_SUBST(PKG_REL_DATE)
AC_SUBST(ac_configure_args)
XML_STRUCTURE_VERSION="4"
AC_SUBST(XML_STRUCTURE_VERSION)
dnl Figure out how to invoke "install" and what install options to use.
AC_PROG_INSTALL
AC_SUBST(INSTALL)
#dnl What OS are we running?
AC_CANONICAL_HOST
dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PATH_PROG([STRIP],[strip],[true])
AC_PATH_PROG(CP,cp)
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
#AC_CHECK_HEADERS(netinet/in.h string.h sys/socket.h unistd.h stdio.h stdlib.h getopt.h signal.h)
AC_CHECK_HEADERS(dirent.h stdio.h errno.h unistd.h syslog.h signal.h stdlib.h dirent.h string.h pthread.h getopt.h grp.h pwd.h sys/mman.h sys/types.h sys/wait.h sys/stat.h sys/socket.h sys/loadavg.h netinet/in.h fcntl.h limits.h)
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_UID_T
# Checks for structure members
#AC_CHECK_MEMBER([struct dirent.d_type], [AC_MSG_RESULT([We successfully have a `dirent_d_type'!])],
# [AC_MSG_ERROR([We need `dirent.d_type'!])],
# [#include <dirent.h>])
AC_STRUCT_DIRENT_D_TYPE
# Checks for library functions.
AC_FUNC_FORK
AC_CHECK_FUNCS([bzero socket alarm strerror strspn getloadavg])
AC_FUNC_MALLOC
AC_FUNC_STAT
AC_C_CONST
dnl Layout Methods
layout="default"
AC_ARG_WITH(layout,[ --with-layout=\[default,debian\] sets directory layout],layout=$withval)
case $layout in
debian)
prefix="/"
sysconfdir="/etc/${PKG_NAME}"
localstatedir="/var/log/${PKG_NAME}"
libexecdir="/usr/lib/${PKG_NAME}/libexec"
libdir="/usr/lib/${PKG_NAME}"
datarootdir="/usr/share/${PKG_NAME}/html"
PERFDATA_LOG="/var/log/${PKG_NAME}/perfdata.log"
PERFDATA_DIR="/var/lib/${PKG_NAME}/perfdata"
PERFDATA_SPOOL_DIR="/var/spool/${PKG_NAME}"
bindir="/usr/bin"
sbindir="/usr/sbin"
;;
default-0.4)
prefix="/usr/local/nagios"
sysconfdir="\${prefix}/etc/pnp"
localstatedir="\${prefix}/var"
libexecdir="\${prefix}/libexec"
datarootdir="\${prefix}/share/pnp"
libdir="\${prefix}/lib/pnp"
PERFDATA_LOG="\${prefix}/var/perfdata.log"
PERFDATA_DIR="\${prefix}/share/perfdata"
PERFDATA_SPOOL_DIR="\${prefix}/var/spool/perfdata"
;;
default)
PERFDATA_LOG="${localstatedir}/perfdata.log"
PERFDATA_DIR="${localstatedir}/perfdata"
PERFDATA_SPOOL_DIR="${localstatedir}/spool"
mandir="\${prefix}/man"
;;
esac
AC_ARG_WITH(kohana,[ --without-kohana does not install the kohana framework],KOHANA=no,KOHANA=yes)
AC_SUBST(KOHANA)
AC_ARG_WITH(kohana_system,[ --with-kohana_system=<existing kohana system dir> Points to an already installed kohana framework],KOHANA_SYSTEM=$withval,KOHANA_SYSTEM=$libdir/kohana/system)
AC_SUBST(KOHANA_SYSTEM)
AC_ARG_WITH(nagios_user,[ --with-nagios-user=<user> sets user name to run nagios],nagios_user=$withval,nagios_user=nagios)
AC_ARG_WITH(nagios_group,[ --with-nagios-group=<grp> sets group name to run nagios],nagios_grp=$withval,nagios_grp=nagios)
AC_SUBST(nagios_user)
AC_SUBST(nagios_grp)
AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_USER,"$nagios_user")
AC_DEFINE_UNQUOTED(DEFAULT_NAGIOS_GROUP,"$nagios_grp")
INSTALL_OPTS="-o $nagios_user -g $nagios_grp"
AC_SUBST(INSTALL_OPTS)
# Checks for programs.
AC_PATH_PROG(PERL,perl)
# Check for Perl lib path
PERL_LIB_PATH=no
AC_ARG_WITH(perl_lib_path,[ --with-perl_lib_path=<path_to_perl_libs> sets path to rrdtool RRDs perl modules.],PERL_LIB_PATH=$withval,PERL_LIB_PATH=no)
AC_SUBST(PERL_LIB_PATH)
# Check for rrdtool
RRDTOOL=no
AC_ARG_WITH(rrdtool,[ --with-rrdtool=<path_to_rrdtool> sets path to rrdtool],RRDTOOL=$withval,RRDTOOL=no)
if test RRDTOOL=no; then
AC_PATH_PROG(RRDTOOL,rrdtool)
fi
AC_MSG_CHECKING(rrdtool path $RRDTOOL)
if [ test -d $RRDTOOL ];then
AC_MSG_RESULT(no)
AC_MSG_ERROR([$RRDTOOL is a directory! PNP needs the Path to the rrdtool binary!])
fi
AC_MSG_RESULT(yes)
AC_MSG_CHECKING(for executable Bit on $RRDTOOL)
if [ ! test -x $RRDTOOL] ;then
AC_MSG_RESULT(no)
AC_MSG_ERROR([$RRDTOOL is not executable!])
fi
AC_MSG_RESULT(yes)
AC_SUBST(RRDTOOL)
AC_ARG_WITH(perfdata-logfile,[ --with-perfdata-logfile=<perfdata_logfile> Tell me where I should store the 'process_perfdata.pl' Logfile],
PERFDATA_LOG=$withval
)
AC_SUBST(PERFDATA_LOG)
AC_ARG_WITH(perfdata-dir,[ --with-perfdata-dir=<path_to_perfdata> Tell me where I should store the RRD Database Files],
PERFDATA_DIR=$withval
)
AC_SUBST(PERFDATA_DIR)
AC_ARG_WITH(perfdata-spool-dir,[ --with-perfdata-spool-dir=<path_to_perfdata_spool_dir> Tell me where I should store perfdata files for bulk mode with npcd],
PERFDATA_SPOOL_DIR=$withval
)
AC_SUBST(PERFDATA_SPOOL_DIR)
AC_ARG_WITH(debug,[ --with-debug Enable debuging for process_perfdata.pl],
DEBUG="2",
DEBUG="0"
)
AC_SUBST(DEBUG)
dnl Check for location of Apache conf.d directory
HTTP_CONF=no
AC_ARG_WITH(httpd_conf,[ --with-httpd-conf=<path_to_conf> sets path to Apache conf.d directory],HTTPD_CONF=$withval,HTTPD_CONF=no)
if test x$HTTPD_CONF = xno; then
if test -d /etc/httpd/conf.d; then
HTTPD_CONF="/etc/httpd/conf.d"
elif test -d /etc/apache2/conf.d; then
HTTPD_CONF="/etc/apache2/conf.d"
elif test -d /etc/apache/conf.d; then
HTTPD_CONF="/etc/apache/conf.d"
else
HTTPD_CONF="/etc/httpd/conf.d"
fi
fi
AC_SUBST(HTTPD_CONF)
dnl Check for location of init scripts
init_dir=/etc/rc.d/init.d
if test -d /etc/rc.d/init.d; then
init_dir="/etc/rc.d/init.d"
elif test -d /usr/local/etc/rc.d; then
init_dir="/usr/local/etc/rc.d"
elif test -d /etc/rc.d; then
init_dir="/etc/rc.d"
elif test -d /etc/init.d; then
init_dir="/etc/init.d"
elif test -d /sbin/init.d; then
init_dir="/sbin/init.d"
fi
BASE_URL=${PKG_NAME}
AC_ARG_WITH(base-url,[ --with-base-url=/${PKG_NAME} ],BASE_URL=$withval,BASE_URL=/${PKG_NAME})
AC_SUBST(BASE_URL)
dnl User can override init script location
AC_ARG_WITH(init_dir,[ --with-init-dir=<path> sets directory to place init script into],init_dir=$withval)
AC_SUBST(init_dir)
pnpsender_name=pnpsender
AC_SUBST(pnpsender_name)
npcd_name=npcd
AC_SUBST(npcd_name)
pp_pl_name=process_perfdata.pl
AC_SUBST(pp_pl_name)
dnl - Modified version from www.erlang.org
dnl - Some 12/15/05 mods made after reading http://xaxxon.slackworks.com/phuku/dl.html
AC_MSG_CHECKING(for linker flags for loadable modules)
case $host_os in
solaris2*|sysv4*)
MOD_LDFLAGS="-G"
;;
aix4*|aix5*|aix6*|aix7*)
#MOD_LDFLAGS="-G -bnoentry -bexpall"
MOD_LDFLAGS="-shared -Wl,-G -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bexpall"
;;
freebsd2*)
# Non-ELF GNU linker
MOD_LDFLAGS="-Bshareable"
;;
darwin*)
# Mach-O linker, a shared lib and a loadable
# object file is not the same thing.
MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress"
MOD_CFLAGS="$MOD_CFLAGS -fno-common"
;;
linux* | k*bsd*-gnu*)
# assume GNU linker and ELF
MOD_LDFLAGS="-shared"
MOD_CFLAGS="-fPIC"
;;
*)
# assume GNU linker and ELF
MOD_LDFLAGS="-shared"
;;
esac
AC_MSG_RESULT([$MOD_LDFLAGS])
AC_SUBST(MOD_CFLAGS)
AC_SUBST(MOD_LDFLAGS)
#
# Checking for Perl Modules
#
AC_MSG_CHECKING(for Perl Module Time::HiRes)
$PERL -MTime::HiRes -e exit >/dev/null 2>&1
if test $? -ne 0; then
AC_MSG_RESULT(no)
AC_MSG_ERROR(Perl Module Time::HiRes not available)
else
AC_MSG_RESULT(yes)
fi
AC_MSG_CHECKING(for Perl Module Getopt::Long)
$PERL -MGetopt::Long -e exit >/dev/null 2>&1
if test $? -ne 0; then
AC_MSG_RESULT(no)
AC_MSG_ERROR(Perl Module Getopt::Long not available)
else
AC_MSG_RESULT(yes)
fi
RRDS=0
AC_MSG_CHECKING(for optional Perl Module RRDs)
$PERL -I${PERL_LIB_PATH} -MRRDs -e exit >/dev/null 2>&1
if test $? -ne 0; then
AC_MSG_RESULT(no)
AC_MSG_WARN(Perl Module RRDs not available)
RRDS=0
else
AC_MSG_RESULT(yes)
RRDS=1
fi
AC_SUBST(RRDS)
AC_CONFIG_FILES( subst Makefile share/Makefile lib/Makefile scripts/Makefile src/Makefile sample-config/Makefile man/Makefile )
AC_OUTPUT()
$PERL subst summary
$PERL subst scripts/process_perfdata.pl
$PERL subst scripts/rrd_convert.pl
$PERL subst scripts/rrd_modify.pl
$PERL subst scripts/rc.npcd
$PERL subst scripts/rc.pnp_gearman_worker
$PERL subst scripts/check_pnp_rrds.pl
$PERL subst share/pnp/index.php
$PERL subst share/pnp/install.php
$PERL subst sample-config/httpd.conf
$PERL subst sample-config/lighttpd.pnp4nagios.conf
$PERL subst sample-config/nginx.pnp4nagios.conf
$PERL subst sample-config/nagios.cfg-sample
$PERL subst sample-config/misccommands.cfg-sample
$PERL subst sample-config/pnp/config.php
$PERL subst sample-config/pnp/npcd.cfg-sample
$PERL subst sample-config/pnp/process_perfdata.cfg-sample
$PERL subst sample-config/pnp/pnp4nagios_release
$PERL subst contrib/ssi/status-header.ssi
$PERL subst man/npcd.8
$PERL summary

View File

@ -0,0 +1,62 @@
Name: pnp4nagios
Version: 0.6.7
Release: 1
License: GNU Public License version 2
Packager: Olivier Raginel <babar@cern.ch>
Vendor: PNP4nagios team
URL: http://pnp4nagios.org
Prefix: /opt/pnp4nagios
Source: http://github.com/Babar/pnp4nagios/tarball/%{name}-%{version}.tar.gz
Group: Applications/Monitoring
Requires: perl(Gearman::Worker), perl(Crypt::Rijndael)
BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
Summary: Gearman version of pnp4nagios
Provides: pnp4nagios
%description
From the web page (http://docs.pnp4nagios.org/pnp-0.6/start):
PNP is an addon to Nagios which analyzes performance data provided by plugins
and stores them automatically into RRD-databases (Round Robin Databases, see
RRD Tool).
This is the version with support for Gearman, suitable to use with mod_gearman.
%prep
%setup -q
%build
./configure --with-nagios-user=nagios \
--with-nagios-group=nagios \
--prefix=%{_prefix} \
--libdir=%{_libdir}/%{name} \
--sysconfdir=%{_sysconfdir}/%{name} \
--localstatedir=%{_localstatedir} \
--with-init-dir=%{_initrddir} \
--with-layout=debian
%{__make} all
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_prefix}
%{__make} install fullinstall DESTDIR=$RPM_BUILD_ROOT INIT_OPTS= INSTALL_OPTS=
%clean
rm -rf $RPM_BUILD_ROOT
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
%defattr(-,root,root)
%docdir %{_defaultdocdir}
%{_prefix}
%{_sysconfdir}
%defattr(-,nagios,root)
%{_localstatedir}
%changelog
* Wed Oct 21 2010 Olivier Raginel <babar@cern.ch>
- First build

128
contrib/pnp4nagios.spec Normal file
View File

@ -0,0 +1,128 @@
# $Id:$
# Upstream: pnp4nagios-devel@lists.sourceforge.net
Name: pnp4nagios
Version: 0.6.16
Release: 1
Summary: PNP is not PerfParse. A Nagios/Icinga perfdata graphing solution
Group: Applications/System
License: GPLv2
URL: http://www.pnp4nagios.org/
Source: http://downloads.sourceforge.net/pnp4nagios/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: rrdtool-devel
BuildRequires: perl-rrdtool
Requires: rrdtool
Requires: perl-rrdtool
Obsoletes: pnp
%description
PNP is an addon to Nagios/Icinga which analyzes performance data provided by plugins and stores them automatically into RRD-databases.
%prep
%setup
%build
sed -i -e 's/INSTALL_OPTS="-o $nagios_user -g $nagios_grp"/INSTALL_OPTS=""/' configure
sed -i -e 's/INIT_OPTS=-o root -g root/INIT_OPTS=/' scripts/Makefile.in
# hardcode that until a proper fix is upstream
sed -i -e 's/MANDIR=@mandir@/MANDIR=\/usr\/share\/man/' man/Makefile.in
%configure --with-perfdata-logfile=%{_localstatedir}/log/nagios/perfdata.log \
--sysconfdir=%{_sysconfdir}/%{name} \
--datarootdir=%{_datadir}/%{name} \
--with-perfdata-dir=%{_datadir}/%{name}/perfdata \
--with-perfdata-spool-dir=%{_localstatedir}/spool/nagios \
--mandir=%{_mandir} \
--libdir=%{_libdir}/%{name} # only kohana is installed there and maybe we have a system wide kohana already
make %{?_smp_mflags} all
%install
rm -rf %{buildroot}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/httpd/conf.d/
make fullinstall DESTDIR=%{buildroot}
mv %{buildroot}%{_sysconfdir}/%{name}/check_commands/check_nwstat.cfg-sample %{buildroot}%{_sysconfdir}/%{name}/check_commands/check_nwstat.cfg
mv %{buildroot}%{_sysconfdir}/%{name}/pages/web_traffic.cfg-sample %{buildroot}%{_sysconfdir}/%{name}/pages/web_traffic.cfg
mv %{buildroot}%{_sysconfdir}/%{name}/rra.cfg-sample %{buildroot}%{_sysconfdir}/%{name}/rra.cfg
sed -i -e 's*log_file = /var/npcd.log*log_file = /var/log/nagios/npcd.log*' %{buildroot}%{_sysconfdir}/%{name}/npcd.cfg
# drop local versioning, we already provide our own upgrade safety
rm -f %{buildroot}%{_sysconfdir}/%{name}/config.php.%{version}
rm -f %{buildroot}%{_sysconfdir}/%{name}/config_local.php
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,nagios,nagios,-)
%doc AUTHORS
%doc ChangeLog
%doc COPYING
%doc INSTALL
%doc README
%doc THANKS
%config(noreplace) %{_sysconfdir}/%{name}/check_commands/check_all_local_disks.cfg-sample
%config(noreplace) %{_sysconfdir}/%{name}/check_commands/check_nrpe.cfg-sample
%config(noreplace) %{_sysconfdir}/%{name}/check_commands/check_nwstat.cfg
%config(noreplace) %{_sysconfdir}/%{name}/npcd.cfg
%config(noreplace) %{_sysconfdir}/%{name}/pages/web_traffic.cfg
%config(noreplace) %{_sysconfdir}/%{name}/process_perfdata.cfg
%config(noreplace) %{_sysconfdir}/%{name}/rra.cfg
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%{_sysconfdir}/%{name}/background.pdf
%{_sysconfdir}/%{name}/config.php
%{_sysconfdir}/%{name}/misccommands.cfg-sample
%{_sysconfdir}/%{name}/nagios.cfg-sample
%{_sysconfdir}/%{name}/pnp4nagios_release
%attr(755,root,root) %{_sysconfdir}/rc.d/init.d/npcd
%attr(755,root,root) %{_sysconfdir}/rc.d/init.d/pnp_gearman_worker
%{_bindir}/npcd
%{_libdir}/pnp4nagios/npcdmod.o
%{_libdir}/%{name}
%{_libexecdir}/check_pnp_rrds.pl
%{_libexecdir}/process_perfdata.pl
%{_libexecdir}/rrd_convert.pl
%{_datadir}/%{name}
%{_mandir}/man8/npcd.8.gz
%changelog
* Mon Feb 06 2012 Michael Friedrich <michael.friedrich@univie.ac.at> - 0.6.16-1
- Updated to version 0.6.16.
- drop (Build)Requires nagios, we can use other core(s) as well
- verify_pnp_config.pl => verify_pnp_config_v2.pl not installed anymore
- npcd.cfg and process_perfdata.cfg get now installed by make install w/o -sample suffix
- recognize new initscript for pnp_gearman_worker
- autoremove versionized config.php, we use config(noreplace)
- drop config_local.php which would override default settings
- fix npcd.8 man page prefix install
* Tue Feb 15 2011 Christoph Maser <cmr@financial.com> - 0.6.11-1
- Updated to version 0.6.11.
* Tue Aug 31 2010 Christoph Maser <cmr@financial.com> - 0.6.6-1
- Updated to version 0.6.6.
* Thu Dec 24 2009 Christoph Maser <cmr@financial.com> - 0.6.2 - 2
- add --with-perfdata-spool-dir and --with-perfdata--dir
- mark httpd-config snippet as config file
* Thu Dec 24 2009 Christoph Maser <cmr@financial.com> - 0.6.2 - 1
- Update to version 0.6.2
- Rename to pnp4nagios
* Mon Mar 23 2009 Christoph Maser <cmr@financial.com> - 0.4.14 - 2
- Update to version 0.4.14
* Mon Mar 23 2009 Christoph Maser <cmr@financial.com> - 0.4.13 - 2
- modify log path
- add documentation files
* Mon Mar 23 2009 Christoph Maser <cmr@financial.com> - 0.4.13 - 1
- Initial package (using brain ;)

View File

@ -0,0 +1,9 @@
<script src="@BASE_URL@/media/js/jquery-min.js" type="text/javascript"></script>
<script src="@BASE_URL@/media/js/jquery.cluetip.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('a.tips').cluetip({ajaxCache: false, dropShadow: false,showTitle: false });
});
</script>

16
helpers/kohana-install.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
#
# PNP4Nagios Helper Script
#
DIR=`dirname $0`
cd $DIR/../lib/kohana
for D in `find . -type d -printf "%P\n"`;do
if [ "$D" != "" ];then
echo -e "\t\$(INSTALL) -m 755 \$(INSTALL_OPTS) -d \$(DESTDIR)\$(LIBDIR)/kohana/$D"
fi
done
for F in `find . -type f -printf "%P\n"`;do
if [ "$F" != "" ];then
echo -e "\t\$(INSTALL) -m 644 \$(INSTALL_OPTS) kohana/$F \$(DESTDIR)\$(LIBDIR)/kohana/$F"
fi
done

42
helpers/wiki2html.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
#set -xv
LANG="de en"
LANG_TARGET=(de_DE en_US)
FILES=( about advanced config doc_complete dwnld install modes new-features npcd pages perfdata_format rrdcached rrd_convert start timeranges tpl_helper tpl_helper_pnp tpl_custom tpl upgrade verify verify_pnp_config webfe_cfg webfe wrapper xport mobile )
DESTDIR="../share/pnp/documents"
URL="http://docs.pnp4nagios.org"
cd $DESTDIR
lindex=0
for L in $LANG; do
if [ "$L" == "en" ];then
PART="pnp-0.6"
else
PART="$L/pnp-0.6"
fi
T=${LANG_TARGET[$lindex]}
mkdir $T
index=0
documents=${#FILES[@]}
while [ "$index" -lt "$documents" ];do
F=${FILES[$index]}
echo "$L $F"
wget -nv -O "${T}/${F}.html" "${URL}/${PART}/${F}?do=export_xhtmlbody"
sed -i -e's/ü/\&uuml;/g' "${T}/${F}.html"
sed -i -e's/Ü/\&Uuml;/g' "${T}/${F}.html"
sed -i -e's/ä/\&auml;/g' "${T}/${F}.html"
sed -i -e's/Ä/\&Auml;/g' "${T}/${F}.html"
sed -i -e's/ö/\&ouml;/g' "${T}/${F}.html"
sed -i -e's/Ö/\&Ouml;/g' "${T}/${F}.html"
((index++))
done
((lindex++))
done
rm de_DE/dwnld.html
ln -s en_US/dwnld.html de_DE/dwnld.html

222
include/broker.h Normal file
View File

@ -0,0 +1,222 @@
/*****************************************************************************
*
* BROKER.H - Event broker includes for Nagios
*
* Copyright (c) 2002-2006 Ethan Galstad (nagios@nagios.org)
* Last Modified: 12-12-2006
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef _BROKER_H
#define _BROKER_H
#include "config.h"
#include "nagios.h"
#ifdef __cplusplus
extern "C" {
#endif
/*************** EVENT BROKER OPTIONS *****************/
#define BROKER_NOTHING 0
#define BROKER_EVERYTHING 1048575
#define BROKER_PROGRAM_STATE 1 /* DONE */
#define BROKER_TIMED_EVENTS 2 /* DONE */
#define BROKER_SERVICE_CHECKS 4 /* DONE */
#define BROKER_HOST_CHECKS 8 /* DONE */
#define BROKER_EVENT_HANDLERS 16 /* DONE */
#define BROKER_LOGGED_DATA 32 /* DONE */
#define BROKER_NOTIFICATIONS 64 /* DONE */
#define BROKER_FLAPPING_DATA 128 /* DONE */
#define BROKER_COMMENT_DATA 256 /* DONE */
#define BROKER_DOWNTIME_DATA 512 /* DONE */
#define BROKER_SYSTEM_COMMANDS 1024 /* DONE */
#define BROKER_OCP_DATA 2048 /* DONE */
#define BROKER_STATUS_DATA 4096 /* DONE */
#define BROKER_ADAPTIVE_DATA 8192 /* DONE */
#define BROKER_EXTERNALCOMMAND_DATA 16384 /* DONE */
#define BROKER_RETENTION_DATA 32768 /* DONE */
#define BROKER_ACKNOWLEDGEMENT_DATA 65536
#define BROKER_STATECHANGE_DATA 131072
#define BROKER_RESERVED18 262144
#define BROKER_RESERVED19 524288
/****** EVENT TYPES ************************/
#define NEBTYPE_NONE 0
#define NEBTYPE_HELLO 1
#define NEBTYPE_GOODBYE 2
#define NEBTYPE_INFO 3
#define NEBTYPE_PROCESS_START 100
#define NEBTYPE_PROCESS_DAEMONIZE 101
#define NEBTYPE_PROCESS_RESTART 102
#define NEBTYPE_PROCESS_SHUTDOWN 103
#define NEBTYPE_PROCESS_PRELAUNCH 104 /* before objects are read or verified */
#define NEBTYPE_PROCESS_EVENTLOOPSTART 105
#define NEBTYPE_PROCESS_EVENTLOOPEND 106
#define NEBTYPE_TIMEDEVENT_ADD 200
#define NEBTYPE_TIMEDEVENT_REMOVE 201
#define NEBTYPE_TIMEDEVENT_EXECUTE 202
#define NEBTYPE_TIMEDEVENT_DELAY 203 /* NOT IMPLEMENTED */
#define NEBTYPE_TIMEDEVENT_SKIP 204 /* NOT IMPLEMENTED */
#define NEBTYPE_TIMEDEVENT_SLEEP 205
#define NEBTYPE_LOG_DATA 300
#define NEBTYPE_LOG_ROTATION 301
#define NEBTYPE_SYSTEM_COMMAND_START 400
#define NEBTYPE_SYSTEM_COMMAND_END 401
#define NEBTYPE_EVENTHANDLER_START 500
#define NEBTYPE_EVENTHANDLER_END 501
#define NEBTYPE_NOTIFICATION_START 600
#define NEBTYPE_NOTIFICATION_END 601
#define NEBTYPE_CONTACTNOTIFICATION_START 602
#define NEBTYPE_CONTACTNOTIFICATION_END 603
#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_START 604
#define NEBTYPE_CONTACTNOTIFICATIONMETHOD_END 605
#define NEBTYPE_SERVICECHECK_INITIATE 700
#define NEBTYPE_SERVICECHECK_PROCESSED 701
#define NEBTYPE_SERVICECHECK_RAW_START 702 /* NOT IMPLEMENTED */
#define NEBTYPE_SERVICECHECK_RAW_END 703 /* NOT IMPLEMENTED */
#define NEBTYPE_SERVICECHECK_ASYNC_PRECHECK 704
#define NEBTYPE_HOSTCHECK_INITIATE 800 /* a check of the route to the host has been initiated */
#define NEBTYPE_HOSTCHECK_PROCESSED 801 /* the processed/final result of a host check */
#define NEBTYPE_HOSTCHECK_RAW_START 802 /* the start of a "raw" host check */
#define NEBTYPE_HOSTCHECK_RAW_END 803 /* a finished "raw" host check */
#define NEBTYPE_HOSTCHECK_ASYNC_PRECHECK 804
#define NEBTYPE_HOSTCHECK_SYNC_PRECHECK 805
#define NEBTYPE_COMMENT_ADD 900
#define NEBTYPE_COMMENT_DELETE 901
#define NEBTYPE_COMMENT_LOAD 902
#define NEBTYPE_FLAPPING_START 1000
#define NEBTYPE_FLAPPING_STOP 1001
#define NEBTYPE_DOWNTIME_ADD 1100
#define NEBTYPE_DOWNTIME_DELETE 1101
#define NEBTYPE_DOWNTIME_LOAD 1102
#define NEBTYPE_DOWNTIME_START 1103
#define NEBTYPE_DOWNTIME_STOP 1104
#define NEBTYPE_PROGRAMSTATUS_UPDATE 1200
#define NEBTYPE_HOSTSTATUS_UPDATE 1201
#define NEBTYPE_SERVICESTATUS_UPDATE 1202
#define NEBTYPE_CONTACTSTATUS_UPDATE 1203
#define NEBTYPE_ADAPTIVEPROGRAM_UPDATE 1300
#define NEBTYPE_ADAPTIVEHOST_UPDATE 1301
#define NEBTYPE_ADAPTIVESERVICE_UPDATE 1302
#define NEBTYPE_ADAPTIVECONTACT_UPDATE 1303
#define NEBTYPE_EXTERNALCOMMAND_START 1400
#define NEBTYPE_EXTERNALCOMMAND_END 1401
#define NEBTYPE_AGGREGATEDSTATUS_STARTDUMP 1500
#define NEBTYPE_AGGREGATEDSTATUS_ENDDUMP 1501
#define NEBTYPE_RETENTIONDATA_STARTLOAD 1600
#define NEBTYPE_RETENTIONDATA_ENDLOAD 1601
#define NEBTYPE_RETENTIONDATA_STARTSAVE 1602
#define NEBTYPE_RETENTIONDATA_ENDSAVE 1603
#define NEBTYPE_ACKNOWLEDGEMENT_ADD 1700
#define NEBTYPE_ACKNOWLEDGEMENT_REMOVE 1701 /* NOT IMPLEMENTED */
#define NEBTYPE_ACKNOWLEDGEMENT_LOAD 1702 /* NOT IMPLEMENTED */
#define NEBTYPE_STATECHANGE_START 1800 /* NOT IMPLEMENTED */
#define NEBTYPE_STATECHANGE_END 1801
/****** EVENT FLAGS ************************/
#define NEBFLAG_NONE 0
#define NEBFLAG_PROCESS_INITIATED 1 /* event was initiated by Nagios process */
#define NEBFLAG_USER_INITIATED 2 /* event was initiated by a user request */
#define NEBFLAG_MODULE_INITIATED 3 /* event was initiated by an event broker module */
/****** EVENT ATTRIBUTES *******************/
#define NEBATTR_NONE 0
#define NEBATTR_SHUTDOWN_NORMAL 1
#define NEBATTR_SHUTDOWN_ABNORMAL 2
#define NEBATTR_RESTART_NORMAL 4
#define NEBATTR_RESTART_ABNORMAL 8
#define NEBATTR_FLAPPING_STOP_NORMAL 1
#define NEBATTR_FLAPPING_STOP_DISABLED 2 /* flapping stopped because flap detection was disabled */
#define NEBATTR_DOWNTIME_STOP_NORMAL 1
#define NEBATTR_DOWNTIME_STOP_CANCELLED 2
/****** EVENT BROKER FUNCTIONS *************/
#ifdef USE_EVENT_BROKER
struct timeval get_broker_timestamp(struct timeval *);
void broker_program_state(int,int,int,struct timeval *);
void broker_timed_event(int,int,int,timed_event *,struct timeval *);
void broker_log_data(int,int,int,char *,unsigned long,time_t,struct timeval *);
void broker_event_handler(int,int,int,int,void *,int,int,struct timeval,struct timeval,double,int,int,int,char *,char *,char *,struct timeval *);
void broker_ocp_data(int,int,int,void *,int,int,double,int,int,struct timeval *);
void broker_system_command(int,int,int,struct timeval,struct timeval,double,int,int,int,char *,char *,struct timeval *);
int broker_host_check(int,int,int,host *,int,int,int,struct timeval,struct timeval,char *,double,double,int,int,int,char *,char *,char *,char *,struct timeval *);
int broker_service_check(int,int,int,service *,int,struct timeval,struct timeval,char *,double,double,int,int,int,char *,struct timeval *);
void broker_comment_data(int,int,int,int,int,char *,char *,time_t,char *,char *,int,int,int,time_t,unsigned long,struct timeval *);
void broker_downtime_data(int,int,int,int,char *,char *,time_t,char *,char *,time_t,time_t,int,unsigned long,unsigned long,unsigned long,struct timeval *);
void broker_flapping_data(int,int,int,int,void *,double,double,double,struct timeval *);
void broker_program_status(int,int,int,struct timeval *);
void broker_host_status(int,int,int,host *,struct timeval *);
void broker_service_status(int,int,int,service *,struct timeval *);
void broker_contact_status(int,int,int,contact *,struct timeval *);
void broker_notification_data(int,int,int,int,int,struct timeval,struct timeval,void *,char *,char *,int,int,struct timeval *);
void broker_contact_notification_data(int,int,int,int,int,struct timeval,struct timeval,void *,contact *,char *,char *,int,struct timeval *);
void broker_contact_notification_method_data(int,int,int,int,int,struct timeval,struct timeval,void *,contact *,char *,char *,char *,int,struct timeval *);
void broker_adaptive_program_data(int,int,int,int,unsigned long,unsigned long,unsigned long,unsigned long,struct timeval *);
void broker_adaptive_host_data(int,int,int,host *,int,unsigned long,unsigned long,struct timeval *);
void broker_adaptive_service_data(int,int,int,service *,int,unsigned long,unsigned long,struct timeval *);
void broker_adaptive_contact_data(int,int,int,contact *,int,unsigned long,unsigned long,unsigned long,unsigned long,unsigned long,unsigned long, struct timeval *);
void broker_external_command(int,int,int,int,time_t,char *,char *,struct timeval *);
void broker_aggregated_status_data(int,int,int,struct timeval *);
void broker_retention_data(int,int,int,struct timeval *);
void broker_acknowledgement_data(int,int,int,int,void *,char *,char *,int,int,int,struct timeval *);
void broker_statechange_data(int,int,int,int,void *,int,int,int,int,struct timeval *);
#endif
#ifdef __cplusplus
}
#endif
#endif

500
include/common.h Normal file
View File

@ -0,0 +1,500 @@
/************************************************************************
*
* Nagios Common Header File
* Written By: Ethan Galstad (nagios@nagios.org)
* Last Modified: 10-22-2007
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************/
#define PROGRAM_VERSION "3.0"
#define PROGRAM_MODIFICATION_DATE "03-13-2008"
/*#define DEBUG_CHECK_IPC 1 */
/*#define DEBUG_CHECK_IPC2 1*/
/* daemon is thread safe */
#ifdef NSCORE
#ifndef _REENTRANT
#define _REENTRANT
#endif
#ifndef _THREAD_SAFE
#define _THREAD_SAFE
#endif
#endif
/* Experimental performance tweaks - use with caution */
#undef USE_MEMORY_PERFORMANCE_TWEAKS
/* my_free has been freed from bondage as a function */
#define my_free(ptr) { if(ptr) { free(ptr); ptr = NULL; } }
/***************************** COMMANDS *********************************/
#define CMD_NONE 0
#define CMD_ADD_HOST_COMMENT 1
#define CMD_DEL_HOST_COMMENT 2
#define CMD_ADD_SVC_COMMENT 3
#define CMD_DEL_SVC_COMMENT 4
#define CMD_ENABLE_SVC_CHECK 5
#define CMD_DISABLE_SVC_CHECK 6
#define CMD_SCHEDULE_SVC_CHECK 7
#define CMD_DELAY_SVC_NOTIFICATION 9
#define CMD_DELAY_HOST_NOTIFICATION 10
#define CMD_DISABLE_NOTIFICATIONS 11
#define CMD_ENABLE_NOTIFICATIONS 12
#define CMD_RESTART_PROCESS 13
#define CMD_SHUTDOWN_PROCESS 14
#define CMD_ENABLE_HOST_SVC_CHECKS 15
#define CMD_DISABLE_HOST_SVC_CHECKS 16
#define CMD_SCHEDULE_HOST_SVC_CHECKS 17
#define CMD_DELAY_HOST_SVC_NOTIFICATIONS 19 /* currently unimplemented */
#define CMD_DEL_ALL_HOST_COMMENTS 20
#define CMD_DEL_ALL_SVC_COMMENTS 21
#define CMD_ENABLE_SVC_NOTIFICATIONS 22
#define CMD_DISABLE_SVC_NOTIFICATIONS 23
#define CMD_ENABLE_HOST_NOTIFICATIONS 24
#define CMD_DISABLE_HOST_NOTIFICATIONS 25
#define CMD_ENABLE_ALL_NOTIFICATIONS_BEYOND_HOST 26
#define CMD_DISABLE_ALL_NOTIFICATIONS_BEYOND_HOST 27
#define CMD_ENABLE_HOST_SVC_NOTIFICATIONS 28
#define CMD_DISABLE_HOST_SVC_NOTIFICATIONS 29
#define CMD_PROCESS_SERVICE_CHECK_RESULT 30
#define CMD_SAVE_STATE_INFORMATION 31
#define CMD_READ_STATE_INFORMATION 32
#define CMD_ACKNOWLEDGE_HOST_PROBLEM 33
#define CMD_ACKNOWLEDGE_SVC_PROBLEM 34
#define CMD_START_EXECUTING_SVC_CHECKS 35
#define CMD_STOP_EXECUTING_SVC_CHECKS 36
#define CMD_START_ACCEPTING_PASSIVE_SVC_CHECKS 37
#define CMD_STOP_ACCEPTING_PASSIVE_SVC_CHECKS 38
#define CMD_ENABLE_PASSIVE_SVC_CHECKS 39
#define CMD_DISABLE_PASSIVE_SVC_CHECKS 40
#define CMD_ENABLE_EVENT_HANDLERS 41
#define CMD_DISABLE_EVENT_HANDLERS 42
#define CMD_ENABLE_HOST_EVENT_HANDLER 43
#define CMD_DISABLE_HOST_EVENT_HANDLER 44
#define CMD_ENABLE_SVC_EVENT_HANDLER 45
#define CMD_DISABLE_SVC_EVENT_HANDLER 46
#define CMD_ENABLE_HOST_CHECK 47
#define CMD_DISABLE_HOST_CHECK 48
#define CMD_START_OBSESSING_OVER_SVC_CHECKS 49
#define CMD_STOP_OBSESSING_OVER_SVC_CHECKS 50
#define CMD_REMOVE_HOST_ACKNOWLEDGEMENT 51
#define CMD_REMOVE_SVC_ACKNOWLEDGEMENT 52
#define CMD_SCHEDULE_FORCED_HOST_SVC_CHECKS 53
#define CMD_SCHEDULE_FORCED_SVC_CHECK 54
#define CMD_SCHEDULE_HOST_DOWNTIME 55
#define CMD_SCHEDULE_SVC_DOWNTIME 56
#define CMD_ENABLE_HOST_FLAP_DETECTION 57
#define CMD_DISABLE_HOST_FLAP_DETECTION 58
#define CMD_ENABLE_SVC_FLAP_DETECTION 59
#define CMD_DISABLE_SVC_FLAP_DETECTION 60
#define CMD_ENABLE_FLAP_DETECTION 61
#define CMD_DISABLE_FLAP_DETECTION 62
#define CMD_ENABLE_HOSTGROUP_SVC_NOTIFICATIONS 63
#define CMD_DISABLE_HOSTGROUP_SVC_NOTIFICATIONS 64
#define CMD_ENABLE_HOSTGROUP_HOST_NOTIFICATIONS 65
#define CMD_DISABLE_HOSTGROUP_HOST_NOTIFICATIONS 66
#define CMD_ENABLE_HOSTGROUP_SVC_CHECKS 67
#define CMD_DISABLE_HOSTGROUP_SVC_CHECKS 68
#define CMD_CANCEL_HOST_DOWNTIME 69 /* not internally implemented */
#define CMD_CANCEL_SVC_DOWNTIME 70 /* not internally implemented */
#define CMD_CANCEL_ACTIVE_HOST_DOWNTIME 71 /* old - no longer used */
#define CMD_CANCEL_PENDING_HOST_DOWNTIME 72 /* old - no longer used */
#define CMD_CANCEL_ACTIVE_SVC_DOWNTIME 73 /* old - no longer used */
#define CMD_CANCEL_PENDING_SVC_DOWNTIME 74 /* old - no longer used */
#define CMD_CANCEL_ACTIVE_HOST_SVC_DOWNTIME 75 /* unimplemented */
#define CMD_CANCEL_PENDING_HOST_SVC_DOWNTIME 76 /* unimplemented */
#define CMD_FLUSH_PENDING_COMMANDS 77
#define CMD_DEL_HOST_DOWNTIME 78
#define CMD_DEL_SVC_DOWNTIME 79
#define CMD_ENABLE_FAILURE_PREDICTION 80
#define CMD_DISABLE_FAILURE_PREDICTION 81
#define CMD_ENABLE_PERFORMANCE_DATA 82
#define CMD_DISABLE_PERFORMANCE_DATA 83
#define CMD_SCHEDULE_HOSTGROUP_HOST_DOWNTIME 84
#define CMD_SCHEDULE_HOSTGROUP_SVC_DOWNTIME 85
#define CMD_SCHEDULE_HOST_SVC_DOWNTIME 86
/* new commands in Nagios 2.x found below... */
#define CMD_PROCESS_HOST_CHECK_RESULT 87
#define CMD_START_EXECUTING_HOST_CHECKS 88
#define CMD_STOP_EXECUTING_HOST_CHECKS 89
#define CMD_START_ACCEPTING_PASSIVE_HOST_CHECKS 90
#define CMD_STOP_ACCEPTING_PASSIVE_HOST_CHECKS 91
#define CMD_ENABLE_PASSIVE_HOST_CHECKS 92
#define CMD_DISABLE_PASSIVE_HOST_CHECKS 93
#define CMD_START_OBSESSING_OVER_HOST_CHECKS 94
#define CMD_STOP_OBSESSING_OVER_HOST_CHECKS 95
#define CMD_SCHEDULE_HOST_CHECK 96
#define CMD_SCHEDULE_FORCED_HOST_CHECK 98
#define CMD_START_OBSESSING_OVER_SVC 99
#define CMD_STOP_OBSESSING_OVER_SVC 100
#define CMD_START_OBSESSING_OVER_HOST 101
#define CMD_STOP_OBSESSING_OVER_HOST 102
#define CMD_ENABLE_HOSTGROUP_HOST_CHECKS 103
#define CMD_DISABLE_HOSTGROUP_HOST_CHECKS 104
#define CMD_ENABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 105
#define CMD_DISABLE_HOSTGROUP_PASSIVE_SVC_CHECKS 106
#define CMD_ENABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 107
#define CMD_DISABLE_HOSTGROUP_PASSIVE_HOST_CHECKS 108
#define CMD_ENABLE_SERVICEGROUP_SVC_NOTIFICATIONS 109
#define CMD_DISABLE_SERVICEGROUP_SVC_NOTIFICATIONS 110
#define CMD_ENABLE_SERVICEGROUP_HOST_NOTIFICATIONS 111
#define CMD_DISABLE_SERVICEGROUP_HOST_NOTIFICATIONS 112
#define CMD_ENABLE_SERVICEGROUP_SVC_CHECKS 113
#define CMD_DISABLE_SERVICEGROUP_SVC_CHECKS 114
#define CMD_ENABLE_SERVICEGROUP_HOST_CHECKS 115
#define CMD_DISABLE_SERVICEGROUP_HOST_CHECKS 116
#define CMD_ENABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 117
#define CMD_DISABLE_SERVICEGROUP_PASSIVE_SVC_CHECKS 118
#define CMD_ENABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 119
#define CMD_DISABLE_SERVICEGROUP_PASSIVE_HOST_CHECKS 120
#define CMD_SCHEDULE_SERVICEGROUP_HOST_DOWNTIME 121
#define CMD_SCHEDULE_SERVICEGROUP_SVC_DOWNTIME 122
#define CMD_CHANGE_GLOBAL_HOST_EVENT_HANDLER 123
#define CMD_CHANGE_GLOBAL_SVC_EVENT_HANDLER 124
#define CMD_CHANGE_HOST_EVENT_HANDLER 125
#define CMD_CHANGE_SVC_EVENT_HANDLER 126
#define CMD_CHANGE_HOST_CHECK_COMMAND 127
#define CMD_CHANGE_SVC_CHECK_COMMAND 128
#define CMD_CHANGE_NORMAL_HOST_CHECK_INTERVAL 129
#define CMD_CHANGE_NORMAL_SVC_CHECK_INTERVAL 130
#define CMD_CHANGE_RETRY_SVC_CHECK_INTERVAL 131
#define CMD_CHANGE_MAX_HOST_CHECK_ATTEMPTS 132
#define CMD_CHANGE_MAX_SVC_CHECK_ATTEMPTS 133
#define CMD_SCHEDULE_AND_PROPAGATE_TRIGGERED_HOST_DOWNTIME 134
#define CMD_ENABLE_HOST_AND_CHILD_NOTIFICATIONS 135
#define CMD_DISABLE_HOST_AND_CHILD_NOTIFICATIONS 136
#define CMD_SCHEDULE_AND_PROPAGATE_HOST_DOWNTIME 137
#define CMD_ENABLE_SERVICE_FRESHNESS_CHECKS 138
#define CMD_DISABLE_SERVICE_FRESHNESS_CHECKS 139
#define CMD_ENABLE_HOST_FRESHNESS_CHECKS 140
#define CMD_DISABLE_HOST_FRESHNESS_CHECKS 141
#define CMD_SET_HOST_NOTIFICATION_NUMBER 142
#define CMD_SET_SVC_NOTIFICATION_NUMBER 143
/* new commands in Nagios 3.x found below... */
#define CMD_CHANGE_HOST_CHECK_TIMEPERIOD 144
#define CMD_CHANGE_SVC_CHECK_TIMEPERIOD 145
#define CMD_PROCESS_FILE 146
#define CMD_CHANGE_CUSTOM_HOST_VAR 147
#define CMD_CHANGE_CUSTOM_SVC_VAR 148
#define CMD_CHANGE_CUSTOM_CONTACT_VAR 149
#define CMD_ENABLE_CONTACT_HOST_NOTIFICATIONS 150
#define CMD_DISABLE_CONTACT_HOST_NOTIFICATIONS 151
#define CMD_ENABLE_CONTACT_SVC_NOTIFICATIONS 152
#define CMD_DISABLE_CONTACT_SVC_NOTIFICATIONS 153
#define CMD_ENABLE_CONTACTGROUP_HOST_NOTIFICATIONS 154
#define CMD_DISABLE_CONTACTGROUP_HOST_NOTIFICATIONS 155
#define CMD_ENABLE_CONTACTGROUP_SVC_NOTIFICATIONS 156
#define CMD_DISABLE_CONTACTGROUP_SVC_NOTIFICATIONS 157
#define CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL 158
#define CMD_SEND_CUSTOM_HOST_NOTIFICATION 159
#define CMD_SEND_CUSTOM_SVC_NOTIFICATION 160
#define CMD_CHANGE_HOST_NOTIFICATION_TIMEPERIOD 161
#define CMD_CHANGE_SVC_NOTIFICATION_TIMEPERIOD 162
#define CMD_CHANGE_CONTACT_HOST_NOTIFICATION_TIMEPERIOD 163
#define CMD_CHANGE_CONTACT_SVC_NOTIFICATION_TIMEPERIOD 164
#define CMD_CHANGE_HOST_MODATTR 165
#define CMD_CHANGE_SVC_MODATTR 166
#define CMD_CHANGE_CONTACT_MODATTR 167
#define CMD_CHANGE_CONTACT_MODHATTR 168
#define CMD_CHANGE_CONTACT_MODSATTR 169
/* custom command introduced in Nagios 3.x */
#define CMD_CUSTOM_COMMAND 999
/************************ SERVICE CHECK TYPES ****************************/
#define SERVICE_CHECK_ACTIVE 0 /* Nagios performed the service check */
#define SERVICE_CHECK_PASSIVE 1 /* the service check result was submitted by an external source */
/************************** HOST CHECK TYPES *****************************/
#define HOST_CHECK_ACTIVE 0 /* Nagios performed the host check */
#define HOST_CHECK_PASSIVE 1 /* the host check result was submitted by an external source */
/************************ SERVICE STATE TYPES ****************************/
#define SOFT_STATE 0
#define HARD_STATE 1
/************************* SCHEDULED DOWNTIME TYPES **********************/
#define SERVICE_DOWNTIME 1 /* service downtime */
#define HOST_DOWNTIME 2 /* host downtime */
#define ANY_DOWNTIME 3 /* host or service downtime */
/************************** NOTIFICATION OPTIONS *************************/
#define NOTIFICATION_OPTION_NONE 0
#define NOTIFICATION_OPTION_BROADCAST 1
#define NOTIFICATION_OPTION_FORCED 2
#define NOTIFICATION_OPTION_INCREMENT 4
/************************** ACKNOWLEDGEMENT TYPES ************************/
#define HOST_ACKNOWLEDGEMENT 0
#define SERVICE_ACKNOWLEDGEMENT 1
#define ACKNOWLEDGEMENT_NONE 0
#define ACKNOWLEDGEMENT_NORMAL 1
#define ACKNOWLEDGEMENT_STICKY 2
/**************************** DEPENDENCY TYPES ***************************/
#define NOTIFICATION_DEPENDENCY 1
#define EXECUTION_DEPENDENCY 2
/********************** HOST/SERVICE CHECK OPTIONS ***********************/
#define CHECK_OPTION_NONE 0 /* no check options */
#define CHECK_OPTION_FORCE_EXECUTION 1 /* force execution of a check (ignores disabled services/hosts, invalid timeperiods) */
#define CHECK_OPTION_FRESHNESS_CHECK 2 /* this is a freshness check */
#define CHECK_OPTION_ORPHAN_CHECK 4 /* this is an orphan check */
/**************************** PROGRAM MODES ******************************/
#define STANDBY_MODE 0
#define ACTIVE_MODE 1
/************************** LOG ROTATION MODES ***************************/
#define LOG_ROTATION_NONE 0
#define LOG_ROTATION_HOURLY 1
#define LOG_ROTATION_DAILY 2
#define LOG_ROTATION_WEEKLY 3
#define LOG_ROTATION_MONTHLY 4
/***************************** LOG VERSIONS ******************************/
#define LOG_VERSION_1 "1.0"
#define LOG_VERSION_2 "2.0"
/*************************** CHECK STATISTICS ****************************/
#define ACTIVE_SCHEDULED_SERVICE_CHECK_STATS 0
#define ACTIVE_ONDEMAND_SERVICE_CHECK_STATS 1
#define PASSIVE_SERVICE_CHECK_STATS 2
#define ACTIVE_SCHEDULED_HOST_CHECK_STATS 3
#define ACTIVE_ONDEMAND_HOST_CHECK_STATS 4
#define PASSIVE_HOST_CHECK_STATS 5
#define ACTIVE_CACHED_HOST_CHECK_STATS 6
#define ACTIVE_CACHED_SERVICE_CHECK_STATS 7
#define EXTERNAL_COMMAND_STATS 8
#define PARALLEL_HOST_CHECK_STATS 9
#define SERIAL_HOST_CHECK_STATS 10
#define MAX_CHECK_STATS_TYPES 11
/************************* GENERAL DEFINITIONS **************************/
#define OK 0
#define ERROR -2 /* value was changed from -1 so as to not interfere with STATUS_UNKNOWN plugin result */
#ifndef TRUE
#define TRUE 1
#elif (TRUE!=1)
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#elif (FALSE!=0)
#define FALSE 0
#endif
/****************** HOST CONFIG FILE READING OPTIONS ********************/
#define READ_HOSTS 1
#define READ_HOSTGROUPS 2
#define READ_CONTACTS 4
#define READ_CONTACTGROUPS 8
#define READ_SERVICES 16
#define READ_COMMANDS 32
#define READ_TIMEPERIODS 64
#define READ_SERVICEESCALATIONS 128
#define READ_HOSTGROUPESCALATIONS 256 /* no longer implemented */
#define READ_SERVICEDEPENDENCIES 512
#define READ_HOSTDEPENDENCIES 1024
#define READ_HOSTESCALATIONS 2048
#define READ_HOSTEXTINFO 4096
#define READ_SERVICEEXTINFO 8192
#define READ_SERVICEGROUPS 16384
#define READ_ALL_OBJECT_DATA READ_HOSTS | READ_HOSTGROUPS | READ_CONTACTS | READ_CONTACTGROUPS | READ_SERVICES | READ_COMMANDS | READ_TIMEPERIODS | READ_SERVICEESCALATIONS | READ_SERVICEDEPENDENCIES | READ_HOSTDEPENDENCIES | READ_HOSTESCALATIONS | READ_HOSTEXTINFO | READ_SERVICEEXTINFO | READ_SERVICEGROUPS
/************************** DATE RANGE TYPES ****************************/
#define DATERANGE_CALENDAR_DATE 0 /* 2008-12-25 */
#define DATERANGE_MONTH_DATE 1 /* july 4 (specific month) */
#define DATERANGE_MONTH_DAY 2 /* day 21 (generic month) */
#define DATERANGE_MONTH_WEEK_DAY 3 /* 3rd thursday (specific month) */
#define DATERANGE_WEEK_DAY 4 /* 3rd thursday (generic month) */
#define DATERANGE_TYPES 5
/************************** DATE/TIME TYPES *****************************/
#define LONG_DATE_TIME 0
#define SHORT_DATE_TIME 1
#define SHORT_DATE 2
#define SHORT_TIME 3
#define HTTP_DATE_TIME 4 /* time formatted for use in HTTP headers */
/**************************** DATE FORMATS ******************************/
#define DATE_FORMAT_US 0 /* U.S. (MM-DD-YYYY HH:MM:SS) */
#define DATE_FORMAT_EURO 1 /* European (DD-MM-YYYY HH:MM:SS) */
#define DATE_FORMAT_ISO8601 2 /* ISO8601 (YYYY-MM-DD HH:MM:SS) */
#define DATE_FORMAT_STRICT_ISO8601 3 /* ISO8601 (YYYY-MM-DDTHH:MM:SS) */
/************************** MISC DEFINITIONS ****************************/
#define MAX_FILENAME_LENGTH 256 /* max length of path/filename that Nagios will process */
#define MAX_INPUT_BUFFER 1024 /* size in bytes of max. input buffer (for reading files, misc stuff) */
#define MAX_COMMAND_BUFFER 8192 /* max length of raw or processed command line */
#define MAX_EXTERNAL_COMMAND_LENGTH 8192 /* max length of an external command */
#define MAX_DATETIME_LENGTH 48
/************************* MODIFIED ATTRIBUTES **************************/
#define MODATTR_NONE 0
#define MODATTR_NOTIFICATIONS_ENABLED 1
#define MODATTR_ACTIVE_CHECKS_ENABLED 2
#define MODATTR_PASSIVE_CHECKS_ENABLED 4
#define MODATTR_EVENT_HANDLER_ENABLED 8
#define MODATTR_FLAP_DETECTION_ENABLED 16
#define MODATTR_FAILURE_PREDICTION_ENABLED 32
#define MODATTR_PERFORMANCE_DATA_ENABLED 64
#define MODATTR_OBSESSIVE_HANDLER_ENABLED 128
#define MODATTR_EVENT_HANDLER_COMMAND 256
#define MODATTR_CHECK_COMMAND 512
#define MODATTR_NORMAL_CHECK_INTERVAL 1024
#define MODATTR_RETRY_CHECK_INTERVAL 2048
#define MODATTR_MAX_CHECK_ATTEMPTS 4096
#define MODATTR_FRESHNESS_CHECKS_ENABLED 8192
#define MODATTR_CHECK_TIMEPERIOD 16384
#define MODATTR_CUSTOM_VARIABLE 32768
#define MODATTR_NOTIFICATION_TIMEPERIOD 65536

177
include/config.h.in Normal file
View File

@ -0,0 +1,177 @@
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* Default Nagios Group */
#undef DEFAULT_NAGIOS_GROUP
/* Default Nagios User */
#undef DEFAULT_NAGIOS_USER
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
/* Define to 1 if you have the `getloadavg' function. */
#undef HAVE_GETLOADAVG
/* Define to 1 if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
/* Define to 1 if you have the <grp.h> header file. */
#undef HAVE_GRP_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#undef HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
/* Define to 1 if `stat' has the bug that it succeeds when given the
zero-length file name argument. */
#undef HAVE_STAT_EMPTY_STRING_BUG
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strspn' function. */
#undef HAVE_STRSPN
/* Define to 1 if `d_type' is member of `struct dirent'. */
#undef HAVE_STRUCT_DIRENT_D_TYPE
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to 1 if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/wait.h> header file. */
#undef HAVE_SYS_WAIT_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the `vfork' function. */
#undef HAVE_VFORK
/* Define to 1 if you have the <vfork.h> header file. */
#undef HAVE_VFORK_H
/* Define to 1 if `fork' works. */
#undef HAVE_WORKING_FORK
/* Define to 1 if `vfork' works. */
#undef HAVE_WORKING_VFORK
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
slash. */
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define as `fork' if `vfork' does not work. */
#undef vfork

4
include/global.h Normal file
View File

@ -0,0 +1,4 @@
#ifndef GLOBAL_H_
#define GLOBAL_H_
#endif /*GLOBAL_H_*/

43
include/locations.h Normal file
View File

@ -0,0 +1,43 @@
/************************************************************************
*
* Nagios Locations Header File
* Written By: Ethan Galstad (nagios@nagios.org)
* Last Modified: 04-30-2007
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************/
#define DEFAULT_TEMP_FILE "/usr/local/nagios/var/tempfile"
#define DEFAULT_TEMP_PATH "/tmp"
#define DEFAULT_CHECK_RESULT_PATH "/usr/local/nagios/var/spool/checkresults"
#define DEFAULT_STATUS_FILE "/usr/local/nagios/var/status.dat"
#define DEFAULT_LOG_FILE "/usr/local/nagios/var/nagios.log"
#define DEFAULT_LOG_ARCHIVE_PATH "/usr/local/nagios/var/archives/"
#define DEFAULT_DEBUG_FILE "/usr/local/nagios/var/nagios.debug"
#define DEFAULT_COMMENT_FILE "/usr/local/nagios/var/comments.dat"
#define DEFAULT_DOWNTIME_FILE "/usr/local/nagios/var/downtime.dat"
#define DEFAULT_RETENTION_FILE "/usr/local/nagios/var/retention.dat"
#define DEFAULT_COMMAND_FILE "/usr/local/nagios/var/rw/nagios.cmd"
#define DEFAULT_CONFIG_FILE "/usr/local/nagios/etc/nagios.cfg"
#define DEFAULT_PHYSICAL_HTML_PATH "/usr/local/nagios/share"
#define DEFAULT_URL_HTML_PATH "/nagios"
#define DEFAULT_PHYSICAL_CGIBIN_PATH "/usr/local/nagios/sbin"
#define DEFAULT_URL_CGIBIN_PATH "/nagios/cgi-bin"
#define DEFAULT_CGI_CONFIG_FILE "/usr/local/nagios/etc/cgi.cfg"
#define DEFAULT_LOCK_FILE "/usr/local/nagios/var/nagios.lock"
#define DEFAULT_OBJECT_CACHE_FILE "/usr/local/nagios/var/objects.cache"
#define DEFAULT_PRECACHED_OBJECT_FILE "/usr/local/nagios/var/objects.precache"
#define DEFAULT_EVENT_BROKER_FILE "/usr/local/nagios/var/broker.socket"
#define DEFAULT_P1_FILE "/usr/local/nagios/bin/p1.pl" /**** EMBEDDED PERL ****/
#define DEFAULT_AUTH_FILE "" /**** EMBEDDED PERL - IS THIS USED? ****/

812
include/nagios.h Normal file
View File

@ -0,0 +1,812 @@
/************************************************************************
*
* Nagios Main Header File
* Written By: Ethan Galstad (nagios@nagios.org)
* Last Modified: 02-23-2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
************************************************************************/
#ifndef _NAGIOS_H
#define _NAGIOS_H
#ifndef __GNUC__
# define __attribute__(x) /* nothing */
#endif
#include "config.h"
//#include "pnp.h"
#include "common.h"
#include "locations.h"
#include "objects.h"
#ifdef __cplusplus
extern "C" {
#endif
/************* MISC LENGTH/SIZE DEFINITIONS ***********/
/*
NOTE: Plugin length is artificially capped at 8k to prevent runaway plugins from returning MBs/GBs of data
back to Nagios. If you increase the 8k cap by modifying this value, make sure you also increase the value
of MAX_EXTERNAL_COMMAND_LENGTH in common.h to allow for passive checks results received through the external
command file. EG 10/19/07
*/
#define MAX_PLUGIN_OUTPUT_LENGTH 8192 /* max length of plugin output (including perf data) */
/******************* DEFAULT VALUES *******************/
#define DEFAULT_LOG_LEVEL 1 /* log all events to main log file */
#define DEFAULT_USE_SYSLOG 1 /* log events to syslog? 1=yes, 0=no */
#define DEFAULT_SYSLOG_LEVEL 2 /* log only severe events to syslog */
#define DEFAULT_NOTIFICATION_LOGGING 1 /* log notification events? 1=yes, 0=no */
#define DEFAULT_INTER_CHECK_DELAY 5.0 /* seconds between initial service check scheduling */
#define DEFAULT_INTERLEAVE_FACTOR 1 /* default interleave to use when scheduling checks */
#define DEFAULT_SLEEP_TIME 0.5 /* seconds between event run checks */
#define DEFAULT_INTERVAL_LENGTH 60 /* seconds per interval unit for check scheduling */
#define DEFAULT_RETRY_INTERVAL 30 /* services are retried in 30 seconds if they're not OK */
#define DEFAULT_COMMAND_CHECK_INTERVAL -1 /* interval to check for external commands (default = as often as possible) */
#define DEFAULT_CHECK_REAPER_INTERVAL 10 /* interval in seconds to reap host and service check results */
#define DEFAULT_MAX_REAPER_TIME 30 /* maximum number of seconds to spend reaping service checks before we break out for a while */
#define DEFAULT_MAX_CHECK_RESULT_AGE 3600 /* maximum number of seconds that a check result file is considered to be valid */
#define DEFAULT_MAX_PARALLEL_SERVICE_CHECKS 0 /* maximum number of service checks we can have running at any given time (0=unlimited) */
#define DEFAULT_RETENTION_UPDATE_INTERVAL 60 /* minutes between auto-save of retention data */
#define DEFAULT_RETENTION_SCHEDULING_HORIZON 900 /* max seconds between program restarts that we will preserve scheduling information */
#define DEFAULT_STATUS_UPDATE_INTERVAL 60 /* seconds between aggregated status data updates */
#define DEFAULT_FRESHNESS_CHECK_INTERVAL 60 /* seconds between service result freshness checks */
#define DEFAULT_AUTO_RESCHEDULING_INTERVAL 30 /* seconds between host and service check rescheduling events */
#define DEFAULT_AUTO_RESCHEDULING_WINDOW 180 /* window of time (in seconds) for which we should reschedule host and service checks */
#define DEFAULT_ORPHAN_CHECK_INTERVAL 60 /* seconds between checks for orphaned hosts and services */
#define DEFAULT_NOTIFICATION_TIMEOUT 30 /* max time in seconds to wait for notification commands to complete */
#define DEFAULT_EVENT_HANDLER_TIMEOUT 30 /* max time in seconds to wait for event handler commands to complete */
#define DEFAULT_HOST_CHECK_TIMEOUT 30 /* max time in seconds to wait for host check commands to complete */
#define DEFAULT_SERVICE_CHECK_TIMEOUT 60 /* max time in seconds to wait for service check commands to complete */
#define DEFAULT_OCSP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */
#define DEFAULT_OCHP_TIMEOUT 15 /* max time in seconds to wait for obsessive compulsive processing commands to complete */
#define DEFAULT_PERFDATA_TIMEOUT 5 /* max time in seconds to wait for performance data commands to complete */
#define DEFAULT_TIME_CHANGE_THRESHOLD 900 /* compensate for time changes of more than 15 minutes */
#define DEFAULT_LOG_HOST_RETRIES 0 /* don't log host retries */
#define DEFAULT_LOG_SERVICE_RETRIES 0 /* don't log service retries */
#define DEFAULT_LOG_EVENT_HANDLERS 1 /* log event handlers */
#define DEFAULT_LOG_INITIAL_STATES 0 /* don't log initial service and host states */
#define DEFAULT_LOG_EXTERNAL_COMMANDS 1 /* log external commands */
#define DEFAULT_LOG_PASSIVE_CHECKS 1 /* log passive service checks */
#define DEFAULT_DEBUG_LEVEL 0 /* don't log any debugging information */
#define DEFAULT_DEBUG_VERBOSITY 1
#define DEFAULT_MAX_DEBUG_FILE_SIZE 1000000 /* max size of debug log */
#define DEFAULT_AGGRESSIVE_HOST_CHECKING 0 /* don't use "aggressive" host checking */
#define DEFAULT_CHECK_EXTERNAL_COMMANDS 1 /* check for external commands */
#define DEFAULT_CHECK_ORPHANED_SERVICES 1 /* check for orphaned services */
#define DEFAULT_CHECK_ORPHANED_HOSTS 1 /* check for orphaned hosts */
#define DEFAULT_ENABLE_FLAP_DETECTION 0 /* don't enable flap detection */
#define DEFAULT_PROCESS_PERFORMANCE_DATA 0 /* don't process performance data */
#define DEFAULT_CHECK_SERVICE_FRESHNESS 1 /* check service result freshness */
#define DEFAULT_CHECK_HOST_FRESHNESS 0 /* don't check host result freshness */
#define DEFAULT_AUTO_RESCHEDULE_CHECKS 0 /* don't auto-reschedule host and service checks */
#define DEFAULT_TRANSLATE_PASSIVE_HOST_CHECKS 0 /* should we translate DOWN/UNREACHABLE passive host checks? */
#define DEFAULT_PASSIVE_HOST_CHECKS_SOFT 0 /* passive host checks are treated as HARD by default */
#define DEFAULT_LOW_SERVICE_FLAP_THRESHOLD 20.0 /* low threshold for detection of service flapping */
#define DEFAULT_HIGH_SERVICE_FLAP_THRESHOLD 30.0 /* high threshold for detection of service flapping */
#define DEFAULT_LOW_HOST_FLAP_THRESHOLD 20.0 /* low threshold for detection of host flapping */
#define DEFAULT_HIGH_HOST_FLAP_THRESHOLD 30.0 /* high threshold for detection of host flapping */
#define DEFAULT_HOST_CHECK_SPREAD 30 /* max minutes to schedule all initial host checks */
#define DEFAULT_SERVICE_CHECK_SPREAD 30 /* max minutes to schedule all initial service checks */
#define DEFAULT_CACHED_HOST_CHECK_HORIZON 15 /* max age in seconds that cached host checks can be used */
#define DEFAULT_CACHED_SERVICE_CHECK_HORIZON 15 /* max age in seconds that cached service checks can be used */
#define DEFAULT_ENABLE_PREDICTIVE_HOST_DEPENDENCY_CHECKS 1 /* should we use predictive host dependency checks? */
#define DEFAULT_ENABLE_PREDICTIVE_SERVICE_DEPENDENCY_CHECKS 1 /* should we use predictive service dependency checks? */
#define DEFAULT_USE_LARGE_INSTALLATION_TWEAKS 0 /* don't use tweaks for large Nagios installations */
#define DEFAULT_ENABLE_EMBEDDED_PERL 1 /* enable embedded Perl interpreter (if compiled in) */
#define DEFAULT_USE_EMBEDDED_PERL_IMPLICITLY 1 /* by default, embedded Perl is used for Perl plugins that don't explicitly disable it */
#define DEFAULT_ADDITIONAL_FRESHNESS_LATENCY 15 /* seconds to be added to freshness thresholds when automatically calculated by Nagios */
/******************* LOGGING TYPES ********************/
#define NSLOG_RUNTIME_ERROR 1
#define NSLOG_RUNTIME_WARNING 2
#define NSLOG_VERIFICATION_ERROR 4
#define NSLOG_VERIFICATION_WARNING 8
#define NSLOG_CONFIG_ERROR 16
#define NSLOG_CONFIG_WARNING 32
#define NSLOG_PROCESS_INFO 64
#define NSLOG_EVENT_HANDLER 128
/*#define NSLOG_NOTIFICATION 256*/ /* NOT USED ANYMORE - CAN BE REUSED */
#define NSLOG_EXTERNAL_COMMAND 512
#define NSLOG_HOST_UP 1024
#define NSLOG_HOST_DOWN 2048
#define NSLOG_HOST_UNREACHABLE 4096
#define NSLOG_SERVICE_OK 8192
#define NSLOG_SERVICE_UNKNOWN 16384
#define NSLOG_SERVICE_WARNING 32768
#define NSLOG_SERVICE_CRITICAL 65536
#define NSLOG_PASSIVE_CHECK 131072
#define NSLOG_INFO_MESSAGE 262144
#define NSLOG_HOST_NOTIFICATION 524288
#define NSLOG_SERVICE_NOTIFICATION 1048576
/***************** DEBUGGING LEVELS *******************/
#define DEBUGL_ALL -1
#define DEBUGL_NONE 0
#define DEBUGL_FUNCTIONS 1
#define DEBUGL_CONFIG 2
#define DEBUGL_PROCESS 4
#define DEBUGL_STATUSDATA 4
#define DEBUGL_RETENTIONDATA 4
#define DEBUGL_EVENTS 8
#define DEBUGL_CHECKS 16
#define DEBUGL_IPC 16
#define DEBUGL_FLAPPING 16
#define DEBUGL_EVENTHANDLERS 16
#define DEBUGL_PERFDATA 16
#define DEBUGL_NOTIFICATIONS 32
#define DEBUGL_EVENTBROKER 64
#define DEBUGL_EXTERNALCOMMANDS 128
#define DEBUGL_COMMANDS 256
#define DEBUGL_DOWNTIME 512
#define DEBUGL_COMMENTS 1024
#define DEBUGL_MACROS 2048
#define DEBUGV_BASIC 0
#define DEBUGV_MORE 1
#define DEBUGV_MOST 2
/******************** HOST STATUS *********************/
#define HOST_UP 0
#define HOST_DOWN 1
#define HOST_UNREACHABLE 2
/******************* STATE LOGGING TYPES **************/
#define INITIAL_STATES 1
#define CURRENT_STATES 2
/************ SERVICE DEPENDENCY VALUES ***************/
#define DEPENDENCIES_OK 0
#define DEPENDENCIES_FAILED 1
/*********** ROUTE CHECK PROPAGATION TYPES ************/
#define PROPAGATE_TO_PARENT_HOSTS 1
#define PROPAGATE_TO_CHILD_HOSTS 2
/****************** SERVICE STATES ********************/
#define STATE_OK 0
#define STATE_WARNING 1
#define STATE_CRITICAL 2
#define STATE_UNKNOWN 3 /* changed from -1 on 02/24/2001 */
/****************** FLAPPING TYPES ********************/
#define HOST_FLAPPING 0
#define SERVICE_FLAPPING 1
/**************** NOTIFICATION TYPES ******************/
#define HOST_NOTIFICATION 0
#define SERVICE_NOTIFICATION 1
/************* NOTIFICATION REASON TYPES ***************/
#define NOTIFICATION_NORMAL 0
#define NOTIFICATION_ACKNOWLEDGEMENT 1
#define NOTIFICATION_FLAPPINGSTART 2
#define NOTIFICATION_FLAPPINGSTOP 3
#define NOTIFICATION_FLAPPINGDISABLED 4
#define NOTIFICATION_DOWNTIMESTART 5
#define NOTIFICATION_DOWNTIMEEND 6
#define NOTIFICATION_DOWNTIMECANCELLED 7
#define NOTIFICATION_CUSTOM 99
/**************** EVENT HANDLER TYPES *****************/
#define HOST_EVENTHANDLER 0
#define SERVICE_EVENTHANDLER 1
#define GLOBAL_HOST_EVENTHANDLER 2
#define GLOBAL_SERVICE_EVENTHANDLER 3
/***************** STATE CHANGE TYPES *****************/
#define HOST_STATECHANGE 0
#define SERVICE_STATECHANGE 1
/***************** OBJECT CHECK TYPES *****************/
#define SERVICE_CHECK 0
#define HOST_CHECK 1
/******************* EVENT TYPES **********************/
#define EVENT_SERVICE_CHECK 0 /* active service check */
#define EVENT_COMMAND_CHECK 1 /* external command check */
#define EVENT_LOG_ROTATION 2 /* log file rotation */
#define EVENT_PROGRAM_SHUTDOWN 3 /* program shutdown */
#define EVENT_PROGRAM_RESTART 4 /* program restart */
#define EVENT_CHECK_REAPER 5 /* reaps results from host and service checks */
#define EVENT_ORPHAN_CHECK 6 /* checks for orphaned hosts and services */
#define EVENT_RETENTION_SAVE 7 /* save (dump) retention data */
#define EVENT_STATUS_SAVE 8 /* save (dump) status data */
#define EVENT_SCHEDULED_DOWNTIME 9 /* scheduled host or service downtime */
#define EVENT_SFRESHNESS_CHECK 10 /* checks service result "freshness" */
#define EVENT_EXPIRE_DOWNTIME 11 /* checks for (and removes) expired scheduled downtime */
#define EVENT_HOST_CHECK 12 /* active host check */
#define EVENT_HFRESHNESS_CHECK 13 /* checks host result "freshness" */
#define EVENT_RESCHEDULE_CHECKS 14 /* adjust scheduling of host and service checks */
#define EVENT_EXPIRE_COMMENT 15 /* removes expired comments */
#define EVENT_SLEEP 98 /* asynchronous sleep event that occurs when event queues are empty */
#define EVENT_USER_FUNCTION 99 /* USER-defined function (modules) */
/******* INTER-CHECK DELAY CALCULATION TYPES **********/
#define ICD_NONE 0 /* no inter-check delay */
#define ICD_DUMB 1 /* dumb delay of 1 second */
#define ICD_SMART 2 /* smart delay */
#define ICD_USER 3 /* user-specified delay */
/******* INTERLEAVE FACTOR CALCULATION TYPES **********/
#define ILF_USER 0 /* user-specified interleave factor */
#define ILF_SMART 1 /* smart interleave */
/************ SCHEDULED DOWNTIME TYPES ****************/
#define ACTIVE_DOWNTIME 0 /* active downtime - currently in effect */
#define PENDING_DOWNTIME 1 /* pending downtime - scheduled for the future */
/****************** DATA STRUCTURES *******************/
/* TIMED_EVENT structure */
typedef struct timed_event_struct{
int event_type;
time_t run_time;
int recurring;
unsigned long event_interval;
int compensate_for_time_change;
void *timing_func;
void *event_data;
void *event_args;
int event_options;
struct timed_event_struct *next;
struct timed_event_struct *prev;
}timed_event;
/* NOTIFY_LIST structure */
typedef struct notify_list_struct{
contact *contact;
struct notify_list_struct *next;
}notification;
/* CHECK_RESULT structure */
typedef struct check_result_struct{
int object_check_type; /* is this a service or a host check? */
char *host_name; /* host name */
char *service_description; /* service description */
int check_type; /* was this an active or passive service check? */
int check_options;
int scheduled_check; /* was this a scheduled or an on-demand check? */
int reschedule_check; /* should we reschedule the next check */
char *output_file; /* what file is the output stored in? */
FILE *output_file_fp;
int output_file_fd;
double latency;
struct timeval start_time; /* time the service check was initiated */
struct timeval finish_time; /* time the service check was completed */
int early_timeout; /* did the service check timeout? */
int exited_ok; /* did the plugin check return okay? */
int return_code; /* plugin return code */
char *output; /* plugin output */
struct check_result_struct *next;
}check_result;
/* SCHED_INFO structure */
typedef struct sched_info_struct{
int total_services;
int total_scheduled_services;
int total_hosts;
int total_scheduled_hosts;
double average_services_per_host;
double average_scheduled_services_per_host;
unsigned long service_check_interval_total;
unsigned long host_check_interval_total;
double average_service_execution_time;
double average_service_check_interval;
double average_host_check_interval;
double average_service_inter_check_delay;
double average_host_inter_check_delay;
double service_inter_check_delay;
double host_inter_check_delay;
int service_interleave_factor;
int max_service_check_spread;
int max_host_check_spread;
time_t first_service_check;
time_t last_service_check;
time_t first_host_check;
time_t last_host_check;
}sched_info;
/* PASSIVE_CHECK_RESULT structure */
typedef struct passive_check_result_struct{
int object_check_type;
char *host_name;
char *service_description;
int return_code;
char *output;
time_t check_time;
double latency;
struct passive_check_result_struct *next;
}passive_check_result;
/* CIRCULAR_BUFFER structure - used by worker threads */
typedef struct circular_buffer_struct{
void **buffer;
int tail;
int head;
int items;
int high; /* highest number of items that has ever been stored in buffer */
unsigned long overflow;
pthread_mutex_t buffer_lock;
}circular_buffer;
/* MMAPFILE structure - used for reading files via mmap() */
typedef struct mmapfile_struct{
char *path;
int mode;
int fd;
unsigned long file_size;
unsigned long current_position;
unsigned long current_line;
void *mmap_buf;
}mmapfile;
/* DBUF structure - dynamic string storage */
typedef struct dbuf_struct{
char *buf;
unsigned long used_size;
unsigned long allocated_size;
unsigned long chunk_size;
}dbuf;
#define CHECK_STATS_BUCKETS 15
/* used for tracking host and service check statistics */
typedef struct check_stats_struct{
int current_bucket;
int bucket[CHECK_STATS_BUCKETS];
int overflow_bucket;
int minute_stats[3];
time_t last_update;
}check_stats;
/******************* THREAD STUFF ********************/
/* slots in circular buffers */
#define DEFAULT_EXTERNAL_COMMAND_BUFFER_SLOTS 4096
/* worker threads */
#define TOTAL_WORKER_THREADS 1
#define COMMAND_WORKER_THREAD 0
/******************** FUNCTIONS **********************/
/**** Configuration Functions ****/
int read_main_config_file(char *); /* reads the main config file (nagios.cfg) */
int read_resource_file(char *); /* processes macros in resource file */
int read_all_object_data(char *); /* reads all object config data */
/**** Setup Functions ****/
int pre_flight_check(void); /* try and verify the configuration data */
int pre_flight_object_check(int *,int *); /* verify object relationships and settings */
int pre_flight_circular_check(int *,int *); /* detects circular dependencies and paths */
void init_timing_loop(void); /* setup the initial scheduling queue */
void setup_sighandler(void); /* trap signals */
void reset_sighandler(void); /* reset signals to default action */
int daemon_init(void); /* switches to daemon mode */
int drop_privileges(char *,char *); /* drops privileges before startup */
void display_scheduling_info(void); /* displays service check scheduling information */
/**** Event Queue Functions ****/
int schedule_new_event(int,int,time_t,int,unsigned long,void *,int,void *,void *,int); /* schedules a new timed event */
void reschedule_event(timed_event *,timed_event **,timed_event **); /* reschedules an event */
void add_event(timed_event *,timed_event **,timed_event **); /* adds an event to the execution queue */
void remove_event(timed_event *,timed_event **,timed_event **); /* remove an event from the execution queue */
int event_execution_loop(void); /* main monitoring/event handler loop */
int handle_timed_event(timed_event *); /* top level handler for timed events */
void adjust_check_scheduling(void); /* auto-adjusts scheduling of host and service checks */
void compensate_for_system_time_change(unsigned long,unsigned long); /* attempts to compensate for a change in the system time */
void adjust_timestamp_for_time_change(time_t,time_t,unsigned long,time_t *); /* adjusts a timestamp variable for a system time change */
void resort_event_list(timed_event **,timed_event **); /* resorts event list by event run time for system time changes */
/**** IPC Functions ****/
int move_check_result_to_queue(char *);
int process_check_result_queue(char *);
int process_check_result_file(char *);
int add_check_result_to_list(check_result *);
check_result *read_check_result(void); /* reads a host/service check result from the list in memory */
int delete_check_result_file(char *);
int free_check_result_list(void);
int init_check_result(check_result *);
int free_check_result(check_result *); /* frees memory associated with a host/service check result */
int parse_check_output(char *,char **,char **,char **,int,int);
int open_command_file(void); /* creates the external command file as a named pipe (FIFO) and opens it for reading */
int close_command_file(void); /* closes and deletes the external command file (FIFO) */
/**** Monitoring/Event Handler Functions ****/
int check_service_dependencies(service *,int); /* checks service dependencies */
int check_host_dependencies(host *,int); /* checks host dependencies */
void check_for_orphaned_services(void); /* checks for orphaned services */
void check_for_orphaned_hosts(void); /* checks for orphaned hosts */
void check_service_result_freshness(void); /* checks the "freshness" of service check results */
int is_service_result_fresh(service *,time_t,int); /* determines if a service's check results are fresh */
void check_host_result_freshness(void); /* checks the "freshness" of host check results */
int is_host_result_fresh(host *,time_t,int); /* determines if a host's check results are fresh */
int my_system(char *,int,int *,double *,char **,int); /* executes a command via popen(), but also protects against timeouts */
/**** Flap Detection Functions ****/
void check_for_service_flapping(service *,int,int); /* determines whether or not a service is "flapping" between states */
void check_for_host_flapping(host *,int,int,int); /* determines whether or not a host is "flapping" between states */
void set_service_flap(service *,double,double,double,int); /* handles a service that is flapping */
void clear_service_flap(service *,double,double,double); /* handles a service that has stopped flapping */
void set_host_flap(host *,double,double,double,int); /* handles a host that is flapping */
void clear_host_flap(host *,double,double,double); /* handles a host that has stopped flapping */
void enable_flap_detection_routines(void); /* enables flap detection on a program-wide basis */
void disable_flap_detection_routines(void); /* disables flap detection on a program-wide basis */
void enable_host_flap_detection(host *); /* enables flap detection for a particular host */
void disable_host_flap_detection(host *); /* disables flap detection for a particular host */
void enable_service_flap_detection(service *); /* enables flap detection for a particular service */
void disable_service_flap_detection(service *); /* disables flap detection for a particular service */
void handle_host_flap_detection_disabled(host *); /* handles the details when flap detection is disabled globally or on a per-host basis */
void handle_service_flap_detection_disabled(service *); /* handles the details when flap detection is disabled globally or on a per-service basis */
/**** Route/Host Check Functions ****/
int perform_on_demand_host_check(host *,int *,int,int,unsigned long);
int perform_scheduled_host_check(host *,int,double);
int check_host_check_viability_3x(host *,int,int *,time_t *);
int adjust_host_check_attempt_3x(host *,int);
int determine_host_reachability(host *);
int process_host_check_result_3x(host *,int,char *,int,int,int,unsigned long);
int perform_on_demand_host_check_3x(host *,int *,int,int,unsigned long);
int run_sync_host_check_3x(host *,int *,int,int,unsigned long);
int execute_sync_host_check_3x(host *);
int run_scheduled_host_check_3x(host *,int,double);
int run_async_host_check_3x(host *,int,double,int,int,int *,time_t *);
int handle_async_host_check_result_3x(host *,check_result *);
/**** Service Check Functions ****/
int check_service_check_viability(service *,int,int *,time_t *);
int run_scheduled_service_check(service *,int,double);
int run_async_service_check(service *,int,double,int,int,int *,time_t *);
int handle_async_service_check_result(service *,check_result *);
/**** Event Handler Functions ****/
int handle_host_state(host *); /* top level host state handler */
/**** Common Check Fucntions *****/
int reap_check_results(void);
/**** Check Statistics Functions ****/
int init_check_stats(void);
int update_check_stats(int,time_t);
int generate_check_stats(void);
/**** Event Handler Functions ****/
int obsessive_compulsive_service_check_processor(service *); /* distributed monitoring craziness... */
int obsessive_compulsive_host_check_processor(host *); /* distributed monitoring craziness... */
int handle_service_event(service *); /* top level service event logic */
int run_service_event_handler(service *); /* runs the event handler for a specific service */
int run_global_service_event_handler(service *); /* runs the global service event handler */
int handle_host_event(host *); /* top level host event logic */
int run_host_event_handler(host *); /* runs the event handler for a specific host */
int run_global_host_event_handler(host *); /* runs the global host event handler */
/**** Notification Functions ****/
int check_service_notification_viability(service *,int,int); /* checks viability of notifying all contacts about a service */
int is_valid_escalation_for_service_notification(service *,serviceescalation *,int); /* checks if an escalation entry is valid for a particular service notification */
int should_service_notification_be_escalated(service *); /* checks if a service notification should be escalated */
int service_notification(service *,int,char *,char *,int); /* notify all contacts about a service (problem or recovery) */
int check_contact_service_notification_viability(contact *,service *,int,int); /* checks viability of notifying a contact about a service */
int notify_contact_of_service(contact *,service *,int,char *,char *,int,int); /* notify a single contact about a service */
int check_host_notification_viability(host *,int,int); /* checks viability of notifying all contacts about a host */
int is_valid_escalation_for_host_notification(host *,hostescalation *,int); /* checks if an escalation entry is valid for a particular host notification */
int should_host_notification_be_escalated(host *); /* checks if a host notification should be escalated */
int host_notification(host *,int,char *,char *,int); /* notify all contacts about a host (problem or recovery) */
int check_contact_host_notification_viability(contact *,host *,int,int); /* checks viability of notifying a contact about a host */
int notify_contact_of_host(contact *,host *,int,char *,char *,int,int); /* notify a single contact about a host */
int create_notification_list_from_host(host *,int,int *); /* given a host, create list of contacts to be notified (remove duplicates) */
int create_notification_list_from_service(service *,int,int *); /* given a service, create list of contacts to be notified (remove duplicates) */
int add_notification(contact *); /* adds a notification instance */
notification *find_notification(contact *); /* finds a notification object */
time_t get_next_host_notification_time(host *,time_t); /* calculates nex acceptable re-notification time for a host */
time_t get_next_service_notification_time(service *,time_t); /* calculates nex acceptable re-notification time for a service */
/**** Logging Functions ****/
void logit(int,int,const char *, ...)
__attribute__((__format__(__printf__, 3, 4)));
int write_to_logs_and_console(char *,unsigned long,int); /* writes a string to screen and logs */
int write_to_console(char *); /* writes a string to screen */
int write_to_all_logs(char *,unsigned long); /* writes a string to main log file and syslog facility */
int write_to_all_logs_with_timestamp(char *,unsigned long,time_t *); /* writes a string to main log file and syslog facility */
int write_to_log(char *,unsigned long,time_t *); /* write a string to the main log file */
int write_to_syslog(char *,unsigned long); /* write a string to the syslog facility */
int log_service_event(service *); /* logs a service event */
int log_host_event(host *); /* logs a host event */
int log_host_states(int,time_t *); /* logs initial/current host states */
int log_service_states(int,time_t *); /* logs initial/current service states */
int rotate_log_file(time_t); /* rotates the main log file */
int write_log_file_info(time_t *); /* records log file/version info */
int open_debug_log(void);
int log_debug_info(int,int,const char *,...)
__attribute__((__format__(__printf__, 3, 4)));
int close_debug_log(void);
/**** Cleanup Functions ****/
void cleanup(void); /* cleanup after ourselves (before quitting or restarting) */
void free_memory(void); /* free memory allocated to all linked lists in memory */
int reset_variables(void); /* reset all global variables */
void free_notification_list(void); /* frees all memory allocated to the notification list */
/**** Hash Functions ****/
int hashfunc(const char *name1, const char *name2, int hashslots);
int compare_hashdata(const char *,const char *,const char *,const char *);
/**** Miscellaneous Functions ****/
void sighandler(int); /* handles signals */
void service_check_sighandler(int); /* handles timeouts when executing service checks */
void host_check_sighandler(int); /* handles timeouts when executing host checks */
void my_system_sighandler(int); /* handles timeouts when executing commands via my_system() */
void file_lock_sighandler(int); /* handles timeouts while waiting for file locks */
void strip(char *); /* strips whitespace from string */
char *my_strtok(char *,char *); /* my replacement for strtok() function (doesn't skip consecutive tokens) */
char *my_strsep(char **,const char *); /* Solaris doesn't have strsep(), so I took this from the glibc source code */
#ifdef REMOVED_10182007
int my_free(void **); /* my wrapper for free() */
#endif
int compare_strings(char *,char *); /* compares two strings for equality */
char *escape_newlines(char *);
int contains_illegal_object_chars(char *); /* tests whether or not an object name (host, service, etc.) contains illegal characters */
int my_rename(char *,char *); /* renames a file - works across filesystems */
int my_fcopy(char *,char *); /* copies a file - works across filesystems */
int get_raw_command_line(command *,char *,char **,int); /* given a raw command line, determine the actual command to run */
int check_time_against_period(time_t,timeperiod *); /* check to see if a specific time is covered by a time period */
int is_daterange_single_day(daterange *);
time_t calculate_time_from_weekday_of_month(int,int,int,int); /* calculates midnight time of specific (3rd, last, etc.) weekday of a particular month */
time_t calculate_time_from_day_of_month(int,int,int); /* calculates midnight time of specific (1st, last, etc.) day of a particular month */
void get_next_valid_time(time_t, time_t *,timeperiod *); /* get the next valid time in a time period */
void get_datetime_string(time_t *,char *,int,int); /* get a date/time string for use in output */
void get_time_breakdown(unsigned long,int *,int *,int *, int *);
time_t get_next_log_rotation_time(void); /* determine the next time to schedule a log rotation */
int init_embedded_perl(char **); /* initialized embedded perl interpreter */
int deinit_embedded_perl(void); /* cleans up embedded perl */
int file_uses_embedded_perl(char *); /* tests whether or not the embedded perl interpreter should be used on a file */
int dbuf_init(dbuf *,int);
int dbuf_free(dbuf *);
int dbuf_strcat(dbuf *,char *);
int set_environment_var(char *,char *,int); /* sets/clears and environment variable */
/**** External Command Functions ****/
int check_for_external_commands(void); /* checks for any external commands */
int process_external_command1(char *); /* top-level external command processor */
int process_external_command2(int,time_t,char *); /* process an external command */
int process_external_commands_from_file(char *,int); /* process external commands in a file */
int process_host_command(int,time_t,char *); /* process an external host command */
int process_hostgroup_command(int,time_t,char *); /* process an external hostgroup command */
int process_service_command(int,time_t,char *); /* process an external service command */
int process_servicegroup_command(int,time_t,char *); /* process an external servicegroup command */
int process_contact_command(int,time_t,char *); /* process an external contact command */
int process_contactgroup_command(int,time_t,char *); /* process an external contactgroup command */
/**** External Command Implementations ****/
int cmd_add_comment(int,time_t,char *); /* add a service or host comment */
int cmd_delete_comment(int,char *); /* delete a service or host comment */
int cmd_delete_all_comments(int,char *); /* delete all comments associated with a host or service */
int cmd_delay_notification(int,char *); /* delay a service or host notification */
int cmd_schedule_service_check(int,char *,int); /* schedule an immediate or delayed service check */
int cmd_schedule_check(int,char *); /* schedule an immediate or delayed host check */
int cmd_schedule_host_service_checks(int,char *,int); /* schedule an immediate or delayed checks of all services on a host */
int cmd_signal_process(int,char *); /* schedules a program shutdown or restart */
int cmd_process_service_check_result(int,time_t,char *); /* processes a passive service check */
int cmd_process_host_check_result(int,time_t,char *); /* processes a passive host check */
int cmd_acknowledge_problem(int,char *); /* acknowledges a host or service problem */
int cmd_remove_acknowledgement(int,char *); /* removes a host or service acknowledgement */
int cmd_schedule_downtime(int,time_t,char *); /* schedules host or service downtime */
int cmd_delete_downtime(int,char *); /* cancels active/pending host or service scheduled downtime */
int cmd_change_object_int_var(int,char *); /* changes host/svc (int) variable */
int cmd_change_object_char_var(int,char *); /* changes host/svc (char) variable */
int cmd_change_object_custom_var(int,char *); /* changes host/svc custom variable */
int cmd_process_external_commands_from_file(int,char *); /* process external commands from a file */
int process_passive_service_check(time_t,char *,char *,int,char *);
int process_passive_host_check(time_t,char *,int,char *);
/**** Internal Command Implementations ****/
void disable_service_checks(service *); /* disables a service check */
void enable_service_checks(service *); /* enables a service check */
void schedule_service_check(service *,time_t,int); /* schedules an immediate or delayed service check */
void schedule_host_check(host *,time_t,int); /* schedules an immediate or delayed host check */
void enable_all_notifications(void); /* enables notifications on a program-wide basis */
void disable_all_notifications(void); /* disables notifications on a program-wide basis */
void enable_service_notifications(service *); /* enables service notifications */
void disable_service_notifications(service *); /* disables service notifications */
void enable_host_notifications(host *); /* enables host notifications */
void disable_host_notifications(host *); /* disables host notifications */
void enable_and_propagate_notifications(host *,int,int,int,int); /* enables notifications for all hosts and services beyond a given host */
void disable_and_propagate_notifications(host *,int,int,int,int); /* disables notifications for all hosts and services beyond a given host */
void schedule_and_propagate_downtime(host *,time_t,char *,char *,time_t,time_t,int,unsigned long,unsigned long); /* schedules downtime for all hosts beyond a given host */
void acknowledge_host_problem(host *,char *,char *,int,int,int); /* acknowledges a host problem */
void acknowledge_service_problem(service *,char *,char *,int,int,int); /* acknowledges a service problem */
void remove_host_acknowledgement(host *); /* removes a host acknowledgement */
void remove_service_acknowledgement(service *); /* removes a service acknowledgement */
void start_executing_service_checks(void); /* starts executing service checks */
void stop_executing_service_checks(void); /* stops executing service checks */
void start_accepting_passive_service_checks(void); /* starts accepting passive service check results */
void stop_accepting_passive_service_checks(void); /* stops accepting passive service check results */
void enable_passive_service_checks(service *); /* enables passive service checks for a particular service */
void disable_passive_service_checks(service *); /* disables passive service checks for a particular service */
void start_using_event_handlers(void); /* enables event handlers on a program-wide basis */
void stop_using_event_handlers(void); /* disables event handlers on a program-wide basis */
void enable_service_event_handler(service *); /* enables the event handler for a particular service */
void disable_service_event_handler(service *); /* disables the event handler for a particular service */
void enable_host_event_handler(host *); /* enables the event handler for a particular host */
void disable_host_event_handler(host *); /* disables the event handler for a particular host */
void enable_host_checks(host *); /* enables checks of a particular host */
void disable_host_checks(host *); /* disables checks of a particular host */
void start_obsessing_over_service_checks(void); /* start obsessing about service check results */
void stop_obsessing_over_service_checks(void); /* stop obsessing about service check results */
void start_obsessing_over_host_checks(void); /* start obsessing about host check results */
void stop_obsessing_over_host_checks(void); /* stop obsessing about host check results */
void enable_service_freshness_checks(void); /* enable service freshness checks */
void disable_service_freshness_checks(void); /* disable service freshness checks */
void enable_host_freshness_checks(void); /* enable host freshness checks */
void disable_host_freshness_checks(void); /* disable host freshness checks */
void process_passive_checks(void); /* processes passive host and service check results */
void enable_all_failure_prediction(void); /* enables failure prediction on a program-wide basis */
void disable_all_failure_prediction(void); /* disables failure prediction on a program-wide basis */
void enable_performance_data(void); /* enables processing of performance data on a program-wide basis */
void disable_performance_data(void); /* disables processing of performance data on a program-wide basis */
void start_executing_host_checks(void); /* starts executing host checks */
void stop_executing_host_checks(void); /* stops executing host checks */
void start_accepting_passive_host_checks(void); /* starts accepting passive host check results */
void stop_accepting_passive_host_checks(void); /* stops accepting passive host check results */
void enable_passive_host_checks(host *); /* enables passive host checks for a particular host */
void disable_passive_host_checks(host *); /* disables passive host checks for a particular host */
void start_obsessing_over_service(service *); /* start obsessing about specific service check results */
void stop_obsessing_over_service(service *); /* stop obsessing about specific service check results */
void start_obsessing_over_host(host *); /* start obsessing about specific host check results */
void stop_obsessing_over_host(host *); /* stop obsessing about specific host check results */
void set_host_notification_number(host *,int); /* sets current notification number for a specific host */
void set_service_notification_number(service *,int); /* sets current notification number for a specific service */
void enable_contact_host_notifications(contact *); /* enables host notifications for a specific contact */
void disable_contact_host_notifications(contact *); /* disables host notifications for a specific contact */
void enable_contact_service_notifications(contact *); /* enables service notifications for a specific contact */
void disable_contact_service_notifications(contact *); /* disables service notifications for a specific contact */
int init_check_result_worker_thread(void);
int shutdown_check_result_worker_thread(void);
void * check_result_worker_thread(void *);
void cleanup_check_result_worker_thread(void *);
int init_command_file_worker_thread(void);
int shutdown_command_file_worker_thread(void);
void * command_file_worker_thread(void *);
void cleanup_command_file_worker_thread(void *);
int submit_external_command(char *,int *);
int submit_raw_external_command(char *,time_t *,int *);
char *get_program_version(void);
char *get_program_modification_date(void);
mmapfile *mmap_fopen(char *); /* open a file read-only via mmap() */
int mmap_fclose(mmapfile *);
char *mmap_fgets(mmapfile *);
char *mmap_fgets_multiline(mmapfile *);
#ifdef __cplusplus
}
#endif
#endif

88
include/nebcallbacks.h Normal file
View File

@ -0,0 +1,88 @@
/*****************************************************************************
*
* NEBCALLBACKS.H - Include file for event broker modules
*
* Copyright (c) 2002-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 01-06-2007
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef _NEBCALLBACKS_H
#define _NEBCALLBACKS_H
#include "config.h"
#include "nebmodules.h"
#ifdef __cplusplus
extern "C" {
#endif
/***** CALLBACK TYPES *****/
#define NEBCALLBACK_NUMITEMS 33 /* total number of callback types we have */
#define NEBCALLBACK_RESERVED0 0 /* reserved for future use */
#define NEBCALLBACK_RESERVED1 1
#define NEBCALLBACK_RESERVED2 2
#define NEBCALLBACK_RESERVED3 3
#define NEBCALLBACK_RESERVED4 4
#define NEBCALLBACK_RAW_DATA 5
#define NEBCALLBACK_NEB_DATA 6
#define NEBCALLBACK_PROCESS_DATA 7
#define NEBCALLBACK_TIMED_EVENT_DATA 8
#define NEBCALLBACK_LOG_DATA 9
#define NEBCALLBACK_SYSTEM_COMMAND_DATA 10
#define NEBCALLBACK_EVENT_HANDLER_DATA 11
#define NEBCALLBACK_NOTIFICATION_DATA 12
#define NEBCALLBACK_SERVICE_CHECK_DATA 13
#define NEBCALLBACK_HOST_CHECK_DATA 14
#define NEBCALLBACK_COMMENT_DATA 15
#define NEBCALLBACK_DOWNTIME_DATA 16
#define NEBCALLBACK_FLAPPING_DATA 17
#define NEBCALLBACK_PROGRAM_STATUS_DATA 18
#define NEBCALLBACK_HOST_STATUS_DATA 19
#define NEBCALLBACK_SERVICE_STATUS_DATA 20
#define NEBCALLBACK_ADAPTIVE_PROGRAM_DATA 21
#define NEBCALLBACK_ADAPTIVE_HOST_DATA 22
#define NEBCALLBACK_ADAPTIVE_SERVICE_DATA 23
#define NEBCALLBACK_EXTERNAL_COMMAND_DATA 24
#define NEBCALLBACK_AGGREGATED_STATUS_DATA 25
#define NEBCALLBACK_RETENTION_DATA 26
#define NEBCALLBACK_CONTACT_NOTIFICATION_DATA 27
#define NEBCALLBACK_CONTACT_NOTIFICATION_METHOD_DATA 28
#define NEBCALLBACK_ACKNOWLEDGEMENT_DATA 29
#define NEBCALLBACK_STATE_CHANGE_DATA 30
#define NEBCALLBACK_CONTACT_STATUS_DATA 31
#define NEBCALLBACK_ADAPTIVE_CONTACT_DATA 32
/***** CALLBACK FUNCTIONS *****/
int neb_register_callback(int callback_type, void *mod_handle, int priority, int (*callback_func)(int,void *));
int neb_deregister_callback(int callback_type, int (*callback_func)(int,void *));
int neb_deregister_module_callbacks(nebmodule *);
#ifdef __cplusplus
}
#endif
#endif

102
include/nebmodules.h Normal file
View File

@ -0,0 +1,102 @@
/*****************************************************************************
*
* NEBMODULES.H - Include file for event broker modules
*
* Copyright (c) 2002-2006 Ethan Galstad (nagios@nagios.org)
* Last Modified: 02-27-2006
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef _NEBMODULES_H
#define _NEBMODULES_H
#ifdef __cplusplus
extern "C" {
#endif
/***** MODULE VERSION INFORMATION *****/
#define NEB_API_VERSION(x) int __neb_api_version = x;
#define CURRENT_NEB_API_VERSION 3
/***** MODULE INFORMATION *****/
#define NEBMODULE_MODINFO_NUMITEMS 6
#define NEBMODULE_MODINFO_TITLE 0
#define NEBMODULE_MODINFO_AUTHOR 1
#define NEBMODULE_MODINFO_COPYRIGHT 2
#define NEBMODULE_MODINFO_VERSION 3
#define NEBMODULE_MODINFO_LICENSE 4
#define NEBMODULE_MODINFO_DESC 5
/***** MODULE LOAD/UNLOAD OPTIONS *****/
#define NEBMODULE_NORMAL_LOAD 0 /* module is being loaded normally */
#define NEBMODULE_REQUEST_UNLOAD 0 /* request module to unload (but don't force it) */
#define NEBMODULE_FORCE_UNLOAD 1 /* force module to unload */
/***** MODULES UNLOAD REASONS *****/
#define NEBMODULE_NEB_SHUTDOWN 1 /* event broker is shutting down */
#define NEBMODULE_NEB_RESTART 2 /* event broker is restarting */
#define NEBMODULE_ERROR_NO_INIT 3 /* _module_init() function was not found in module */
#define NEBMODULE_ERROR_BAD_INIT 4 /* _module_init() function returned a bad code */
#define NEBMODULE_ERROR_API_VERSION 5 /* module version is incompatible with current api */
/***** MODULE STRUCTURES *****/
/* NEB module structure */
typedef struct nebmodule_struct{
char *filename;
char *args;
char *info[NEBMODULE_MODINFO_NUMITEMS];
int should_be_loaded;
int is_currently_loaded;
#ifdef USE_LTDL
lt_dlhandle module_handle;
lt_ptr init_func;
lt_ptr deinit_func;
#else
void *module_handle;
void *init_func;
void *deinit_func;
#endif
#ifdef HAVE_PTHREAD_H
pthread_t thread_id;
#endif
struct nebmodule_struct *next;
}nebmodule;
/***** MODULE FUNCTIONS *****/
int neb_set_module_info(void *,int,char *);
#ifdef __cplusplus
}
#endif
#endif

533
include/nebstructs.h Normal file
View File

@ -0,0 +1,533 @@
/*****************************************************************************
*
* NEBSTRUCTS.H - Event broker includes for Nagios
*
* Copyright (c) 2003-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 10-28-2007
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef _NEBSTRUCTS_H
#define _NEBSTRUCTS_H
#include "config.h"
#include "pnp.h"
#include "objects.h"
#include "nagios.h"
#ifdef __cplusplus
extern "C" {
#endif
/****** STRUCTURES *************************/
/* process data structure */
typedef struct nebstruct_process_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
}nebstruct_process_data;
/* timed event data structure */
typedef struct nebstruct_timed_event_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int event_type;
int recurring;
time_t run_time;
void *event_data;
void *event_ptr;
}nebstruct_timed_event_data;
/* log data structure */
typedef struct nebstruct_log_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
time_t entry_time;
int data_type;
char *data;
}nebstruct_log_data;
/* system command structure */
typedef struct nebstruct_system_command_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
struct timeval start_time;
struct timeval end_time;
int timeout;
char *command_line;
int early_timeout;
double execution_time;
int return_code;
char *output;
}nebstruct_system_command_data;
/* event handler structure */
typedef struct nebstruct_event_handler_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int eventhandler_type;
char *host_name;
char *service_description;
int state_type;
int state;
int timeout;
char *command_name;
char *command_args;
char *command_line;
struct timeval start_time;
struct timeval end_time;
int early_timeout;
double execution_time;
int return_code;
char *output;
void *object_ptr;
}nebstruct_event_handler_data;
/* host check structure */
typedef struct nebstruct_host_check_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
char *host_name;
int current_attempt;
int check_type;
int max_attempts;
int state_type;
int state;
int timeout;
char *command_name;
char *command_args;
char *command_line;
struct timeval start_time;
struct timeval end_time;
int early_timeout;
double execution_time;
double latency;
int return_code;
char *output;
char *long_output;
char *perf_data;
void *object_ptr;
}nebstruct_host_check_data;
/* service check structure */
typedef struct nebstruct_service_check_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
char *host_name;
char *service_description;
int check_type;
int current_attempt;
int max_attempts;
int state_type;
int state;
int timeout;
char *command_name;
char *command_args;
char *command_line;
struct timeval start_time;
struct timeval end_time;
int early_timeout;
double execution_time;
double latency;
int return_code;
char *output;
char *long_output;
char *perf_data;
void *object_ptr;
}nebstruct_service_check_data;
/* comment data structure */
typedef struct nebstruct_comment_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int comment_type;
char *host_name;
char *service_description;
time_t entry_time;
char *author_name;
char *comment_data;
int persistent;
int source;
int entry_type;
int expires;
time_t expire_time;
unsigned long comment_id;
void *object_ptr; /* not implemented yet */
}nebstruct_comment_data;
/* downtime data structure */
typedef struct nebstruct_downtime_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int downtime_type;
char *host_name;
char *service_description;
time_t entry_time;
char *author_name;
char *comment_data;
time_t start_time;
time_t end_time;
int fixed;
unsigned long duration;
unsigned long triggered_by;
unsigned long downtime_id;
void *object_ptr; /* not implemented yet */
}nebstruct_downtime_data;
/* flapping data structure */
typedef struct nebstruct_flapping_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int flapping_type;
char *host_name;
char *service_description;
double percent_change;
double high_threshold;
double low_threshold;
unsigned long comment_id;
void *object_ptr;
}nebstruct_flapping_data;
/* program status structure */
typedef struct nebstruct_program_status_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
time_t program_start;
int pid;
int daemon_mode;
time_t last_command_check;
time_t last_log_rotation;
int notifications_enabled;
int active_service_checks_enabled;
int passive_service_checks_enabled;
int active_host_checks_enabled;
int passive_host_checks_enabled;
int event_handlers_enabled;
int flap_detection_enabled;
int failure_prediction_enabled;
int process_performance_data;
int obsess_over_hosts;
int obsess_over_services;
unsigned long modified_host_attributes;
unsigned long modified_service_attributes;
char *global_host_event_handler;
char *global_service_event_handler;
}nebstruct_program_status_data;
/* host status structure */
typedef struct nebstruct_host_status_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
void *object_ptr;
}nebstruct_host_status_data;
/* service status structure */
typedef struct nebstruct_service_status_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
void *object_ptr;
}nebstruct_service_status_data;
/* contact status structure */
typedef struct nebstruct_contact_status_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
void *object_ptr;
}nebstruct_contact_status_data;
/* notification data structure */
typedef struct nebstruct_notification_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int notification_type;
struct timeval start_time;
struct timeval end_time;
char *host_name;
char *service_description;
int reason_type;
int state;
char *output;
char *ack_author;
char *ack_data;
int escalated;
int contacts_notified;
void *object_ptr;
}nebstruct_notification_data;
/* contact notification data structure */
typedef struct nebstruct_contact_notification_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int notification_type;
struct timeval start_time;
struct timeval end_time;
char *host_name;
char *service_description;
char *contact_name;
int reason_type;
int state;
char *output;
char *ack_author;
char *ack_data;
int escalated;
void *object_ptr;
void *contact_ptr;
}nebstruct_contact_notification_data;
/* contact notification method data structure */
typedef struct nebstruct_contact_notification_method_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int notification_type;
struct timeval start_time;
struct timeval end_time;
char *host_name;
char *service_description;
char *contact_name;
char *command_name;
char *command_args;
int reason_type;
int state;
char *output;
char *ack_author;
char *ack_data;
int escalated;
void *object_ptr;
void *contact_ptr;
}nebstruct_contact_notification_method_data;
/* adaptive program data structure */
typedef struct nebstruct_adaptive_program_data_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int command_type;
unsigned long modified_host_attribute;
unsigned long modified_host_attributes;
unsigned long modified_service_attribute;
unsigned long modified_service_attributes;
}nebstruct_adaptive_program_data;
/* adaptive host data structure */
typedef struct nebstruct_adaptive_host_data_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int command_type;
unsigned long modified_attribute;
unsigned long modified_attributes;
void *object_ptr;
}nebstruct_adaptive_host_data;
/* adaptive service data structure */
typedef struct nebstruct_adaptive_service_data_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int command_type;
unsigned long modified_attribute;
unsigned long modified_attributes;
void *object_ptr;
}nebstruct_adaptive_service_data;
/* adaptive contact data structure */
typedef struct nebstruct_adaptive_contact_data_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int command_type;
unsigned long modified_attribute;
unsigned long modified_attributes;
unsigned long modified_host_attribute;
unsigned long modified_host_attributes;
unsigned long modified_service_attribute;
unsigned long modified_service_attributes;
void *object_ptr;
}nebstruct_adaptive_contact_data;
/* external command data structure */
typedef struct nebstruct_external_command_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int command_type;
time_t entry_time;
char *command_string;
char *command_args;
}nebstruct_external_command_data;
/* aggregated status data structure */
typedef struct nebstruct_aggregated_status_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
}nebstruct_aggregated_status_data;
/* retention data structure */
typedef struct nebstruct_retention_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
}nebstruct_retention_data;
/* acknowledgement structure */
typedef struct nebstruct_acknowledgement_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int acknowledgement_type;
char *host_name;
char *service_description;
int state;
char *author_name;
char *comment_data;
int is_sticky;
int persistent_comment;
int notify_contacts;
void *object_ptr;
}nebstruct_acknowledgement_data;
/* state change structure */
typedef struct nebstruct_statechange_struct{
int type;
int flags;
int attr;
struct timeval timestamp;
int statechange_type;
char *host_name;
char *service_description;
int state;
int state_type;
int current_attempt;
int max_attempts;
char *output;
void *object_ptr;
}nebstruct_statechange_data;
#ifdef __cplusplus
}
#endif
#endif

41
include/npcdmod.h Normal file
View File

@ -0,0 +1,41 @@
/*****************************************************************************
*
* NPCDMOD.H
*
* Copyright (c) 2008 Hendrik Baecker (http://www.pnp4nagios.org)
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Last Modified: 11-18-2008
*
*****************************************************************************/
#define PERFDATA_BUFFER 65536
/* MMAPFILE structure - used for reading files via mmap() */
typedef struct pnp_mmapfile_struct {
char *path;
int mode;
int fd;
unsigned long file_size;
unsigned long current_position;
unsigned long current_line;
void *mmap_buf;
} pnp_mmapfile;
pnp_mmapfile *pnp_mmap_fopen(char *); /* open a file read-only via mmap() */
int pnp_mmap_fclose(pnp_mmapfile *);
char *pnp_mmap_fgets(pnp_mmapfile *);
char *pnp_mmap_fgets_multiline(pnp_mmapfile *);
extern void pnp_strip(char *);

771
include/objects.h Normal file
View File

@ -0,0 +1,771 @@
/*****************************************************************************
*
* OBJECTS.H - Header file for object addition/search functions
*
* Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
* Last Modified: 11-10-2007
*
* License:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*****************************************************************************/
#ifndef _OBJECTS_H
#define _OBJECTS_H
#include "config.h"
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
/*************** CURRENT OBJECT REVISION **************/
#define CURRENT_OBJECT_STRUCTURE_VERSION 307 /* increment when changes are made to data structures... */
/* Nagios 3 starts at 300, Nagios 4 at 400, etc. */
/***************** OBJECT SIZE LIMITS *****************/
#define MAX_STATE_HISTORY_ENTRIES 21 /* max number of old states to keep track of for flap detection */
#define MAX_CONTACT_ADDRESSES 6 /* max number of custom addresses a contact can have */
/***************** SKIP LISTS ****************/
#define NUM_OBJECT_SKIPLISTS 13
#define HOST_SKIPLIST 1
#define SERVICE_SKIPLIST 2
#define COMMAND_SKIPLIST 3
#define TIMEPERIOD_SKIPLIST 4
#define CONTACT_SKIPLIST 5
#define CONTACTGROUP_SKIPLIST 6
#define HOSTGROUP_SKIPLIST 7
#define SERVICEGROUP_SKIPLIST 8
#define HOSTDEPENDENCY_SKIPLIST 9
#define SERVICEDEPENDENCY_SKIPLIST 10
#define HOSTESCALATION_SKIPLIST 11
#define SERVICEESCALATION_SKIPLIST 12
/****************** DATA STRUCTURES *******************/
typedef struct host_struct host;
typedef struct service_struct service;
typedef struct contact_struct contact;
/* OBJECT LIST STRUCTURE */
typedef struct objectlist_struct{
void *object_ptr;
struct objectlist_struct *next;
}objectlist;
/* TIMERANGE structure */
typedef struct timerange_struct{
unsigned long range_start;
unsigned long range_end;
struct timerange_struct *next;
}timerange;
/* DATERANGE structure */
typedef struct daterange_struct{
int type;
int syear; /* start year */
int smon; /* start month */
int smday; /* start day of month (may 3rd, last day in feb) */
int swday; /* start day of week (thursday) */
int swday_offset; /* start weekday offset (3rd thursday, last monday in jan) */
int eyear;
int emon;
int emday;
int ewday;
int ewday_offset;
int skip_interval;
timerange *times;
struct daterange_struct *next;
}daterange;
/* TIMEPERIODEXCLUSION structure */
typedef struct timeperiodexclusion_struct{
char *timeperiod_name;
struct timeperiod_struct *timeperiod_ptr;
struct timeperiodexclusion_struct *next;
}timeperiodexclusion;
/* TIMEPERIOD structure */
typedef struct timeperiod_struct{
char *name;
char *alias;
timerange *days[7];
daterange *exceptions[DATERANGE_TYPES];
timeperiodexclusion *exclusions;
struct timeperiod_struct *next;
struct timeperiod_struct *nexthash;
}timeperiod;
/* CONTACTSMEMBER structure */
typedef struct contactsmember_struct{
char *contact_name;
#ifdef NSCORE
contact *contact_ptr;
#endif
struct contactsmember_struct *next;
}contactsmember;
/* CONTACTGROUP structure */
typedef struct contactgroup_struct{
char *group_name;
char *alias;
contactsmember *members;
struct contactgroup_struct *next;
struct contactgroup_struct *nexthash;
}contactgroup;
/* CONTACTGROUPSMEMBER structure */
typedef struct contactgroupsmember_struct{
char *group_name;
#ifdef NSCORE
contactgroup *group_ptr;
#endif
struct contactgroupsmember_struct *next;
}contactgroupsmember;
/* CUSTOMVARIABLESMEMBER structure */
typedef struct customvariablesmember_struct{
char *variable_name;
char *variable_value;
int has_been_modified;
struct customvariablesmember_struct *next;
}customvariablesmember;
/* COMMAND structure */
typedef struct command_struct{
char *name;
char *command_line;
struct command_struct *next;
struct command_struct *nexthash;
}command;
/* COMMANDSMEMBER structure */
typedef struct commandsmember_struct{
char *command;
#ifdef NSCORE
command *command_ptr;
#endif
struct commandsmember_struct *next;
}commandsmember;
/* CONTACT structure */
struct contact_struct{
char *name;
char *alias;
char *email;
char *pager;
char *address[MAX_CONTACT_ADDRESSES];
commandsmember *host_notification_commands;
commandsmember *service_notification_commands;
int notify_on_service_unknown;
int notify_on_service_warning;
int notify_on_service_critical;
int notify_on_service_recovery;
int notify_on_service_flapping;
int notify_on_service_downtime;
int notify_on_host_down;
int notify_on_host_unreachable;
int notify_on_host_recovery;
int notify_on_host_flapping;
int notify_on_host_downtime;
char *host_notification_period;
char *service_notification_period;
int host_notifications_enabled;
int service_notifications_enabled;
int can_submit_commands;
int retain_status_information;
int retain_nonstatus_information;
customvariablesmember *custom_variables;
#ifdef NSCORE
time_t last_host_notification;
time_t last_service_notification;
unsigned long modified_attributes;
unsigned long modified_host_attributes;
unsigned long modified_service_attributes;
timeperiod *host_notification_period_ptr;
timeperiod *service_notification_period_ptr;
objectlist *contactgroups_ptr;
#endif
struct contact_struct *next;
struct contact_struct *nexthash;
};
/* SERVICESMEMBER structure */
typedef struct servicesmember_struct{
char *host_name;
char *service_description;
#ifdef NSCORE
service *service_ptr;
#endif
struct servicesmember_struct *next;
}servicesmember;
/* HOSTSMEMBER structure */
typedef struct hostsmember_struct{
char *host_name;
#ifdef NSCORE
host *host_ptr;
#endif
struct hostsmember_struct *next;
}hostsmember;
/* HOSTGROUP structure */
typedef struct hostgroup_struct{
char *group_name;
char *alias;
hostsmember *members;
char *notes;
char *notes_url;
char *action_url;
struct hostgroup_struct *next;
struct hostgroup_struct *nexthash;
}hostgroup;
/* HOST structure */
struct host_struct{
char *name;
char *display_name;
char *alias;
char *address;
hostsmember *parent_hosts;
hostsmember *child_hosts;
servicesmember *services;
char *host_check_command;
int initial_state;
double check_interval;
double retry_interval;
int max_attempts;
char *event_handler;
contactgroupsmember *contact_groups;
contactsmember *contacts;
double notification_interval;
double first_notification_delay;
int notify_on_down;
int notify_on_unreachable;
int notify_on_recovery;
int notify_on_flapping;
int notify_on_downtime;
char *notification_period;
char *check_period;
int flap_detection_enabled;
double low_flap_threshold;
double high_flap_threshold;
int flap_detection_on_up;
int flap_detection_on_down;
int flap_detection_on_unreachable;
int stalk_on_up;
int stalk_on_down;
int stalk_on_unreachable;
int check_freshness;
int freshness_threshold;
int process_performance_data;
int checks_enabled;
int accept_passive_host_checks;
int event_handler_enabled;
int retain_status_information;
int retain_nonstatus_information;
int failure_prediction_enabled;
char *failure_prediction_options;
int obsess_over_host;
char *notes;
char *notes_url;
char *action_url;
char *icon_image;
char *icon_image_alt;
char *vrml_image;
char *statusmap_image;
int have_2d_coords;
int x_2d;
int y_2d;
int have_3d_coords;
double x_3d;
double y_3d;
double z_3d;
int should_be_drawn;
customvariablesmember *custom_variables;
#ifdef NSCORE
int problem_has_been_acknowledged;
int acknowledgement_type;
int check_type;
int current_state;
int last_state;
int last_hard_state;
char *plugin_output;
char *long_plugin_output;
char *perf_data;
int state_type;
int current_attempt;
unsigned long current_event_id;
unsigned long last_event_id;
unsigned long current_problem_id;
unsigned long last_problem_id;
double latency;
double execution_time;
int is_executing;
int check_options;
int notifications_enabled;
time_t last_host_notification;
time_t next_host_notification;
time_t next_check;
int should_be_scheduled;
time_t last_check;
time_t last_state_change;
time_t last_hard_state_change;
time_t last_time_up;
time_t last_time_down;
time_t last_time_unreachable;
int has_been_checked;
int is_being_freshened;
int notified_on_down;
int notified_on_unreachable;
int current_notification_number;
int no_more_notifications;
unsigned long current_notification_id;
int check_flapping_recovery_notification;
int scheduled_downtime_depth;
int pending_flex_downtime;
int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */
int state_history_index;
time_t last_state_history_update;
int is_flapping;
unsigned long flapping_comment_id;
double percent_state_change;
int total_services;
unsigned long total_service_check_interval;
unsigned long modified_attributes;
int circular_path_checked;
int contains_circular_path;
command *event_handler_ptr;
command *check_command_ptr;
timeperiod *check_period_ptr;
timeperiod *notification_period_ptr;
objectlist *hostgroups_ptr;
#endif
struct host_struct *next;
struct host_struct *nexthash;
};
/* SERVICEGROUP structure */
typedef struct servicegroup_struct{
char *group_name;
char *alias;
servicesmember *members;
char *notes;
char *notes_url;
char *action_url;
struct servicegroup_struct *next;
struct servicegroup_struct *nexthash;
}servicegroup;
/* SERVICE structure */
struct service_struct{
char *host_name;
char *description;
char *display_name;
char *service_check_command;
char *event_handler;
int initial_state;
double check_interval;
double retry_interval;
int max_attempts;
int parallelize;
contactgroupsmember *contact_groups;
contactsmember *contacts;
double notification_interval;
double first_notification_delay;
int notify_on_unknown;
int notify_on_warning;
int notify_on_critical;
int notify_on_recovery;
int notify_on_flapping;
int notify_on_downtime;
int stalk_on_ok;
int stalk_on_warning;
int stalk_on_unknown;
int stalk_on_critical;
int is_volatile;
char *notification_period;
char *check_period;
int flap_detection_enabled;
double low_flap_threshold;
double high_flap_threshold;
int flap_detection_on_ok;
int flap_detection_on_warning;
int flap_detection_on_unknown;
int flap_detection_on_critical;
int process_performance_data;
int check_freshness;
int freshness_threshold;
int accept_passive_service_checks;
int event_handler_enabled;
int checks_enabled;
int retain_status_information;
int retain_nonstatus_information;
int notifications_enabled;
int obsess_over_service;
int failure_prediction_enabled;
char *failure_prediction_options;
char *notes;
char *notes_url;
char *action_url;
char *icon_image;
char *icon_image_alt;
customvariablesmember *custom_variables;
#ifdef NSCORE
int problem_has_been_acknowledged;
int acknowledgement_type;
int host_problem_at_last_check;
int check_type;
int current_state;
int last_state;
int last_hard_state;
char *plugin_output;
char *long_plugin_output;
char *perf_data;
int state_type;
time_t next_check;
int should_be_scheduled;
time_t last_check;
int current_attempt;
unsigned long current_event_id;
unsigned long last_event_id;
unsigned long current_problem_id;
unsigned long last_problem_id;
time_t last_notification;
time_t next_notification;
int no_more_notifications;
int check_flapping_recovery_notification;
time_t last_state_change;
time_t last_hard_state_change;
time_t last_time_ok;
time_t last_time_warning;
time_t last_time_unknown;
time_t last_time_critical;
int has_been_checked;
int is_being_freshened;
int notified_on_unknown;
int notified_on_warning;
int notified_on_critical;
int current_notification_number;
unsigned long current_notification_id;
double latency;
double execution_time;
int is_executing;
int check_options;
int scheduled_downtime_depth;
int pending_flex_downtime;
int state_history[MAX_STATE_HISTORY_ENTRIES]; /* flap detection */
int state_history_index;
int is_flapping;
unsigned long flapping_comment_id;
double percent_state_change;
unsigned long modified_attributes;
host *host_ptr;
command *event_handler_ptr;
char *event_handler_args;
command *check_command_ptr;
char *check_command_args;
timeperiod *check_period_ptr;
timeperiod *notification_period_ptr;
objectlist *servicegroups_ptr;
#endif
struct service_struct *next;
struct service_struct *nexthash;
};
/* SERVICE ESCALATION structure */
typedef struct serviceescalation_struct{
char *host_name;
char *description;
int first_notification;
int last_notification;
double notification_interval;
char *escalation_period;
int escalate_on_recovery;
int escalate_on_warning;
int escalate_on_unknown;
int escalate_on_critical;
contactgroupsmember *contact_groups;
contactsmember *contacts;
#ifdef NSCORE
service *service_ptr;
timeperiod *escalation_period_ptr;
#endif
struct serviceescalation_struct *next;
struct serviceescalation_struct *nexthash;
}serviceescalation;
/* SERVICE DEPENDENCY structure */
typedef struct servicedependency_struct{
int dependency_type;
char *dependent_host_name;
char *dependent_service_description;
char *host_name;
char *service_description;
char *dependency_period;
int inherits_parent;
int fail_on_ok;
int fail_on_warning;
int fail_on_unknown;
int fail_on_critical;
int fail_on_pending;
#ifdef NSCORE
int circular_path_checked;
int contains_circular_path;
service *master_service_ptr;
service *dependent_service_ptr;
timeperiod *dependency_period_ptr;
#endif
struct servicedependency_struct *next;
struct servicedependency_struct *nexthash;
}servicedependency;
/* HOST ESCALATION structure */
typedef struct hostescalation_struct{
char *host_name;
int first_notification;
int last_notification;
double notification_interval;
char *escalation_period;
int escalate_on_recovery;
int escalate_on_down;
int escalate_on_unreachable;
contactgroupsmember *contact_groups;
contactsmember *contacts;
#ifdef NSCORE
host *host_ptr;
timeperiod *escalation_period_ptr;
#endif
struct hostescalation_struct *next;
struct hostescalation_struct *nexthash;
}hostescalation;
/* HOST DEPENDENCY structure */
typedef struct hostdependency_struct{
int dependency_type;
char *dependent_host_name;
char *host_name;
char *dependency_period;
int inherits_parent;
int fail_on_up;
int fail_on_down;
int fail_on_unreachable;
int fail_on_pending;
#ifdef NSCORE
int circular_path_checked;
int contains_circular_path;
host *master_host_ptr;
host *dependent_host_ptr;
timeperiod *dependency_period_ptr;
#endif
struct hostdependency_struct *next;
struct hostdependency_struct *nexthash;
}hostdependency;
/****************** HASH STRUCTURES ********************/
typedef struct host_cursor_struct{
int host_hashchain_iterator;
host *current_host_pointer;
}host_cursor;
/********************* FUNCTIONS **********************/
/**** Top-level input functions ****/
int read_object_config_data(char *,int,int,int); /* reads all external configuration data of specific types */
/**** Object Creation Functions ****/
contact *add_contact(char *,char *,char *,char *,char **,char *,char *,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int,int); /* adds a contact definition */
commandsmember *add_service_notification_command_to_contact(contact *,char *); /* adds a service notification command to a contact definition */
commandsmember *add_host_notification_command_to_contact(contact *,char *); /* adds a host notification command to a contact definition */
customvariablesmember *add_custom_variable_to_contact(contact *,char *,char *); /* adds a custom variable to a service definition */
host *add_host(char *,char *,char *,char *,char *,int,double,double,int,int,int,int,int,int,double,double,char *,int,char *,int,int,char *,int,int,double,double,int,int,int,int,int,int,int,int,char *,int,int,char *,char *,char *,char *,char *,char *,char *,int,int,int,double,double,double,int,int,int,int,int); /* adds a host definition */
hostsmember *add_parent_host_to_host(host *,char *); /* adds a parent host to a host definition */
hostsmember *add_child_link_to_host(host *,host *); /* adds a child host to a host definition */
contactgroupsmember *add_contactgroup_to_host(host *,char *); /* adds a contactgroup to a host definition */
contactsmember *add_contact_to_host(host *,char *); /* adds a contact to a host definition */
customvariablesmember *add_custom_variable_to_host(host *,char *,char *); /* adds a custom variable to a host definition */
timeperiod *add_timeperiod(char *,char *); /* adds a timeperiod definition */
timeperiodexclusion *add_exclusion_to_timeperiod(timeperiod *,char *); /* adds an exclusion to a timeperiod */
timerange *add_timerange_to_timeperiod(timeperiod *,int,unsigned long,unsigned long); /* adds a timerange to a timeperiod definition */
daterange *add_exception_to_timeperiod(timeperiod *,int,int,int,int,int,int,int,int,int,int,int,int);
timerange *add_timerange_to_daterange(daterange *,unsigned long,unsigned long);
hostgroup *add_hostgroup(char *,char *,char *,char *,char *); /* adds a hostgroup definition */
hostsmember *add_host_to_hostgroup(hostgroup *, char *); /* adds a host to a hostgroup definition */
servicegroup *add_servicegroup(char *,char *,char *,char *,char *); /* adds a servicegroup definition */
servicesmember *add_service_to_servicegroup(servicegroup *,char *,char *); /* adds a service to a servicegroup definition */
contactgroup *add_contactgroup(char *,char *); /* adds a contactgroup definition */
contactsmember *add_contact_to_contactgroup(contactgroup *,char *); /* adds a contact to a contact group definition */
command *add_command(char *,char *); /* adds a command definition */
service *add_service(char *,char *,char *,char *,int,int,int,int,double,double,double,double,char *,int,int,int,int,int,int,int,int,char *,int,char *,int,int,double,double,int,int,int,int,int,int,int,int,int,int,char *,int,int,char *,char *,char *,char *,char *,int,int,int); /* adds a service definition */
contactgroupsmember *add_contactgroup_to_service(service *,char *); /* adds a contact group to a service definition */
contactsmember *add_contact_to_service(service *,char *); /* adds a contact to a host definition */
serviceescalation *add_serviceescalation(char *,char *,int,int,double,char *,int,int,int,int); /* adds a service escalation definition */
contactgroupsmember *add_contactgroup_to_serviceescalation(serviceescalation *,char *); /* adds a contact group to a service escalation definition */
contactsmember *add_contact_to_serviceescalation(serviceescalation *,char *); /* adds a contact to a service escalation definition */
customvariablesmember *add_custom_variable_to_service(service *,char *,char *); /* adds a custom variable to a service definition */
servicedependency *add_service_dependency(char *,char *,char *,char *,int,int,int,int,int,int,int,char *); /* adds a service dependency definition */
hostdependency *add_host_dependency(char *,char *,int,int,int,int,int,int,char *); /* adds a host dependency definition */
hostescalation *add_hostescalation(char *,int,int,double,char *,int,int,int); /* adds a host escalation definition */
contactsmember *add_contact_to_hostescalation(hostescalation *,char *); /* adds a contact to a host escalation definition */
contactgroupsmember *add_contactgroup_to_hostescalation(hostescalation *,char *); /* adds a contact group to a host escalation definition */
contactsmember *add_contact_to_object(contactsmember **,char *); /* adds a contact to an object */
customvariablesmember *add_custom_variable_to_object(customvariablesmember **,char *,char *); /* adds a custom variable to an object */
servicesmember *add_service_link_to_host(host *,service *);
/*** Object Skiplist Functions ****/
int init_object_skiplists(void);
int free_object_skiplists(void);
int skiplist_compare_text(const char *val1a, const char *val1b, const char *val2a, const char *val2b);
int skiplist_compare_host(void *a, void *b);
int skiplist_compare_service(void *a, void *b);
int skiplist_compare_command(void *a, void *b);
int skiplist_compare_timeperiod(void *a, void *b);
int skiplist_compare_contact(void *a, void *b);
int skiplist_compare_contactgroup(void *a, void *b);
int skiplist_compare_hostgroup(void *a, void *b);
int skiplist_compare_servicegroup(void *a, void *b);
int skiplist_compare_hostescalation(void *a, void *b);
int skiplist_compare_serviceescalation(void *a, void *b);
int skiplist_compare_hostdependency(void *a, void *b);
int skiplist_compare_servicedependency(void *a, void *b);
int get_host_count(void);
int get_service_count(void);
/**** Object Hash Functions ****/
int add_servicedependency_to_hashlist(servicedependency *);
/**** Object Search Functions ****/
timeperiod * find_timeperiod(char *); /* finds a timeperiod object */
host * find_host(char *); /* finds a host object */
hostgroup * find_hostgroup(char *); /* finds a hostgroup object */
servicegroup * find_servicegroup(char *); /* finds a servicegroup object */
contact * find_contact(char *); /* finds a contact object */
contactgroup * find_contactgroup(char *); /* finds a contactgroup object */
command * find_command(char *); /* finds a command object */
service * find_service(char *,char *); /* finds a service object */
/**** Object Traversal Functions ****/
hostescalation *get_first_hostescalation_by_host(char *, void **);
hostescalation *get_next_hostescalation_by_host(char *,void **);
serviceescalation *get_first_serviceescalation_by_service(char *,char *, void **);
serviceescalation *get_next_serviceescalation_by_service(char *,char *,void **);
hostdependency *get_first_hostdependency_by_dependent_host(char *, void **);
hostdependency *get_next_hostdependency_by_dependent_host(char *, void **);
servicedependency *get_first_servicedependency_by_dependent_service(char *,char *, void **);
servicedependency *get_next_servicedependency_by_dependent_service(char *,char *,void **);
#ifdef NSCORE
int add_object_to_objectlist(objectlist **,void *);
int free_objectlist(objectlist **);
#endif
/**** Object Query Functions ****/
int is_host_immediate_child_of_host(host *,host *); /* checks if a host is an immediate child of another host */
int is_host_primary_immediate_child_of_host(host *,host *); /* checks if a host is an immediate child (and primary child) of another host */
int is_host_immediate_parent_of_host(host *,host *); /* checks if a host is an immediate child of another host */
int is_host_member_of_hostgroup(hostgroup *,host *); /* tests whether or not a host is a member of a specific hostgroup */
int is_host_member_of_servicegroup(servicegroup *,host *); /* tests whether or not a service is a member of a specific servicegroup */
int is_service_member_of_servicegroup(servicegroup *,service *); /* tests whether or not a service is a member of a specific servicegroup */
int is_contact_member_of_contactgroup(contactgroup *, contact *); /* tests whether or not a contact is a member of a specific contact group */
int is_contact_for_hostgroup(hostgroup *,contact *); /* tests whether or not a contact is a member of a specific hostgroup */
int is_contact_for_servicegroup(servicegroup *,contact *); /* tests whether or not a contact is a member of a specific servicegroup */
int is_contact_for_host(host *,contact *); /* tests whether or not a contact is a contact member for a specific host */
int is_escalated_contact_for_host(host *,contact *); /* checks whether or not a contact is an escalated contact for a specific host */
int is_contact_for_service(service *,contact *); /* tests whether or not a contact is a contact member for a specific service */
int is_escalated_contact_for_service(service *,contact *); /* checks whether or not a contact is an escalated contact for a specific service */
int is_host_immediate_parent_of_host(host *,host *); /* tests whether or not a host is an immediate parent of another host */
int number_of_immediate_child_hosts(host *); /* counts the number of immediate child hosts for a particular host */
int number_of_total_child_hosts(host *); /* counts the number of total child hosts for a particular host */
int number_of_immediate_parent_hosts(host *); /* counts the number of immediate parents hosts for a particular host */
int number_of_total_parent_hosts(host *); /* counts the number of total parents hosts for a particular host */
#ifdef NSCORE
int check_for_circular_host_path(host *,host *); /* checks if a circular path exists for a given host */
int check_for_circular_servicedependency_path(servicedependency *,servicedependency *,int); /* checks if a circular dependency exists for a given service */
int check_for_circular_hostdependency_path(hostdependency *,hostdependency *,int); /* checks if a circular dependency exists for a given host */
#endif
/**** Object Cleanup Functions ****/
int free_object_data(void); /* frees all allocated memory for the object definitions */
#ifdef __cplusplus
}
#endif
#endif

126
include/pnp.h Normal file
View File

@ -0,0 +1,126 @@
/* #include "../include/global.h" */
/*************************************
* General Header Files
*************************************/
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
/*************************************
Default defines
**************************************/
extern int do_log(char*);
#define LOG(level, msg) (loglevel >= level || loglevel == -1) ? (do_log(msg)) : (0)
#define TRUE 1
#define FALSE 0
#define OK 0
#define ERROR -2
#define MAX_FILENAME_LENGTH 256
#define MAX_VARIABLE_LENGTH 256
#define MAX_VALUE_LENGTH 256
#define MAX_COMMANDLINE_LENGTH 512
#define MAX_BUFFER_SIZE 1024
#define MAX_LOGMESSAGE_SIZE 768
#define CONFIG_OPT_COUNT 15
#define CONFIG_OPT_LOGTYPE 0
#define CONFIG_OPT_LOGFILE 1
#define CONFIG_OPT_LOGFILESIZE 2
#define CONFIG_OPT_LOGLEVEL 3
#define CONFIG_OPT_SCANDIR 4
#define CONFIG_OPT_RUNCMD 5
#define CONFIG_OPT_RUNCMD_ARG 6
#define CONFIG_OPT_MAXTHREADS 7
#define CONFIG_OPT_USER 8
#define CONFIG_OPT_GROUP 9
#define CONFIG_OPT_PIDFILE 10
#define CONFIG_OPT_USELOAD 11
#define CONFIG_OPT_LOAD 12
#define CONFIG_OPT_SLEEPTIME 13
#define CONFIG_OPT_IDENTMYSELF 14

323
install-sh Executable file
View File

@ -0,0 +1,323 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2005-05-14.22
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

305
lib/Makefile.in Normal file
View File

@ -0,0 +1,305 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
LOGDIR=@localstatedir@
CFGDIR=@sysconfdir@
BINDIR=@bindir@
CGIDIR=@sbindir@
LIBDIR=@libdir@
INSTALL=@INSTALL@
INSTALL_OPTS=@INSTALL_OPTS@
DATAROOTDIR=@datarootdir@
CP=@CP@
all html:
clean:
distclean: clean
-rm -f Makefile
devclean: distclean
install:
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/controllers
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/helpers
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Image
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Session
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/config
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/core
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/views
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/views/pagination
$(INSTALL) -m 755 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBDIR)/kohana/system/fonts
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/controllers/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/controllers/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/controllers/template.php $(DESTDIR)$(LIBDIR)/kohana/system/controllers/template.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/de_DE/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/de_DE/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/nl_NL/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/nl_NL/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/es_ES/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/es_ES/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/ru_RU/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/ru_RU/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/en_US/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/en_US/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/fr_FR/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/fr_FR/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/validation.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/core.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/core.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/orm.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/orm.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/image.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/session.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/database.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/event.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/errors.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/errors.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/i18n/it_IT/swift.php $(DESTDIR)$(LIBDIR)/kohana/system/i18n/it_IT/swift.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/remote.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/remote.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/url.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/url.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/feed.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/feed.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/expires.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/expires.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/text.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/text.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/email.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/email.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/download.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/download.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/format.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/format.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/form.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/form.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/arr.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/arr.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/html.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/html.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/valid.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/valid.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/date.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/date.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/file.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/file.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/request.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/request.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/cookie.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/cookie.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/security.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/security.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/num.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/num.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/helpers/inflector.php $(DESTDIR)$(LIBDIR)/kohana/system/helpers/inflector.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/ORM_Tree.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/ORM_Tree.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Encrypt.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Encrypt.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Database_Expression.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Database_Expression.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Event_Observer.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Event_Observer.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Event_Subject.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Event_Subject.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Cache.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Session.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database/Mssql.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database/Mssql.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database/Pdosqlite.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database/Pdosqlite.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database/Mysqli.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database/Mysqli.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database/Pgsql.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database/Pgsql.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database/Mysql.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database/Mysql.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Alpha.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Alpha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Math.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Math.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Word.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Word.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Riddle.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Riddle.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Basic.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Basic.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha/Black.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha/Black.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Session.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Image.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/Eaccelerator.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/Eaccelerator.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/Apc.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/Apc.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/Memcache.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/Memcache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/Xcache.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/Xcache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/File.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/File.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Cache/Sqlite.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Cache/Sqlite.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Image/GraphicsMagick.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Image/GraphicsMagick.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Image/GD.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Image/GD.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Image/ImageMagick.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Image/ImageMagick.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Session/Cookie.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Session/Cookie.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Session/Cache.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Session/Cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Session/Database.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Session/Database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/drivers/Database.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/drivers/Database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Image.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Validation.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Validation.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/ORM_Versioned.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/ORM_Versioned.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Controller.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Controller.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Model.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Model.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/View.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/View.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Router.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Router.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/ORM_Iterator.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/ORM_Iterator.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Profiler_Table.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Profiler_Table.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/URI.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/URI.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/ORM.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/ORM.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Calendar_Event.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Calendar_Event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Tagcloud.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Tagcloud.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Input.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Input.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/libraries/Database.php $(DESTDIR)$(LIBDIR)/kohana/system/libraries/Database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/locale.php $(DESTDIR)$(LIBDIR)/kohana/system/config/locale.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/routes.php $(DESTDIR)$(LIBDIR)/kohana/system/config/routes.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/pagination.php $(DESTDIR)$(LIBDIR)/kohana/system/config/pagination.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/sql_types.php $(DESTDIR)$(LIBDIR)/kohana/system/config/sql_types.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/captcha.php $(DESTDIR)$(LIBDIR)/kohana/system/config/captcha.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/email.php $(DESTDIR)$(LIBDIR)/kohana/system/config/email.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/image.php $(DESTDIR)$(LIBDIR)/kohana/system/config/image.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/cache_sqlite.php $(DESTDIR)$(LIBDIR)/kohana/system/config/cache_sqlite.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/cache_memcache.php $(DESTDIR)$(LIBDIR)/kohana/system/config/cache_memcache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/session.php $(DESTDIR)$(LIBDIR)/kohana/system/config/session.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/database.php $(DESTDIR)$(LIBDIR)/kohana/system/config/database.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/credit_cards.php $(DESTDIR)$(LIBDIR)/kohana/system/config/credit_cards.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/http.php $(DESTDIR)$(LIBDIR)/kohana/system/config/http.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/mimes.php $(DESTDIR)$(LIBDIR)/kohana/system/config/mimes.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/config/profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/view.php $(DESTDIR)$(LIBDIR)/kohana/system/config/view.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/cache.php $(DESTDIR)$(LIBDIR)/kohana/system/config/cache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/encryption.php $(DESTDIR)$(LIBDIR)/kohana/system/config/encryption.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/upload.php $(DESTDIR)$(LIBDIR)/kohana/system/config/upload.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/cookie.php $(DESTDIR)$(LIBDIR)/kohana/system/config/cookie.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/user_agents.php $(DESTDIR)$(LIBDIR)/kohana/system/config/user_agents.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/inflector.php $(DESTDIR)$(LIBDIR)/kohana/system/config/inflector.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/config/cache_xcache.php $(DESTDIR)$(LIBDIR)/kohana/system/config/cache_xcache.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/Event.php $(DESTDIR)$(LIBDIR)/kohana/system/core/Event.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/transliterate_to_ascii.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/transliterate_to_ascii.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/ucfirst.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/ucfirst.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/ord.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/ord.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strrpos.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strrpos.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strtolower.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strtolower.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/substr.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/substr.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/str_pad.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/str_pad.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strcspn.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strcspn.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/trim.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/trim.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/rtrim.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/rtrim.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strcasecmp.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strcasecmp.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strtoupper.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strtoupper.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/str_split.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/str_split.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strpos.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strpos.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/stristr.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/stristr.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/ucwords.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/ucwords.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/str_ireplace.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/str_ireplace.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strlen.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strlen.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/to_unicode.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/to_unicode.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/substr_replace.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/substr_replace.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/from_unicode.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/from_unicode.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strrev.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strrev.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/strspn.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/strspn.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8/ltrim.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8/ltrim.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/Benchmark.php $(DESTDIR)$(LIBDIR)/kohana/system/core/Benchmark.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/Bootstrap.php $(DESTDIR)$(LIBDIR)/kohana/system/core/Bootstrap.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/Kohana.php $(DESTDIR)$(LIBDIR)/kohana/system/core/Kohana.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/core/utf8.php $(DESTDIR)$(LIBDIR)/kohana/system/core/utf8.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_profiler_table.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_profiler_table.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana/template.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana/template.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_error_page.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_error_page.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_calendar.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_calendar.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/pagination/digg.php $(DESTDIR)$(LIBDIR)/kohana/system/views/pagination/digg.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/pagination/punbb.php $(DESTDIR)$(LIBDIR)/kohana/system/views/pagination/punbb.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/pagination/extended.php $(DESTDIR)$(LIBDIR)/kohana/system/views/pagination/extended.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/pagination/classic.php $(DESTDIR)$(LIBDIR)/kohana/system/views/pagination/classic.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_profiler_table.css $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_profiler_table.css
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_profiler.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_profiler.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_error_disabled.php $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_error_disabled.php
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/views/kohana_errors.css $(DESTDIR)$(LIBDIR)/kohana/system/views/kohana_errors.css
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/fonts/LICENSE $(DESTDIR)$(LIBDIR)/kohana/system/fonts/LICENSE
$(INSTALL) -m 644 $(INSTALL_OPTS) kohana/system/fonts/DejaVuSerif.ttf $(DESTDIR)$(LIBDIR)/kohana/system/fonts/DejaVuSerif.ttf

View File

@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Cache
*
* Cache settings, defined as arrays, or "groups". If no group name is
* used when loading the cache library, the group named "default" will be used.
*
* Each group can be used independently, and multiple groups can be used at once.
*
* Group Options:
* driver - Cache backend driver. Kohana comes with file, database, and memcache drivers.
* > File cache is fast and reliable, but requires many filesystem lookups.
* > Database cache can be used to cache items remotely, but is slower.
* > Memcache is very high performance, but prevents cache tags from being used.
*
* params - Driver parameters, specific to each driver.
*
* lifetime - Default lifetime of caches in seconds. By default caches are stored for
* thirty minutes. Specific lifetime can also be set when creating a new cache.
* Setting this to 0 will never automatically delete caches.
*
* requests - Average number of cache requests that will processed before all expired
* caches are deleted. This is commonly referred to as "garbage collection".
* Setting this to 0 or a negative number will disable automatic garbage collection.
*/
$config['default'] = array
(
'driver' => 'file',
'params' => APPPATH.'cache',
'lifetime' => 1800,
'requests' => 1000
);

View File

@ -0,0 +1,20 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Cache:Memcache
*
* memcache server configuration.
*/
$config['servers'] = array
(
array
(
'host' => '127.0.0.1',
'port' => 11211,
'persistent' => FALSE,
)
);
/**
* Enable cache data compression.
*/
$config['compression'] = FALSE;

View File

@ -0,0 +1,10 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Cache:SQLite
*/
$config['schema'] =
'CREATE TABLE caches(
id VARCHAR(127) PRIMARY KEY,
tags VARCHAR(255),
expiration INTEGER,
cache TEXT);';

View File

@ -0,0 +1,12 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Cache:Xcache
*
* Xcache administrator username.
*/
$config['PHP_AUTH_USER'] = 'kohana';
/**
* Xcache administrator password.
*/
$config['PHP_AUTH_PW'] = 'kohana';

View File

@ -0,0 +1,29 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Captcha configuration is defined in groups which allows you to easily switch
* between different Captcha settings for different forms on your website.
* Note: all groups inherit and overwrite the default group.
*
* Group Options:
* style - Captcha type, e.g. basic, alpha, word, math, riddle
* width - Width of the Captcha image
* height - Height of the Captcha image
* complexity - Difficulty level (0-10), usage depends on chosen style
* background - Path to background image file
* fontpath - Path to font folder
* fonts - Font files
* promote - Valid response count threshold to promote user (FALSE to disable)
*/
$config['default'] = array
(
'style' => 'basic',
'width' => 150,
'height' => 50,
'complexity' => 4,
'background' => '',
'fontpath' => SYSPATH.'fonts/',
'fonts' => array('DejaVuSerif.ttf'),
'promote' => FALSE,
);

View File

@ -0,0 +1,32 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Domain, to restrict the cookie to a specific website domain. For security,
* you are encouraged to set this option. An empty setting allows the cookie
* to be read by any website domain.
*/
$config['domain'] = '';
/**
* Restrict cookies to a specific path, typically the installation directory.
*/
$config['path'] = '/';
/**
* Lifetime of the cookie. A setting of 0 makes the cookie active until the
* users browser is closed or the cookie is deleted.
*/
$config['expire'] = 0;
/**
* Enable this option to only allow the cookie to be read when using the a
* secure protocol.
*/
$config['secure'] = FALSE;
/**
* Enable this option to disable the cookie from being accessed when using a
* secure protocol. This option is only available in PHP 5.2 and above.
*/
$config['httponly'] = FALSE;

View File

@ -0,0 +1,60 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Credit card validation configuration.
*
* Options for each credit card:
* length - All the allowed card number lengths, in a comma separated string
* prefix - The digits the card needs to start with, in regex format
* luhn - Enable or disable card number validation by the Luhn algorithm
*/
$config = array
(
'default' => array
(
'length' => '13,14,15,16,17,18,19',
'prefix' => '',
'luhn' => TRUE
),
'american express' => array
(
'length' => '15',
'prefix' => '3[47]',
'luhn' => TRUE
),
'diners club' => array
(
'length' => '14,16',
'prefix' => '36|55|30[0-5]',
'luhn' => TRUE
),
'discover' => array
(
'length' => '16',
'prefix' => '6(?:5|011)',
'luhn' => TRUE,
),
'jcb' => array
(
'length' => '15,16',
'prefix' => '3|1800|2131',
'luhn' => TRUE
),
'maestro' => array
(
'length' => '16,18',
'prefix' => '50(?:20|38)|6(?:304|759)',
'luhn' => TRUE
),
'mastercard' => array
(
'length' => '16',
'prefix' => '5[1-5]',
'luhn' => TRUE
),
'visa' => array
(
'length' => '13,16',
'prefix' => '4',
'luhn' => TRUE
),
);

View File

@ -0,0 +1,45 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Database
*
* Database connection settings, defined as arrays, or "groups". If no group
* name is used when loading the database library, the group named "default"
* will be used.
*
* Each group can be connected to independently, and multiple groups can be
* connected at once.
*
* Group Options:
* benchmark - Enable or disable database benchmarking
* persistent - Enable or disable a persistent connection
* connection - Array of connection specific parameters; alternatively,
* you can use a DSN though it is not as fast and certain
* characters could create problems (like an '@' character
* in a password):
* 'connection' => 'mysql://dbuser:secret@localhost/kohana'
* character_set - Database character set
* table_prefix - Database table prefix
* object - Enable or disable object results
* cache - Enable or disable query caching
* escape - Enable automatic query builder escaping
*/
$config['default'] = array
(
'benchmark' => TRUE,
'persistent' => FALSE,
'connection' => array
(
'type' => 'mysql',
'user' => 'dbuser',
'pass' => 'p@ssw0rd',
'host' => 'localhost',
'port' => FALSE,
'socket' => FALSE,
'database' => 'kohana'
),
'character_set' => 'utf8',
'table_prefix' => '',
'object' => TRUE,
'cache' => FALSE,
'escape' => TRUE
);

View File

@ -0,0 +1,22 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* SwiftMailer driver, used with the email helper.
*
* @see http://www.swiftmailer.org/wikidocs/v3/connections/nativemail
* @see http://www.swiftmailer.org/wikidocs/v3/connections/sendmail
* @see http://www.swiftmailer.org/wikidocs/v3/connections/smtp
*
* Valid drivers are: native, sendmail, smtp
*/
$config['driver'] = 'native';
/**
* To use secure connections with SMTP, set "port" to 465 instead of 25.
* To enable TLS, set "encryption" to "tls".
*
* Driver options:
* @param null native: no options
* @param string sendmail: executable path, with -bs or equivalent attached
* @param array smtp: hostname, (username), (password), (port), (auth), (encryption)
*/
$config['options'] = NULL;

View File

@ -0,0 +1,31 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Encrypt
*
* Encrypt configuration is defined in groups which allows you to easily switch
* between different encryption settings for different uses.
* Note: all groups inherit and overwrite the default group.
*
* Group Options:
* key - Encryption key used to do encryption and decryption. The default option
* should never be used for a production website.
*
* For best security, your encryption key should be at least 16 characters
* long and contain letters, numbers, and symbols.
* @note Do not use a hash as your key. This significantly lowers encryption entropy.
*
* mode - MCrypt encryption mode. By default, MCRYPT_MODE_NOFB is used. This mode
* offers initialization vector support, is suited to short strings, and
* produces the shortest encrypted output.
* @see http://php.net/mcrypt
*
* cipher - MCrypt encryption cipher. By default, the MCRYPT_RIJNDAEL_128 cipher is used.
* This is also known as 128-bit AES.
* @see http://php.net/mcrypt
*/
$config['default'] = array
(
'key' => 'K0H@NA+PHP_7hE-SW!FtFraM3w0R|<',
'mode' => MCRYPT_MODE_NOFB,
'cipher' => MCRYPT_RIJNDAEL_128
);

View File

@ -0,0 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
// HTTP-EQUIV type meta tags
$config['meta_equiv'] = array
(
'cache-control',
'content-type', 'content-script-type', 'content-style-type',
'content-disposition',
'content-language',
'default-style',
'expires',
'ext-cache',
'pics-label',
'pragma',
'refresh',
'set-cookie',
'vary',
'window-target',
);

View File

@ -0,0 +1,13 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Image
*
* Driver name. Default: GD
*/
$config['driver'] = 'GD';
/**
* Driver parameters:
* ImageMagick - set the "directory" parameter to your ImageMagick installation directory
*/
$config['params'] = array();

View File

@ -0,0 +1,58 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
$config['uncountable'] = array
(
'access',
'advice',
'art',
'baggage',
'dances',
'equipment',
'fish',
'fuel',
'furniture',
'food',
'heat',
'honey',
'homework',
'impatience',
'information',
'knowledge',
'luggage',
'money',
'music',
'news',
'patience',
'progress',
'pollution',
'research',
'rice',
'sand',
'series',
'sheep',
'sms',
'species',
'staff',
'toothpaste',
'traffic',
'understanding',
'water',
'weather',
'work',
);
$config['irregular'] = array
(
'child' => 'children',
'clothes' => 'clothing',
'man' => 'men',
'movie' => 'movies',
'person' => 'people',
'woman' => 'women',
'mouse' => 'mice',
'goose' => 'geese',
'ox' => 'oxen',
'leaf' => 'leaves',
'course' => 'courses',
'size' => 'sizes',
);

View File

@ -0,0 +1,16 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Default language locale name(s).
* First item must be a valid i18n directory name, subsequent items are alternative locales
* for OS's that don't support the first (e.g. Windows). The first valid locale in the array will be used.
* @see http://php.net/setlocale
*/
$config['language'] = array('en_US', 'English_United States');
/**
* Locale timezone. Defaults to use the server timezone.
* @see http://php.net/timezones
*/
$config['timezone'] = '';

View File

@ -0,0 +1,224 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* A list of mime types. Our list is generally more complete and accurate than
* the operating system MIME list.
*
* If there are any missing options, please create a ticket on our issue tracker,
* http://kohanaphp.com/trac/newticket. Be sure to give the filename and
* expected MIME type, as well as any additional information you can provide.
*/
$config = array
(
'323' => array('text/h323'),
'7z' => array('application/x-7z-compressed'),
'abw' => array('application/x-abiword'),
'acx' => array('application/internet-property-stream'),
'ai' => array('application/postscript'),
'aif' => array('audio/x-aiff'),
'aifc' => array('audio/x-aiff'),
'aiff' => array('audio/x-aiff'),
'asf' => array('video/x-ms-asf'),
'asr' => array('video/x-ms-asf'),
'asx' => array('video/x-ms-asf'),
'atom' => array('application/atom+xml'),
'avi' => array('video/avi', 'video/msvideo', 'video/x-msvideo'),
'bin' => array('application/octet-stream','application/macbinary'),
'bmp' => array('image/bmp'),
'c' => array('text/x-csrc'),
'c++' => array('text/x-c++src'),
'cab' => array('application/x-cab'),
'cc' => array('text/x-c++src'),
'cda' => array('application/x-cdf'),
'class' => array('application/octet-stream'),
'cpp' => array('text/x-c++src'),
'cpt' => array('application/mac-compactpro'),
'csh' => array('text/x-csh'),
'css' => array('text/css'),
'csv' => array('text/x-comma-separated-values', 'application/vnd.ms-excel', 'text/comma-separated-values', 'text/csv'),
'dbk' => array('application/docbook+xml'),
'dcr' => array('application/x-director'),
'deb' => array('application/x-debian-package'),
'diff' => array('text/x-diff'),
'dir' => array('application/x-director'),
'divx' => array('video/divx'),
'dll' => array('application/octet-stream', 'application/x-msdos-program'),
'dmg' => array('application/x-apple-diskimage'),
'dms' => array('application/octet-stream'),
'doc' => array('application/msword'),
'dvi' => array('application/x-dvi'),
'dxr' => array('application/x-director'),
'eml' => array('message/rfc822'),
'eps' => array('application/postscript'),
'evy' => array('application/envoy'),
'exe' => array('application/x-msdos-program', 'application/octet-stream'),
'fla' => array('application/octet-stream'),
'flac' => array('application/x-flac'),
'flc' => array('video/flc'),
'fli' => array('video/fli'),
'flv' => array('video/x-flv'),
'gif' => array('image/gif'),
'gtar' => array('application/x-gtar'),
'gz' => array('application/x-gzip'),
'h' => array('text/x-chdr'),
'h++' => array('text/x-c++hdr'),
'hh' => array('text/x-c++hdr'),
'hpp' => array('text/x-c++hdr'),
'hqx' => array('application/mac-binhex40'),
'hs' => array('text/x-haskell'),
'htm' => array('text/html'),
'html' => array('text/html'),
'ico' => array('image/x-icon'),
'ics' => array('text/calendar'),
'iii' => array('application/x-iphone'),
'ins' => array('application/x-internet-signup'),
'iso' => array('application/x-iso9660-image'),
'isp' => array('application/x-internet-signup'),
'jar' => array('application/java-archive'),
'java' => array('application/x-java-applet'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'js' => array('application/x-javascript'),
'json' => array('application/json'),
'latex' => array('application/x-latex'),
'lha' => array('application/octet-stream'),
'log' => array('text/plain', 'text/x-log'),
'lzh' => array('application/octet-stream'),
'm4a' => array('audio/mpeg'),
'm4p' => array('video/mp4v-es'),
'm4v' => array('video/mp4'),
'man' => array('application/x-troff-man'),
'mdb' => array('application/x-msaccess'),
'midi' => array('audio/midi'),
'mid' => array('audio/midi'),
'mif' => array('application/vnd.mif'),
'mka' => array('audio/x-matroska'),
'mkv' => array('video/x-matroska'),
'mov' => array('video/quicktime'),
'movie' => array('video/x-sgi-movie'),
'mp2' => array('audio/mpeg'),
'mp3' => array('audio/mpeg'),
'mp4' => array('application/mp4','audio/mp4','video/mp4'),
'mpa' => array('video/mpeg'),
'mpe' => array('video/mpeg'),
'mpeg' => array('video/mpeg'),
'mpg' => array('video/mpeg'),
'mpg4' => array('video/mp4'),
'mpga' => array('audio/mpeg'),
'mpp' => array('application/vnd.ms-project'),
'mpv' => array('video/x-matroska'),
'mpv2' => array('video/mpeg'),
'ms' => array('application/x-troff-ms'),
'msg' => array('application/msoutlook','application/x-msg'),
'msi' => array('application/x-msi'),
'nws' => array('message/rfc822'),
'oda' => array('application/oda'),
'odb' => array('application/vnd.oasis.opendocument.database'),
'odc' => array('application/vnd.oasis.opendocument.chart'),
'odf' => array('application/vnd.oasis.opendocument.forumla'),
'odg' => array('application/vnd.oasis.opendocument.graphics'),
'odi' => array('application/vnd.oasis.opendocument.image'),
'odm' => array('application/vnd.oasis.opendocument.text-master'),
'odp' => array('application/vnd.oasis.opendocument.presentation'),
'ods' => array('application/vnd.oasis.opendocument.spreadsheet'),
'odt' => array('application/vnd.oasis.opendocument.text'),
'oga' => array('audio/ogg'),
'ogg' => array('application/ogg'),
'ogv' => array('video/ogg'),
'otg' => array('application/vnd.oasis.opendocument.graphics-template'),
'oth' => array('application/vnd.oasis.opendocument.web'),
'otp' => array('application/vnd.oasis.opendocument.presentation-template'),
'ots' => array('application/vnd.oasis.opendocument.spreadsheet-template'),
'ott' => array('application/vnd.oasis.opendocument.template'),
'p' => array('text/x-pascal'),
'pas' => array('text/x-pascal'),
'patch' => array('text/x-diff'),
'pbm' => array('image/x-portable-bitmap'),
'pdf' => array('application/pdf', 'application/x-download'),
'php' => array('application/x-httpd-php'),
'php3' => array('application/x-httpd-php'),
'php4' => array('application/x-httpd-php'),
'php5' => array('application/x-httpd-php'),
'phps' => array('application/x-httpd-php-source'),
'phtml' => array('application/x-httpd-php'),
'pl' => array('text/x-perl'),
'pm' => array('text/x-perl'),
'png' => array('image/png', 'image/x-png'),
'po' => array('text/x-gettext-translation'),
'pot' => array('application/vnd.ms-powerpoint'),
'pps' => array('application/vnd.ms-powerpoint'),
'ppt' => array('application/powerpoint'),
'ps' => array('application/postscript'),
'psd' => array('application/x-photoshop', 'image/x-photoshop'),
'pub' => array('application/x-mspublisher'),
'py' => array('text/x-python'),
'qt' => array('video/quicktime'),
'ra' => array('audio/x-realaudio'),
'ram' => array('audio/x-realaudio', 'audio/x-pn-realaudio'),
'rar' => array('application/rar'),
'rgb' => array('image/x-rgb'),
'rm' => array('audio/x-pn-realaudio'),
'rpm' => array('audio/x-pn-realaudio-plugin', 'application/x-redhat-package-manager'),
'rss' => array('application/rss+xml'),
'rtf' => array('text/rtf'),
'rtx' => array('text/richtext'),
'rv' => array('video/vnd.rn-realvideo'),
'sea' => array('application/octet-stream'),
'sh' => array('text/x-sh'),
'shtml' => array('text/html'),
'sit' => array('application/x-stuffit'),
'smi' => array('application/smil'),
'smil' => array('application/smil'),
'so' => array('application/octet-stream'),
'src' => array('application/x-wais-source'),
'svg' => array('image/svg+xml'),
'swf' => array('application/x-shockwave-flash'),
't' => array('application/x-troff'),
'tar' => array('application/x-tar'),
'tcl' => array('text/x-tcl'),
'tex' => array('application/x-tex'),
'text' => array('text/plain'),
'texti' => array('application/x-texinfo'),
'textinfo' => array('application/x-texinfo'),
'tgz' => array('application/x-tar'),
'tif' => array('image/tiff'),
'tiff' => array('image/tiff'),
'torrent' => array('application/x-bittorrent'),
'tr' => array('application/x-troff'),
'tsv' => array('text/tab-separated-values'),
'txt' => array('text/plain'),
'wav' => array('audio/x-wav'),
'wax' => array('audio/x-ms-wax'),
'wbxml' => array('application/wbxml'),
'wm' => array('video/x-ms-wm'),
'wma' => array('audio/x-ms-wma'),
'wmd' => array('application/x-ms-wmd'),
'wmlc' => array('application/wmlc'),
'wmv' => array('video/x-ms-wmv', 'application/octet-stream'),
'wmx' => array('video/x-ms-wmx'),
'wmz' => array('application/x-ms-wmz'),
'word' => array('application/msword', 'application/octet-stream'),
'wp5' => array('application/wordperfect5.1'),
'wpd' => array('application/vnd.wordperfect'),
'wvx' => array('video/x-ms-wvx'),
'xbm' => array('image/x-xbitmap'),
'xcf' => array('image/xcf'),
'xhtml' => array('application/xhtml+xml'),
'xht' => array('application/xhtml+xml'),
'xl' => array('application/excel', 'application/vnd.ms-excel'),
'xla' => array('application/excel', 'application/vnd.ms-excel'),
'xlc' => array('application/excel', 'application/vnd.ms-excel'),
'xlm' => array('application/excel', 'application/vnd.ms-excel'),
'xls' => array('application/excel', 'application/vnd.ms-excel'),
'xlt' => array('application/excel', 'application/vnd.ms-excel'),
'xml' => array('text/xml'),
'xof' => array('x-world/x-vrml'),
'xpm' => array('image/x-xpixmap'),
'xsl' => array('text/xml'),
'xvid' => array('video/x-xvid'),
'xwd' => array('image/x-xwindowdump'),
'z' => array('application/x-compress'),
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed')
);

View File

@ -0,0 +1,25 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Pagination
*
* Pagination configuration is defined in groups which allows you to easily switch
* between different pagination settings for different website sections.
* Note: all groups inherit and overwrite the default group.
*
* Group Options:
* directory - Views folder in which your pagination style templates reside
* style - Pagination style template (matches view filename)
* uri_segment - URI segment (int or 'label') in which the current page number can be found
* query_string - Alternative to uri_segment: query string key that contains the page number
* items_per_page - Number of items to display per page
* auto_hide - Automatically hides pagination for single pages
*/
$config['default'] = array
(
'directory' => 'pagination',
'style' => 'classic',
'uri_segment' => 3,
'query_string' => '',
'items_per_page' => 20,
'auto_hide' => FALSE,
);

View File

@ -0,0 +1,8 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Profiler
*
* Array of section names to display in the Profiler, TRUE to display all of them.
* Built in sections are benchmarks, database, session, post and cookies, custom sections can be used too.
*/
$config['show'] = TRUE;

View File

@ -0,0 +1,7 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Sets the default route to "welcome"
*/
$config['_default'] = 'welcome';

View File

@ -0,0 +1,47 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Session
*
* Session driver name.
*/
$config['driver'] = 'cookie';
/**
* Session storage parameter, used by drivers.
*/
$config['storage'] = '';
/**
* Session name.
* It must contain only alphanumeric characters and underscores. At least one letter must be present.
*/
$config['name'] = 'kohanasession';
/**
* Session parameters to validate: user_agent, ip_address, expiration.
*/
$config['validate'] = array('user_agent');
/**
* Enable or disable session encryption.
* Note: this has no effect on the native session driver.
* Note: the cookie driver always encrypts session data. Set to TRUE for stronger encryption.
*/
$config['encryption'] = FALSE;
/**
* Session lifetime. Number of seconds that each session will last.
* A value of 0 will keep the session active until the browser is closed (with a limit of 24h).
*/
$config['expiration'] = 7200;
/**
* Number of page loads before the session id is regenerated.
* A value of 0 will disable automatic session id regeneration.
*/
$config['regenerate'] = 3;
/**
* Percentage probability that the gc (garbage collection) routine is started.
*/
$config['gc_probability'] = 2;

View File

@ -0,0 +1,58 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Database
*
* SQL data types. If there are missing values, please report them:
*
* @link http://trac.kohanaphp.com/newticket
*/
$config = array
(
'tinyint' => array('type' => 'int', 'max' => 127),
'smallint' => array('type' => 'int', 'max' => 32767),
'mediumint' => array('type' => 'int', 'max' => 8388607),
'int' => array('type' => 'int', 'max' => 2147483647),
'integer' => array('type' => 'int', 'max' => 2147483647),
'bigint' => array('type' => 'int', 'max' => 9223372036854775807),
'float' => array('type' => 'float'),
'float unsigned' => array('type' => 'float', 'min' => 0),
'boolean' => array('type' => 'boolean'),
'time' => array('type' => 'string', 'format' => '00:00:00'),
'time with time zone' => array('type' => 'string'),
'date' => array('type' => 'string', 'format' => '0000-00-00'),
'year' => array('type' => 'string', 'format' => '0000'),
'datetime' => array('type' => 'string', 'format' => '0000-00-00 00:00:00'),
'timestamp with time zone' => array('type' => 'string'),
'char' => array('type' => 'string', 'exact' => TRUE),
'binary' => array('type' => 'string', 'binary' => TRUE, 'exact' => TRUE),
'varchar' => array('type' => 'string'),
'varbinary' => array('type' => 'string', 'binary' => TRUE),
'blob' => array('type' => 'string', 'binary' => TRUE),
'text' => array('type' => 'string')
);
// DOUBLE
$config['double'] = $config['double precision'] = $config['decimal'] = $config['real'] = $config['numeric'] = $config['float'];
$config['double unsigned'] = $config['float unsigned'];
// BIT
$config['bit'] = $config['boolean'];
// TIMESTAMP
$config['timestamp'] = $config['timestamp without time zone'] = $config['datetime'];
// ENUM
$config['enum'] = $config['set'] = $config['varchar'];
// TEXT
$config['tinytext'] = $config['mediumtext'] = $config['longtext'] = $config['text'];
// BLOB
$config['tsvector'] = $config['tinyblob'] = $config['mediumblob'] = $config['longblob'] = $config['clob'] = $config['bytea'] = $config['blob'];
// CHARACTER
$config['character'] = $config['char'];
$config['character varying'] = $config['varchar'];
// TIME
$config['time without time zone'] = $config['time'];

View File

@ -0,0 +1,17 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* This path is relative to your index file. Absolute paths are also supported.
*/
$config['directory'] = DOCROOT.'upload';
/**
* Enable or disable directory creation.
*/
$config['create_directories'] = FALSE;
/**
* Remove spaces from uploaded filenames.
*/
$config['remove_spaces'] = TRUE;

View File

@ -0,0 +1,112 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* This file contains four arrays of user agent data. It is used by the
* User Agent library to help identify browser, platform, robot, and
* mobile device data. The array keys are used to identify the device
* and the array values are used to set the actual name of the item.
*/
$config['platform'] = array
(
'windows nt 6.0' => 'Windows Vista',
'windows nt 5.2' => 'Windows 2003',
'windows nt 5.0' => 'Windows 2000',
'windows nt 5.1' => 'Windows XP',
'windows nt 4.0' => 'Windows NT',
'winnt4.0' => 'Windows NT',
'winnt 4.0' => 'Windows NT',
'winnt' => 'Windows NT',
'windows 98' => 'Windows 98',
'win98' => 'Windows 98',
'windows 95' => 'Windows 95',
'win95' => 'Windows 95',
'windows' => 'Unknown Windows OS',
'os x' => 'Mac OS X',
'intel mac' => 'Intel Mac',
'ppc mac' => 'PowerPC Mac',
'powerpc' => 'PowerPC',
'ppc' => 'PowerPC',
'cygwin' => 'Cygwin',
'linux' => 'Linux',
'debian' => 'Debian',
'openvms' => 'OpenVMS',
'sunos' => 'Sun Solaris',
'amiga' => 'Amiga',
'beos' => 'BeOS',
'apachebench' => 'ApacheBench',
'freebsd' => 'FreeBSD',
'netbsd' => 'NetBSD',
'bsdi' => 'BSDi',
'openbsd' => 'OpenBSD',
'os/2' => 'OS/2',
'warp' => 'OS/2',
'aix' => 'AIX',
'irix' => 'Irix',
'osf' => 'DEC OSF',
'hp-ux' => 'HP-UX',
'hurd' => 'GNU/Hurd',
'unix' => 'Unknown Unix OS',
);
// The order of this array should NOT be changed. Many browsers return
// multiple browser types so we want to identify the sub-type first.
$config['browser'] = array
(
'Opera' => 'Opera',
'MSIE' => 'Internet Explorer',
'Internet Explorer' => 'Internet Explorer',
'Shiira' => 'Shiira',
'Firefox' => 'Firefox',
'Chimera' => 'Chimera',
'Phoenix' => 'Phoenix',
'Firebird' => 'Firebird',
'Camino' => 'Camino',
'Netscape' => 'Netscape',
'OmniWeb' => 'OmniWeb',
'Chrome' => 'Chrome',
'Safari' => 'Safari',
'Konqueror' => 'Konqueror',
'Epiphany' => 'Epiphany',
'Galeon' => 'Galeon',
'Mozilla' => 'Mozilla',
'icab' => 'iCab',
'lynx' => 'Lynx',
'links' => 'Links',
'hotjava' => 'HotJava',
'amaya' => 'Amaya',
'IBrowse' => 'IBrowse',
);
$config['mobile'] = array
(
'mobileexplorer' => 'Mobile Explorer',
'openwave' => 'Open Wave',
'opera mini' => 'Opera Mini',
'operamini' => 'Opera Mini',
'elaine' => 'Palm',
'palmsource' => 'Palm',
'digital paths' => 'Palm',
'avantgo' => 'Avantgo',
'xiino' => 'Xiino',
'palmscape' => 'Palmscape',
'nokia' => 'Nokia',
'ericsson' => 'Ericsson',
'blackBerry' => 'BlackBerry',
'motorola' => 'Motorola',
'iphone' => 'iPhone',
'android' => 'Android',
);
// There are hundreds of bots but these are the most common.
$config['robot'] = array
(
'googlebot' => 'Googlebot',
'msnbot' => 'MSNBot',
'slurp' => 'Inktomi Slurp',
'yahoo' => 'Yahoo',
'askjeeves' => 'AskJeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
);

View File

@ -0,0 +1,17 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Core
*
* Allowed non-php view types. Most file extensions are supported.
*/
$config['allowed_filetypes'] = array
(
'gif',
'jpg', 'jpeg',
'png',
'tif', 'tiff',
'swf',
'htm', 'html',
'css',
'js'
);

View File

@ -0,0 +1,23 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Outputs the dynamic Captcha resource.
* Usage: Call the Captcha controller from a view, e.g.
* <img src="<?php echo url::site('captcha') ?>" />
*
* $Id: captcha.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Captcha
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class Captcha_Controller extends Controller {
public function __call($method, $args)
{
// Output the Captcha challenge resource (no html)
// Pull the config group name from the URL
Captcha::factory($this->uri->segment(2))->render(FALSE);
}
} // End Captcha_Controller

View File

@ -0,0 +1,54 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Allows a template to be automatically loaded and displayed. Display can be
* dynamically turned off in the controller methods, and the template file
* can be overloaded.
*
* To use it, declare your controller to extend this class:
* `class Your_Controller extends Template_Controller`
*
* $Id: template.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
abstract class Template_Controller extends Controller {
// Template view name
public $template = 'template';
// Default to do auto-rendering
public $auto_render = TRUE;
/**
* Template loading and setup routine.
*/
public function __construct()
{
parent::__construct();
// Load the template
$this->template = new View($this->template);
if ($this->auto_render == TRUE)
{
// Render the template immediately after the controller method
Event::add('system.post_controller', array($this, '_render'));
}
}
/**
* Render the loaded template.
*/
public function _render()
{
if ($this->auto_render == TRUE)
{
// Render the template when the class is destroyed
$this->template->render(TRUE);
}
}
} // End Template_Controller

View File

@ -0,0 +1,125 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Simple benchmarking.
*
* $Id: Benchmark.php 4149 2009-04-01 13:32:50Z Shadowhand $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @license http://kohanaphp.com/license.html
*/
final class Benchmark {
// Benchmark timestamps
private static $marks;
/**
* Set a benchmark start point.
*
* @param string benchmark name
* @return void
*/
public static function start($name)
{
if ( ! isset(self::$marks[$name]))
{
self::$marks[$name] = array();
}
$mark = array
(
'start' => microtime(TRUE),
'stop' => FALSE,
'memory_start' => self::memory_usage(),
'memory_stop' => FALSE
);
array_unshift(self::$marks[$name], $mark);
}
/**
* Set a benchmark stop point.
*
* @param string benchmark name
* @return void
*/
public static function stop($name)
{
if (isset(self::$marks[$name]) AND self::$marks[$name][0]['stop'] === FALSE)
{
self::$marks[$name][0]['stop'] = microtime(TRUE);
self::$marks[$name][0]['memory_stop'] = self::memory_usage();
}
}
/**
* Get the elapsed time between a start and stop.
*
* @param string benchmark name, TRUE for all
* @param integer number of decimal places to count to
* @return array
*/
public static function get($name, $decimals = 4)
{
if ($name === TRUE)
{
$times = array();
$names = array_keys(self::$marks);
foreach ($names as $name)
{
// Get each mark recursively
$times[$name] = self::get($name, $decimals);
}
// Return the array
return $times;
}
if ( ! isset(self::$marks[$name]))
return FALSE;
if (self::$marks[$name][0]['stop'] === FALSE)
{
// Stop the benchmark to prevent mis-matched results
self::stop($name);
}
// Return a string version of the time between the start and stop points
// Properly reading a float requires using number_format or sprintf
$time = $memory = 0;
for ($i = 0; $i < count(self::$marks[$name]); $i++)
{
$time += self::$marks[$name][$i]['stop'] - self::$marks[$name][$i]['start'];
$memory += self::$marks[$name][$i]['memory_stop'] - self::$marks[$name][$i]['memory_start'];
}
return array
(
'time' => number_format($time, $decimals),
'memory' => $memory,
'count' => count(self::$marks[$name])
);
}
/**
* Returns the current memory usage. This is only possible if the
* memory_get_usage function is supported in PHP.
*
* @return integer
*/
private static function memory_usage()
{
static $func;
if ($func === NULL)
{
// Test if memory usage can be seen
$func = function_exists('memory_get_usage');
}
return $func ? memory_get_usage() : 0;
}
} // End Benchmark

View File

@ -0,0 +1,58 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Kohana process control file, loaded by the front controller.
*
* $Id: Bootstrap.php 4409 2009-06-06 00:48:26Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @license http://kohanaphp.com/license.html
*/
define('KOHANA_VERSION', '2.3.4');
define('KOHANA_CODENAME', 'buteo regalis');
// Test of Kohana is running in Windows
define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
// Kohana benchmarks are prefixed to prevent collisions
define('SYSTEM_BENCHMARK', 'system_benchmark');
// Load benchmarking support
require SYSPATH.'core/Benchmark'.EXT;
// Start total_execution
Benchmark::start(SYSTEM_BENCHMARK.'_total_execution');
// Start kohana_loading
Benchmark::start(SYSTEM_BENCHMARK.'_kohana_loading');
// Load core files
require SYSPATH.'core/utf8'.EXT;
require SYSPATH.'core/Event'.EXT;
require SYSPATH.'core/Kohana'.EXT;
// Prepare the environment
Kohana::setup();
// End kohana_loading
Benchmark::stop(SYSTEM_BENCHMARK.'_kohana_loading');
// Start system_initialization
Benchmark::start(SYSTEM_BENCHMARK.'_system_initialization');
// Prepare the system
Event::run('system.ready');
// Determine routing
Event::run('system.routing');
// End system_initialization
Benchmark::stop(SYSTEM_BENCHMARK.'_system_initialization');
// Make the magic happen!
Event::run('system.execute');
// Clean up and exit
Event::run('system.shutdown');

View File

@ -0,0 +1,232 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Process queuing/execution class. Allows an unlimited number of callbacks
* to be added to 'events'. Events can be run multiple times, and can also
* process event-specific data. By default, Kohana has several system events.
*
* $Id: Event.php 4390 2009-06-04 03:05:36Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @license http://kohanaphp.com/license.html
* @link http://docs.kohanaphp.com/general/events
*/
final class Event {
// Event callbacks
private static $events = array();
// Cache of events that have been run
private static $has_run = array();
// Data that can be processed during events
public static $data;
/**
* Add a callback to an event queue.
*
* @param string event name
* @param array http://php.net/callback
* @return boolean
*/
public static function add($name, $callback)
{
if ( ! isset(self::$events[$name]))
{
// Create an empty event if it is not yet defined
self::$events[$name] = array();
}
elseif (in_array($callback, self::$events[$name], TRUE))
{
// The event already exists
return FALSE;
}
// Add the event
self::$events[$name][] = $callback;
return TRUE;
}
/**
* Add a callback to an event queue, before a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_before($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
{
// Just add the event if there are no events
return self::add($name, $callback);
}
else
{
// Insert the event immediately before the existing event
return self::insert_event($name, $key, $callback);
}
}
/**
* Add a callback to an event queue, after a given event.
*
* @param string event name
* @param array existing event callback
* @param array event callback
* @return boolean
*/
public static function add_after($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name])) === FALSE)
{
// Just add the event if there are no events
return self::add($name, $callback);
}
else
{
// Insert the event immediately after the existing event
return self::insert_event($name, $key + 1, $callback);
}
}
/**
* Inserts a new event at a specfic key location.
*
* @param string event name
* @param integer key to insert new event at
* @param array event callback
* @return void
*/
private static function insert_event($name, $key, $callback)
{
if (in_array($callback, self::$events[$name], TRUE))
return FALSE;
// Add the new event at the given key location
self::$events[$name] = array_merge
(
// Events before the key
array_slice(self::$events[$name], 0, $key),
// New event callback
array($callback),
// Events after the key
array_slice(self::$events[$name], $key)
);
return TRUE;
}
/**
* Replaces an event with another event.
*
* @param string event name
* @param array event to replace
* @param array new callback
* @return boolean
*/
public static function replace($name, $existing, $callback)
{
if (empty(self::$events[$name]) OR ($key = array_search($existing, self::$events[$name], TRUE)) === FALSE)
return FALSE;
if ( ! in_array($callback, self::$events[$name], TRUE))
{
// Replace the exisiting event with the new event
self::$events[$name][$key] = $callback;
}
else
{
// Remove the existing event from the queue
unset(self::$events[$name][$key]);
// Reset the array so the keys are ordered properly
self::$events[$name] = array_values(self::$events[$name]);
}
return TRUE;
}
/**
* Get all callbacks for an event.
*
* @param string event name
* @return array
*/
public static function get($name)
{
return empty(self::$events[$name]) ? array() : self::$events[$name];
}
/**
* Clear some or all callbacks from an event.
*
* @param string event name
* @param array specific callback to remove, FALSE for all callbacks
* @return void
*/
public static function clear($name, $callback = FALSE)
{
if ($callback === FALSE)
{
self::$events[$name] = array();
}
elseif (isset(self::$events[$name]))
{
// Loop through each of the event callbacks and compare it to the
// callback requested for removal. The callback is removed if it
// matches.
foreach (self::$events[$name] as $i => $event_callback)
{
if ($callback === $event_callback)
{
unset(self::$events[$name][$i]);
}
}
}
}
/**
* Execute all of the callbacks attached to an event.
*
* @param string event name
* @param array data can be processed as Event::$data by the callbacks
* @return void
*/
public static function run($name, & $data = NULL)
{
if ( ! empty(self::$events[$name]))
{
// So callbacks can access Event::$data
self::$data =& $data;
$callbacks = self::get($name);
foreach ($callbacks as $callback)
{
call_user_func($callback);
}
// Do this to prevent data from getting 'stuck'
$clear_data = '';
self::$data =& $clear_data;
}
// The event has been run!
self::$has_run[$name] = $name;
}
/**
* Check if a given event has been run.
*
* @param string event name
* @return boolean
*/
public static function has_run($name)
{
return isset(self::$has_run[$name]);
}
} // End Event

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,743 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* A port of phputf8 to a unified file/class. Checks PHP status to ensure that
* UTF-8 support is available and normalize global variables to UTF-8. It also
* provides multi-byte aware replacement string functions.
*
* This file is licensed differently from the rest of Kohana. As a port of
* phputf8, which is LGPL software, this file is released under the LGPL.
*
* PCRE needs to be compiled with UTF-8 support (--enable-utf8).
* Support for Unicode properties is highly recommended (--enable-unicode-properties).
* @see http://php.net/manual/reference.pcre.pattern.modifiers.php
*
* UTF-8 conversion will be much more reliable if the iconv extension is loaded.
* @see http://php.net/iconv
*
* The mbstring extension is highly recommended, but must not be overloading
* string functions.
* @see http://php.net/mbstring
*
* $Id: utf8.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
if ( ! preg_match('/^.$/u', 'ñ'))
{
trigger_error
(
'<a href="http://php.net/pcre">PCRE</a> has not been compiled with UTF-8 support. '.
'See <a href="http://php.net/manual/reference.pcre.pattern.modifiers.php">PCRE Pattern Modifiers</a> '.
'for more information. This application cannot be run without UTF-8 support.',
E_USER_ERROR
);
}
if ( ! extension_loaded('iconv'))
{
trigger_error
(
'The <a href="http://php.net/iconv">iconv</a> extension is not loaded. '.
'Without iconv, strings cannot be properly translated to UTF-8 from user input. '.
'This application cannot be run without UTF-8 support.',
E_USER_ERROR
);
}
if (extension_loaded('mbstring') AND (ini_get('mbstring.func_overload') & MB_OVERLOAD_STRING))
{
trigger_error
(
'The <a href="http://php.net/mbstring">mbstring</a> extension is overloading PHP\'s native string functions. '.
'Disable this by setting mbstring.func_overload to 0, 1, 4 or 5 in php.ini or a .htaccess file.'.
'This application cannot be run without UTF-8 support.',
E_USER_ERROR
);
}
// Check PCRE support for Unicode properties such as \p and \X.
$ER = error_reporting(0);
define('PCRE_UNICODE_PROPERTIES', (bool) preg_match('/^\pL$/u', 'ñ'));
error_reporting($ER);
// SERVER_UTF8 ? use mb_* functions : use non-native functions
if (extension_loaded('mbstring'))
{
mb_internal_encoding('UTF-8');
define('SERVER_UTF8', TRUE);
}
else
{
define('SERVER_UTF8', FALSE);
}
// Convert all global variables to UTF-8.
$_GET = utf8::clean($_GET);
$_POST = utf8::clean($_POST);
$_COOKIE = utf8::clean($_COOKIE);
$_SERVER = utf8::clean($_SERVER);
if (PHP_SAPI == 'cli')
{
// Convert command line arguments
$_SERVER['argv'] = utf8::clean($_SERVER['argv']);
}
final class utf8 {
// Called methods
static $called = array();
/**
* Recursively cleans arrays, objects, and strings. Removes ASCII control
* codes and converts to UTF-8 while silently discarding incompatible
* UTF-8 characters.
*
* @param string string to clean
* @return string
*/
public static function clean($str)
{
if (is_array($str) OR is_object($str))
{
foreach ($str as $key => $val)
{
// Recursion!
$str[self::clean($key)] = self::clean($val);
}
}
elseif (is_string($str) AND $str !== '')
{
// Remove control characters
$str = self::strip_ascii_ctrl($str);
if ( ! self::is_ascii($str))
{
// Disable notices
$ER = error_reporting(~E_NOTICE);
// iconv is expensive, so it is only used when needed
$str = iconv('UTF-8', 'UTF-8//IGNORE', $str);
// Turn notices back on
error_reporting($ER);
}
}
return $str;
}
/**
* Tests whether a string contains only 7bit ASCII bytes. This is used to
* determine when to use native functions or UTF-8 functions.
*
* @param string string to check
* @return bool
*/
public static function is_ascii($str)
{
return ! preg_match('/[^\x00-\x7F]/S', $str);
}
/**
* Strips out device control codes in the ASCII range.
*
* @param string string to clean
* @return string
*/
public static function strip_ascii_ctrl($str)
{
return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
}
/**
* Strips out all non-7bit ASCII bytes.
*
* @param string string to clean
* @return string
*/
public static function strip_non_ascii($str)
{
return preg_replace('/[^\x00-\x7F]+/S', '', $str);
}
/**
* Replaces special/accented UTF-8 characters by ASCII-7 'equivalents'.
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string string to transliterate
* @param integer -1 lowercase only, +1 uppercase only, 0 both cases
* @return string
*/
public static function transliterate_to_ascii($str, $case = 0)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _transliterate_to_ascii($str, $case);
}
/**
* Returns the length of the given string.
* @see http://php.net/strlen
*
* @param string string being measured for length
* @return integer
*/
public static function strlen($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strlen($str);
}
/**
* Finds position of first occurrence of a UTF-8 string.
* @see http://php.net/strlen
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string haystack
* @param string needle
* @param integer offset from which character in haystack to start searching
* @return integer position of needle
* @return boolean FALSE if the needle is not found
*/
public static function strpos($str, $search, $offset = 0)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strpos($str, $search, $offset);
}
/**
* Finds position of last occurrence of a char in a UTF-8 string.
* @see http://php.net/strrpos
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string haystack
* @param string needle
* @param integer offset from which character in haystack to start searching
* @return integer position of needle
* @return boolean FALSE if the needle is not found
*/
public static function strrpos($str, $search, $offset = 0)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strrpos($str, $search, $offset);
}
/**
* Returns part of a UTF-8 string.
* @see http://php.net/substr
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @param string input string
* @param integer offset
* @param integer length limit
* @return string
*/
public static function substr($str, $offset, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _substr($str, $offset, $length);
}
/**
* Replaces text within a portion of a UTF-8 string.
* @see http://php.net/substr_replace
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param string replacement string
* @param integer offset
* @return string
*/
public static function substr_replace($str, $replacement, $offset, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _substr_replace($str, $replacement, $offset, $length);
}
/**
* Makes a UTF-8 string lowercase.
* @see http://php.net/strtolower
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string mixed case string
* @return string
*/
public static function strtolower($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strtolower($str);
}
/**
* Makes a UTF-8 string uppercase.
* @see http://php.net/strtoupper
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string mixed case string
* @return string
*/
public static function strtoupper($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strtoupper($str);
}
/**
* Makes a UTF-8 string's first character uppercase.
* @see http://php.net/ucfirst
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string mixed case string
* @return string
*/
public static function ucfirst($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _ucfirst($str);
}
/**
* Makes the first character of every word in a UTF-8 string uppercase.
* @see http://php.net/ucwords
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string mixed case string
* @return string
*/
public static function ucwords($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _ucwords($str);
}
/**
* Case-insensitive UTF-8 string comparison.
* @see http://php.net/strcasecmp
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string string to compare
* @param string string to compare
* @return integer less than 0 if str1 is less than str2
* @return integer greater than 0 if str1 is greater than str2
* @return integer 0 if they are equal
*/
public static function strcasecmp($str1, $str2)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strcasecmp($str1, $str2);
}
/**
* Returns a string or an array with all occurrences of search in subject (ignoring case).
* replaced with the given replace value.
* @see http://php.net/str_ireplace
*
* @note It's not fast and gets slower if $search and/or $replace are arrays.
* @author Harry Fuecks <hfuecks@gmail.com
*
* @param string|array text to replace
* @param string|array replacement text
* @param string|array subject text
* @param integer number of matched and replaced needles will be returned via this parameter which is passed by reference
* @return string if the input was a string
* @return array if the input was an array
*/
public static function str_ireplace($search, $replace, $str, & $count = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _str_ireplace($search, $replace, $str, $count);
}
/**
* Case-insenstive UTF-8 version of strstr. Returns all of input string
* from the first occurrence of needle to the end.
* @see http://php.net/stristr
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param string needle
* @return string matched substring if found
* @return boolean FALSE if the substring was not found
*/
public static function stristr($str, $search)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _stristr($str, $search);
}
/**
* Finds the length of the initial segment matching mask.
* @see http://php.net/strspn
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param string mask for search
* @param integer start position of the string to examine
* @param integer length of the string to examine
* @return integer length of the initial segment that contains characters in the mask
*/
public static function strspn($str, $mask, $offset = NULL, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strspn($str, $mask, $offset, $length);
}
/**
* Finds the length of the initial segment not matching mask.
* @see http://php.net/strcspn
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param string mask for search
* @param integer start position of the string to examine
* @param integer length of the string to examine
* @return integer length of the initial segment that contains characters not in the mask
*/
public static function strcspn($str, $mask, $offset = NULL, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strcspn($str, $mask, $offset, $length);
}
/**
* Pads a UTF-8 string to a certain length with another string.
* @see http://php.net/str_pad
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param integer desired string length after padding
* @param string string to use as padding
* @param string padding type: STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH
* @return string
*/
public static function str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _str_pad($str, $final_str_length, $pad_str, $pad_type);
}
/**
* Converts a UTF-8 string to an array.
* @see http://php.net/str_split
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string input string
* @param integer maximum length of each chunk
* @return array
*/
public static function str_split($str, $split_length = 1)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _str_split($str, $split_length);
}
/**
* Reverses a UTF-8 string.
* @see http://php.net/strrev
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string string to be reversed
* @return string
*/
public static function strrev($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _strrev($str);
}
/**
* Strips whitespace (or other UTF-8 characters) from the beginning and
* end of a string.
* @see http://php.net/trim
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string input string
* @param string string of characters to remove
* @return string
*/
public static function trim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _trim($str, $charlist);
}
/**
* Strips whitespace (or other UTF-8 characters) from the beginning of a string.
* @see http://php.net/ltrim
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string input string
* @param string string of characters to remove
* @return string
*/
public static function ltrim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _ltrim($str, $charlist);
}
/**
* Strips whitespace (or other UTF-8 characters) from the end of a string.
* @see http://php.net/rtrim
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @param string input string
* @param string string of characters to remove
* @return string
*/
public static function rtrim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _rtrim($str, $charlist);
}
/**
* Returns the unicode ordinal for a character.
* @see http://php.net/ord
*
* @author Harry Fuecks <hfuecks@gmail.com>
*
* @param string UTF-8 encoded character
* @return integer
*/
public static function ord($chr)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _ord($chr);
}
/**
* Takes an UTF-8 string and returns an array of ints representing the Unicode characters.
* Astral planes are supported i.e. the ints in the output can be > 0xFFFF.
* Occurrances of the BOM are ignored. Surrogates are not allowed.
*
* The Original Code is Mozilla Communicator client code.
* The Initial Developer of the Original Code is Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer.
* Ported to PHP by Henri Sivonen <hsivonen@iki.fi>, see http://hsivonen.iki.fi/php-utf8/.
* Slight modifications to fit with phputf8 library by Harry Fuecks <hfuecks@gmail.com>.
*
* @param string UTF-8 encoded string
* @return array unicode code points
* @return boolean FALSE if the string is invalid
*/
public static function to_unicode($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _to_unicode($str);
}
/**
* Takes an array of ints representing the Unicode characters and returns a UTF-8 string.
* Astral planes are supported i.e. the ints in the input can be > 0xFFFF.
* Occurrances of the BOM are ignored. Surrogates are not allowed.
*
* The Original Code is Mozilla Communicator client code.
* The Initial Developer of the Original Code is Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998 the Initial Developer.
* Ported to PHP by Henri Sivonen <hsivonen@iki.fi>, see http://hsivonen.iki.fi/php-utf8/.
* Slight modifications to fit with phputf8 library by Harry Fuecks <hfuecks@gmail.com>.
*
* @param array unicode code points representing a string
* @return string utf8 string of characters
* @return boolean FALSE if a code point cannot be found
*/
public static function from_unicode($arr)
{
if ( ! isset(self::$called[__FUNCTION__]))
{
require SYSPATH.'core/utf8/'.__FUNCTION__.EXT;
// Function has been called
self::$called[__FUNCTION__] = TRUE;
}
return _from_unicode($arr);
}
} // End utf8

View File

@ -0,0 +1,68 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::from_unicode
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _from_unicode($arr)
{
ob_start();
$keys = array_keys($arr);
foreach ($keys as $k)
{
// ASCII range (including control chars)
if (($arr[$k] >= 0) AND ($arr[$k] <= 0x007f))
{
echo chr($arr[$k]);
}
// 2 byte sequence
elseif ($arr[$k] <= 0x07ff)
{
echo chr(0xc0 | ($arr[$k] >> 6));
echo chr(0x80 | ($arr[$k] & 0x003f));
}
// Byte order mark (skip)
elseif ($arr[$k] == 0xFEFF)
{
// nop -- zap the BOM
}
// Test for illegal surrogates
elseif ($arr[$k] >= 0xD800 AND $arr[$k] <= 0xDFFF)
{
// Found a surrogate
trigger_error('utf8::from_unicode: Illegal surrogate at index: '.$k.', value: '.$arr[$k], E_USER_WARNING);
return FALSE;
}
// 3 byte sequence
elseif ($arr[$k] <= 0xffff)
{
echo chr(0xe0 | ($arr[$k] >> 12));
echo chr(0x80 | (($arr[$k] >> 6) & 0x003f));
echo chr(0x80 | ($arr[$k] & 0x003f));
}
// 4 byte sequence
elseif ($arr[$k] <= 0x10ffff)
{
echo chr(0xf0 | ($arr[$k] >> 18));
echo chr(0x80 | (($arr[$k] >> 12) & 0x3f));
echo chr(0x80 | (($arr[$k] >> 6) & 0x3f));
echo chr(0x80 | ($arr[$k] & 0x3f));
}
// Out of range
else
{
trigger_error('utf8::from_unicode: Codepoint out of Unicode range at index: '.$k.', value: '.$arr[$k], E_USER_WARNING);
return FALSE;
}
}
$result = ob_get_contents();
ob_end_clean();
return $result;
}

View File

@ -0,0 +1,22 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::ltrim
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ltrim($str, $charlist = NULL)
{
if ($charlist === NULL)
return ltrim($str);
if (utf8::is_ascii($charlist))
return ltrim($str, $charlist);
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
return preg_replace('/^['.$charlist.']+/u', '', $str);
}

View File

@ -0,0 +1,88 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::ord
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ord($chr)
{
$ord0 = ord($chr);
if ($ord0 >= 0 AND $ord0 <= 127)
{
return $ord0;
}
if ( ! isset($chr[1]))
{
trigger_error('Short sequence - at least 2 bytes expected, only 1 seen', E_USER_WARNING);
return FALSE;
}
$ord1 = ord($chr[1]);
if ($ord0 >= 192 AND $ord0 <= 223)
{
return ($ord0 - 192) * 64 + ($ord1 - 128);
}
if ( ! isset($chr[2]))
{
trigger_error('Short sequence - at least 3 bytes expected, only 2 seen', E_USER_WARNING);
return FALSE;
}
$ord2 = ord($chr[2]);
if ($ord0 >= 224 AND $ord0 <= 239)
{
return ($ord0 - 224) * 4096 + ($ord1 - 128) * 64 + ($ord2 - 128);
}
if ( ! isset($chr[3]))
{
trigger_error('Short sequence - at least 4 bytes expected, only 3 seen', E_USER_WARNING);
return FALSE;
}
$ord3 = ord($chr[3]);
if ($ord0 >= 240 AND $ord0 <= 247)
{
return ($ord0 - 240) * 262144 + ($ord1 - 128) * 4096 + ($ord2-128) * 64 + ($ord3 - 128);
}
if ( ! isset($chr[4]))
{
trigger_error('Short sequence - at least 5 bytes expected, only 4 seen', E_USER_WARNING);
return FALSE;
}
$ord4 = ord($chr[4]);
if ($ord0 >= 248 AND $ord0 <= 251)
{
return ($ord0 - 248) * 16777216 + ($ord1-128) * 262144 + ($ord2 - 128) * 4096 + ($ord3 - 128) * 64 + ($ord4 - 128);
}
if ( ! isset($chr[5]))
{
trigger_error('Short sequence - at least 6 bytes expected, only 5 seen', E_USER_WARNING);
return FALSE;
}
if ($ord0 >= 252 AND $ord0 <= 253)
{
return ($ord0 - 252) * 1073741824 + ($ord1 - 128) * 16777216 + ($ord2 - 128) * 262144 + ($ord3 - 128) * 4096 + ($ord4 - 128) * 64 + (ord($chr[5]) - 128);
}
if ($ord0 >= 254 AND $ord0 <= 255)
{
trigger_error('Invalid UTF-8 with surrogate ordinal '.$ord0, E_USER_WARNING);
return FALSE;
}
}

View File

@ -0,0 +1,22 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::rtrim
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _rtrim($str, $charlist = NULL)
{
if ($charlist === NULL)
return rtrim($str);
if (utf8::is_ascii($charlist))
return rtrim($str, $charlist);
$charlist = preg_replace('#[-\[\]:\\\\^/]#', '\\\\$0', $charlist);
return preg_replace('/['.$charlist.']++$/uD', '', $str);
}

View File

@ -0,0 +1,70 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::str_ireplace
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _str_ireplace($search, $replace, $str, & $count = NULL)
{
if (utf8::is_ascii($search) AND utf8::is_ascii($replace) AND utf8::is_ascii($str))
return str_ireplace($search, $replace, $str, $count);
if (is_array($str))
{
foreach ($str as $key => $val)
{
$str[$key] = utf8::str_ireplace($search, $replace, $val, $count);
}
return $str;
}
if (is_array($search))
{
$keys = array_keys($search);
foreach ($keys as $k)
{
if (is_array($replace))
{
if (array_key_exists($k, $replace))
{
$str = utf8::str_ireplace($search[$k], $replace[$k], $str, $count);
}
else
{
$str = utf8::str_ireplace($search[$k], '', $str, $count);
}
}
else
{
$str = utf8::str_ireplace($search[$k], $replace, $str, $count);
}
}
return $str;
}
$search = utf8::strtolower($search);
$str_lower = utf8::strtolower($str);
$total_matched_strlen = 0;
$i = 0;
while (preg_match('/(.*?)'.preg_quote($search, '/').'/s', $str_lower, $matches))
{
$matched_strlen = strlen($matches[0]);
$str_lower = substr($str_lower, $matched_strlen);
$offset = $total_matched_strlen + strlen($matches[1]) + ($i * (strlen($replace) - 1));
$str = substr_replace($str, $replace, $offset, strlen($search));
$total_matched_strlen += $matched_strlen;
$i++;
}
$count += $i;
return $str;
}

View File

@ -0,0 +1,54 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::str_pad
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
if (utf8::is_ascii($str) AND utf8::is_ascii($pad_str))
{
return str_pad($str, $final_str_length, $pad_str, $pad_type);
}
$str_length = utf8::strlen($str);
if ($final_str_length <= 0 OR $final_str_length <= $str_length)
{
return $str;
}
$pad_str_length = utf8::strlen($pad_str);
$pad_length = $final_str_length - $str_length;
if ($pad_type == STR_PAD_RIGHT)
{
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr($str.str_repeat($pad_str, $repeat), 0, $final_str_length);
}
if ($pad_type == STR_PAD_LEFT)
{
$repeat = ceil($pad_length / $pad_str_length);
return utf8::substr(str_repeat($pad_str, $repeat), 0, floor($pad_length)).$str;
}
if ($pad_type == STR_PAD_BOTH)
{
$pad_length /= 2;
$pad_length_left = floor($pad_length);
$pad_length_right = ceil($pad_length);
$repeat_left = ceil($pad_length_left / $pad_str_length);
$repeat_right = ceil($pad_length_right / $pad_str_length);
$pad_left = utf8::substr(str_repeat($pad_str, $repeat_left), 0, $pad_length_left);
$pad_right = utf8::substr(str_repeat($pad_str, $repeat_right), 0, $pad_length_left);
return $pad_left.$str.$pad_right;
}
trigger_error('utf8::str_pad: Unknown padding type (' . $pad_type . ')', E_USER_ERROR);
}

View File

@ -0,0 +1,33 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::str_split
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _str_split($str, $split_length = 1)
{
$split_length = (int) $split_length;
if (utf8::is_ascii($str))
{
return str_split($str, $split_length);
}
if ($split_length < 1)
{
return FALSE;
}
if (utf8::strlen($str) <= $split_length)
{
return array($str);
}
preg_match_all('/.{'.$split_length.'}|[^\x00]{1,'.$split_length.'}$/us', $str, $matches);
return $matches[0];
}

View File

@ -0,0 +1,19 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strcasecmp
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strcasecmp($str1, $str2)
{
if (utf8::is_ascii($str1) AND utf8::is_ascii($str2))
return strcasecmp($str1, $str2);
$str1 = utf8::strtolower($str1);
$str2 = utf8::strtolower($str2);
return strcmp($str1, $str2);
}

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strcspn
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strcspn($str, $mask, $offset = NULL, $length = NULL)
{
if ($str == '' OR $mask == '')
return 0;
if (utf8::is_ascii($str) AND utf8::is_ascii($mask))
return ($offset === NULL) ? strcspn($str, $mask) : (($length === NULL) ? strcspn($str, $mask, $offset) : strcspn($str, $mask, $offset, $length));
if ($str !== NULL OR $length !== NULL)
{
$str = utf8::substr($str, $offset, $length);
}
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^'.$mask.']+/u', $str, $matches);
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}

View File

@ -0,0 +1,28 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::stristr
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _stristr($str, $search)
{
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return stristr($str, $search);
if ($search == '')
return $str;
$str_lower = utf8::strtolower($str);
$search_lower = utf8::strtolower($search);
preg_match('/^(.*?)'.preg_quote($search, '/').'/s', $str_lower, $matches);
if (isset($matches[1]))
return substr($str, strlen($matches[1]));
return FALSE;
}

View File

@ -0,0 +1,21 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strlen
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strlen($str)
{
// Try mb_strlen() first because it's faster than combination of is_ascii() and strlen()
if (SERVER_UTF8)
return mb_strlen($str);
if (utf8::is_ascii($str))
return strlen($str);
return strlen(utf8_decode($str));
}

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strpos
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strpos($str, $search, $offset = 0)
{
$offset = (int) $offset;
if (SERVER_UTF8)
return mb_strpos($str, $search, $offset);
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return strpos($str, $search, $offset);
if ($offset == 0)
{
$array = explode($search, $str, 2);
return isset($array[1]) ? utf8::strlen($array[0]) : FALSE;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strpos($str, $search);
return ($pos === FALSE) ? FALSE : $pos + $offset;
}

View File

@ -0,0 +1,18 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strrev
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strrev($str)
{
if (utf8::is_ascii($str))
return strrev($str);
preg_match_all('/./us', $str, $matches);
return implode('', array_reverse($matches[0]));
}

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strrpos
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strrpos($str, $search, $offset = 0)
{
$offset = (int) $offset;
if (SERVER_UTF8)
return mb_strrpos($str, $search, $offset);
if (utf8::is_ascii($str) AND utf8::is_ascii($search))
return strrpos($str, $search, $offset);
if ($offset == 0)
{
$array = explode($search, $str, -1);
return isset($array[0]) ? utf8::strlen(implode($search, $array)) : FALSE;
}
$str = utf8::substr($str, $offset);
$pos = utf8::strrpos($str, $search);
return ($pos === FALSE) ? FALSE : $pos + $offset;
}

View File

@ -0,0 +1,30 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strspn
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strspn($str, $mask, $offset = NULL, $length = NULL)
{
if ($str == '' OR $mask == '')
return 0;
if (utf8::is_ascii($str) AND utf8::is_ascii($mask))
return ($offset === NULL) ? strspn($str, $mask) : (($length === NULL) ? strspn($str, $mask, $offset) : strspn($str, $mask, $offset, $length));
if ($offset !== NULL OR $length !== NULL)
{
$str = utf8::substr($str, $offset, $length);
}
// Escape these characters: - [ ] . : \ ^ /
// The . and : are escaped to prevent possible warnings about POSIX regex elements
$mask = preg_replace('#[-[\].:\\\\^/]#', '\\\\$0', $mask);
preg_match('/^[^'.$mask.']+/u', $str, $matches);
return isset($matches[0]) ? utf8::strlen($matches[0]) : 0;
}

View File

@ -0,0 +1,84 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strtolower
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strtolower($str)
{
if (SERVER_UTF8)
return mb_strtolower($str);
if (utf8::is_ascii($str))
return strtolower($str);
static $UTF8_UPPER_TO_LOWER = NULL;
if ($UTF8_UPPER_TO_LOWER === NULL)
{
$UTF8_UPPER_TO_LOWER = array(
0x0041=>0x0061, 0x03A6=>0x03C6, 0x0162=>0x0163, 0x00C5=>0x00E5, 0x0042=>0x0062,
0x0139=>0x013A, 0x00C1=>0x00E1, 0x0141=>0x0142, 0x038E=>0x03CD, 0x0100=>0x0101,
0x0490=>0x0491, 0x0394=>0x03B4, 0x015A=>0x015B, 0x0044=>0x0064, 0x0393=>0x03B3,
0x00D4=>0x00F4, 0x042A=>0x044A, 0x0419=>0x0439, 0x0112=>0x0113, 0x041C=>0x043C,
0x015E=>0x015F, 0x0143=>0x0144, 0x00CE=>0x00EE, 0x040E=>0x045E, 0x042F=>0x044F,
0x039A=>0x03BA, 0x0154=>0x0155, 0x0049=>0x0069, 0x0053=>0x0073, 0x1E1E=>0x1E1F,
0x0134=>0x0135, 0x0427=>0x0447, 0x03A0=>0x03C0, 0x0418=>0x0438, 0x00D3=>0x00F3,
0x0420=>0x0440, 0x0404=>0x0454, 0x0415=>0x0435, 0x0429=>0x0449, 0x014A=>0x014B,
0x0411=>0x0431, 0x0409=>0x0459, 0x1E02=>0x1E03, 0x00D6=>0x00F6, 0x00D9=>0x00F9,
0x004E=>0x006E, 0x0401=>0x0451, 0x03A4=>0x03C4, 0x0423=>0x0443, 0x015C=>0x015D,
0x0403=>0x0453, 0x03A8=>0x03C8, 0x0158=>0x0159, 0x0047=>0x0067, 0x00C4=>0x00E4,
0x0386=>0x03AC, 0x0389=>0x03AE, 0x0166=>0x0167, 0x039E=>0x03BE, 0x0164=>0x0165,
0x0116=>0x0117, 0x0108=>0x0109, 0x0056=>0x0076, 0x00DE=>0x00FE, 0x0156=>0x0157,
0x00DA=>0x00FA, 0x1E60=>0x1E61, 0x1E82=>0x1E83, 0x00C2=>0x00E2, 0x0118=>0x0119,
0x0145=>0x0146, 0x0050=>0x0070, 0x0150=>0x0151, 0x042E=>0x044E, 0x0128=>0x0129,
0x03A7=>0x03C7, 0x013D=>0x013E, 0x0422=>0x0442, 0x005A=>0x007A, 0x0428=>0x0448,
0x03A1=>0x03C1, 0x1E80=>0x1E81, 0x016C=>0x016D, 0x00D5=>0x00F5, 0x0055=>0x0075,
0x0176=>0x0177, 0x00DC=>0x00FC, 0x1E56=>0x1E57, 0x03A3=>0x03C3, 0x041A=>0x043A,
0x004D=>0x006D, 0x016A=>0x016B, 0x0170=>0x0171, 0x0424=>0x0444, 0x00CC=>0x00EC,
0x0168=>0x0169, 0x039F=>0x03BF, 0x004B=>0x006B, 0x00D2=>0x00F2, 0x00C0=>0x00E0,
0x0414=>0x0434, 0x03A9=>0x03C9, 0x1E6A=>0x1E6B, 0x00C3=>0x00E3, 0x042D=>0x044D,
0x0416=>0x0436, 0x01A0=>0x01A1, 0x010C=>0x010D, 0x011C=>0x011D, 0x00D0=>0x00F0,
0x013B=>0x013C, 0x040F=>0x045F, 0x040A=>0x045A, 0x00C8=>0x00E8, 0x03A5=>0x03C5,
0x0046=>0x0066, 0x00DD=>0x00FD, 0x0043=>0x0063, 0x021A=>0x021B, 0x00CA=>0x00EA,
0x0399=>0x03B9, 0x0179=>0x017A, 0x00CF=>0x00EF, 0x01AF=>0x01B0, 0x0045=>0x0065,
0x039B=>0x03BB, 0x0398=>0x03B8, 0x039C=>0x03BC, 0x040C=>0x045C, 0x041F=>0x043F,
0x042C=>0x044C, 0x00DE=>0x00FE, 0x00D0=>0x00F0, 0x1EF2=>0x1EF3, 0x0048=>0x0068,
0x00CB=>0x00EB, 0x0110=>0x0111, 0x0413=>0x0433, 0x012E=>0x012F, 0x00C6=>0x00E6,
0x0058=>0x0078, 0x0160=>0x0161, 0x016E=>0x016F, 0x0391=>0x03B1, 0x0407=>0x0457,
0x0172=>0x0173, 0x0178=>0x00FF, 0x004F=>0x006F, 0x041B=>0x043B, 0x0395=>0x03B5,
0x0425=>0x0445, 0x0120=>0x0121, 0x017D=>0x017E, 0x017B=>0x017C, 0x0396=>0x03B6,
0x0392=>0x03B2, 0x0388=>0x03AD, 0x1E84=>0x1E85, 0x0174=>0x0175, 0x0051=>0x0071,
0x0417=>0x0437, 0x1E0A=>0x1E0B, 0x0147=>0x0148, 0x0104=>0x0105, 0x0408=>0x0458,
0x014C=>0x014D, 0x00CD=>0x00ED, 0x0059=>0x0079, 0x010A=>0x010B, 0x038F=>0x03CE,
0x0052=>0x0072, 0x0410=>0x0430, 0x0405=>0x0455, 0x0402=>0x0452, 0x0126=>0x0127,
0x0136=>0x0137, 0x012A=>0x012B, 0x038A=>0x03AF, 0x042B=>0x044B, 0x004C=>0x006C,
0x0397=>0x03B7, 0x0124=>0x0125, 0x0218=>0x0219, 0x00DB=>0x00FB, 0x011E=>0x011F,
0x041E=>0x043E, 0x1E40=>0x1E41, 0x039D=>0x03BD, 0x0106=>0x0107, 0x03AB=>0x03CB,
0x0426=>0x0446, 0x00DE=>0x00FE, 0x00C7=>0x00E7, 0x03AA=>0x03CA, 0x0421=>0x0441,
0x0412=>0x0432, 0x010E=>0x010F, 0x00D8=>0x00F8, 0x0057=>0x0077, 0x011A=>0x011B,
0x0054=>0x0074, 0x004A=>0x006A, 0x040B=>0x045B, 0x0406=>0x0456, 0x0102=>0x0103,
0x039B=>0x03BB, 0x00D1=>0x00F1, 0x041D=>0x043D, 0x038C=>0x03CC, 0x00C9=>0x00E9,
0x00D0=>0x00F0, 0x0407=>0x0457, 0x0122=>0x0123,
);
}
$uni = utf8::to_unicode($str);
if ($uni === FALSE)
return FALSE;
for ($i = 0, $c = count($uni); $i < $c; $i++)
{
if (isset($UTF8_UPPER_TO_LOWER[$uni[$i]]))
{
$uni[$i] = $UTF8_UPPER_TO_LOWER[$uni[$i]];
}
}
return utf8::from_unicode($uni);
}

View File

@ -0,0 +1,84 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::strtoupper
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _strtoupper($str)
{
if (SERVER_UTF8)
return mb_strtoupper($str);
if (utf8::is_ascii($str))
return strtoupper($str);
static $UTF8_LOWER_TO_UPPER = NULL;
if ($UTF8_LOWER_TO_UPPER === NULL)
{
$UTF8_LOWER_TO_UPPER = array(
0x0061=>0x0041, 0x03C6=>0x03A6, 0x0163=>0x0162, 0x00E5=>0x00C5, 0x0062=>0x0042,
0x013A=>0x0139, 0x00E1=>0x00C1, 0x0142=>0x0141, 0x03CD=>0x038E, 0x0101=>0x0100,
0x0491=>0x0490, 0x03B4=>0x0394, 0x015B=>0x015A, 0x0064=>0x0044, 0x03B3=>0x0393,
0x00F4=>0x00D4, 0x044A=>0x042A, 0x0439=>0x0419, 0x0113=>0x0112, 0x043C=>0x041C,
0x015F=>0x015E, 0x0144=>0x0143, 0x00EE=>0x00CE, 0x045E=>0x040E, 0x044F=>0x042F,
0x03BA=>0x039A, 0x0155=>0x0154, 0x0069=>0x0049, 0x0073=>0x0053, 0x1E1F=>0x1E1E,
0x0135=>0x0134, 0x0447=>0x0427, 0x03C0=>0x03A0, 0x0438=>0x0418, 0x00F3=>0x00D3,
0x0440=>0x0420, 0x0454=>0x0404, 0x0435=>0x0415, 0x0449=>0x0429, 0x014B=>0x014A,
0x0431=>0x0411, 0x0459=>0x0409, 0x1E03=>0x1E02, 0x00F6=>0x00D6, 0x00F9=>0x00D9,
0x006E=>0x004E, 0x0451=>0x0401, 0x03C4=>0x03A4, 0x0443=>0x0423, 0x015D=>0x015C,
0x0453=>0x0403, 0x03C8=>0x03A8, 0x0159=>0x0158, 0x0067=>0x0047, 0x00E4=>0x00C4,
0x03AC=>0x0386, 0x03AE=>0x0389, 0x0167=>0x0166, 0x03BE=>0x039E, 0x0165=>0x0164,
0x0117=>0x0116, 0x0109=>0x0108, 0x0076=>0x0056, 0x00FE=>0x00DE, 0x0157=>0x0156,
0x00FA=>0x00DA, 0x1E61=>0x1E60, 0x1E83=>0x1E82, 0x00E2=>0x00C2, 0x0119=>0x0118,
0x0146=>0x0145, 0x0070=>0x0050, 0x0151=>0x0150, 0x044E=>0x042E, 0x0129=>0x0128,
0x03C7=>0x03A7, 0x013E=>0x013D, 0x0442=>0x0422, 0x007A=>0x005A, 0x0448=>0x0428,
0x03C1=>0x03A1, 0x1E81=>0x1E80, 0x016D=>0x016C, 0x00F5=>0x00D5, 0x0075=>0x0055,
0x0177=>0x0176, 0x00FC=>0x00DC, 0x1E57=>0x1E56, 0x03C3=>0x03A3, 0x043A=>0x041A,
0x006D=>0x004D, 0x016B=>0x016A, 0x0171=>0x0170, 0x0444=>0x0424, 0x00EC=>0x00CC,
0x0169=>0x0168, 0x03BF=>0x039F, 0x006B=>0x004B, 0x00F2=>0x00D2, 0x00E0=>0x00C0,
0x0434=>0x0414, 0x03C9=>0x03A9, 0x1E6B=>0x1E6A, 0x00E3=>0x00C3, 0x044D=>0x042D,
0x0436=>0x0416, 0x01A1=>0x01A0, 0x010D=>0x010C, 0x011D=>0x011C, 0x00F0=>0x00D0,
0x013C=>0x013B, 0x045F=>0x040F, 0x045A=>0x040A, 0x00E8=>0x00C8, 0x03C5=>0x03A5,
0x0066=>0x0046, 0x00FD=>0x00DD, 0x0063=>0x0043, 0x021B=>0x021A, 0x00EA=>0x00CA,
0x03B9=>0x0399, 0x017A=>0x0179, 0x00EF=>0x00CF, 0x01B0=>0x01AF, 0x0065=>0x0045,
0x03BB=>0x039B, 0x03B8=>0x0398, 0x03BC=>0x039C, 0x045C=>0x040C, 0x043F=>0x041F,
0x044C=>0x042C, 0x00FE=>0x00DE, 0x00F0=>0x00D0, 0x1EF3=>0x1EF2, 0x0068=>0x0048,
0x00EB=>0x00CB, 0x0111=>0x0110, 0x0433=>0x0413, 0x012F=>0x012E, 0x00E6=>0x00C6,
0x0078=>0x0058, 0x0161=>0x0160, 0x016F=>0x016E, 0x03B1=>0x0391, 0x0457=>0x0407,
0x0173=>0x0172, 0x00FF=>0x0178, 0x006F=>0x004F, 0x043B=>0x041B, 0x03B5=>0x0395,
0x0445=>0x0425, 0x0121=>0x0120, 0x017E=>0x017D, 0x017C=>0x017B, 0x03B6=>0x0396,
0x03B2=>0x0392, 0x03AD=>0x0388, 0x1E85=>0x1E84, 0x0175=>0x0174, 0x0071=>0x0051,
0x0437=>0x0417, 0x1E0B=>0x1E0A, 0x0148=>0x0147, 0x0105=>0x0104, 0x0458=>0x0408,
0x014D=>0x014C, 0x00ED=>0x00CD, 0x0079=>0x0059, 0x010B=>0x010A, 0x03CE=>0x038F,
0x0072=>0x0052, 0x0430=>0x0410, 0x0455=>0x0405, 0x0452=>0x0402, 0x0127=>0x0126,
0x0137=>0x0136, 0x012B=>0x012A, 0x03AF=>0x038A, 0x044B=>0x042B, 0x006C=>0x004C,
0x03B7=>0x0397, 0x0125=>0x0124, 0x0219=>0x0218, 0x00FB=>0x00DB, 0x011F=>0x011E,
0x043E=>0x041E, 0x1E41=>0x1E40, 0x03BD=>0x039D, 0x0107=>0x0106, 0x03CB=>0x03AB,
0x0446=>0x0426, 0x00FE=>0x00DE, 0x00E7=>0x00C7, 0x03CA=>0x03AA, 0x0441=>0x0421,
0x0432=>0x0412, 0x010F=>0x010E, 0x00F8=>0x00D8, 0x0077=>0x0057, 0x011B=>0x011A,
0x0074=>0x0054, 0x006A=>0x004A, 0x045B=>0x040B, 0x0456=>0x0406, 0x0103=>0x0102,
0x03BB=>0x039B, 0x00F1=>0x00D1, 0x043D=>0x041D, 0x03CC=>0x038C, 0x00E9=>0x00C9,
0x00F0=>0x00D0, 0x0457=>0x0407, 0x0123=>0x0122,
);
}
$uni = utf8::to_unicode($str);
if ($uni === FALSE)
return FALSE;
for ($i = 0, $c = count($uni); $i < $c; $i++)
{
if (isset($UTF8_LOWER_TO_UPPER[$uni[$i]]))
{
$uni[$i] = $UTF8_LOWER_TO_UPPER[$uni[$i]];
}
}
return utf8::from_unicode($uni);
}

View File

@ -0,0 +1,75 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::substr
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _substr($str, $offset, $length = NULL)
{
if (SERVER_UTF8)
return ($length === NULL) ? mb_substr($str, $offset) : mb_substr($str, $offset, $length);
if (utf8::is_ascii($str))
return ($length === NULL) ? substr($str, $offset) : substr($str, $offset, $length);
// Normalize params
$str = (string) $str;
$strlen = utf8::strlen($str);
$offset = (int) ($offset < 0) ? max(0, $strlen + $offset) : $offset; // Normalize to positive offset
$length = ($length === NULL) ? NULL : (int) $length;
// Impossible
if ($length === 0 OR $offset >= $strlen OR ($length < 0 AND $length <= $offset - $strlen))
return '';
// Whole string
if ($offset == 0 AND ($length === NULL OR $length >= $strlen))
return $str;
// Build regex
$regex = '^';
// Create an offset expression
if ($offset > 0)
{
// PCRE repeating quantifiers must be less than 65536, so repeat when necessary
$x = (int) ($offset / 65535);
$y = (int) ($offset % 65535);
$regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
$regex .= ($y == 0) ? '' : '.{'.$y.'}';
}
// Create a length expression
if ($length === NULL)
{
$regex .= '(.*)'; // No length set, grab it all
}
// Find length from the left (positive length)
elseif ($length > 0)
{
// Reduce length so that it can't go beyond the end of the string
$length = min($strlen - $offset, $length);
$x = (int) ($length / 65535);
$y = (int) ($length % 65535);
$regex .= '(';
$regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
$regex .= '.{'.$y.'})';
}
// Find length from the right (negative length)
else
{
$x = (int) (-$length / 65535);
$y = (int) (-$length % 65535);
$regex .= '(.*)';
$regex .= ($x == 0) ? '' : '(?:.{65535}){'.$x.'}';
$regex .= '.{'.$y.'}';
}
preg_match('/'.$regex.'/us', $str, $matches);
return $matches[1];
}

View File

@ -0,0 +1,22 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::substr_replace
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _substr_replace($str, $replacement, $offset, $length = NULL)
{
if (utf8::is_ascii($str))
return ($length === NULL) ? substr_replace($str, $replacement, $offset) : substr_replace($str, $replacement, $offset, $length);
$length = ($length === NULL) ? utf8::strlen($str) : (int) $length;
preg_match_all('/./us', $str, $str_array);
preg_match_all('/./us', $replacement, $replacement_array);
array_splice($str_array[0], $offset, $length, $replacement_array[0]);
return implode('', $str_array[0]);
}

View File

@ -0,0 +1,141 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::to_unicode
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _to_unicode($str)
{
$mState = 0; // cached expected number of octets after the current octet until the beginning of the next UTF8 character sequence
$mUcs4 = 0; // cached Unicode character
$mBytes = 1; // cached expected number of octets in the current sequence
$out = array();
$len = strlen($str);
for ($i = 0; $i < $len; $i++)
{
$in = ord($str[$i]);
if ($mState == 0)
{
// When mState is zero we expect either a US-ASCII character or a
// multi-octet sequence.
if (0 == (0x80 & $in))
{
// US-ASCII, pass straight through.
$out[] = $in;
$mBytes = 1;
}
elseif (0xC0 == (0xE0 & $in))
{
// First octet of 2 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x1F) << 6;
$mState = 1;
$mBytes = 2;
}
elseif (0xE0 == (0xF0 & $in))
{
// First octet of 3 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x0F) << 12;
$mState = 2;
$mBytes = 3;
}
elseif (0xF0 == (0xF8 & $in))
{
// First octet of 4 octet sequence
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x07) << 18;
$mState = 3;
$mBytes = 4;
}
elseif (0xF8 == (0xFC & $in))
{
// First octet of 5 octet sequence.
//
// This is illegal because the encoded codepoint must be either
// (a) not the shortest form or
// (b) outside the Unicode range of 0-0x10FFFF.
// Rather than trying to resynchronize, we will carry on until the end
// of the sequence and let the later error handling code catch it.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 0x03) << 24;
$mState = 4;
$mBytes = 5;
}
elseif (0xFC == (0xFE & $in))
{
// First octet of 6 octet sequence, see comments for 5 octet sequence.
$mUcs4 = $in;
$mUcs4 = ($mUcs4 & 1) << 30;
$mState = 5;
$mBytes = 6;
}
else
{
// Current octet is neither in the US-ASCII range nor a legal first octet of a multi-octet sequence.
trigger_error('utf8::to_unicode: Illegal sequence identifier in UTF-8 at byte '.$i, E_USER_WARNING);
return FALSE;
}
}
else
{
// When mState is non-zero, we expect a continuation of the multi-octet sequence
if (0x80 == (0xC0 & $in))
{
// Legal continuation
$shift = ($mState - 1) * 6;
$tmp = $in;
$tmp = ($tmp & 0x0000003F) << $shift;
$mUcs4 |= $tmp;
// End of the multi-octet sequence. mUcs4 now contains the final Unicode codepoint to be output
if (0 == --$mState)
{
// Check for illegal sequences and codepoints
// From Unicode 3.1, non-shortest form is illegal
if (((2 == $mBytes) AND ($mUcs4 < 0x0080)) OR
((3 == $mBytes) AND ($mUcs4 < 0x0800)) OR
((4 == $mBytes) AND ($mUcs4 < 0x10000)) OR
(4 < $mBytes) OR
// From Unicode 3.2, surrogate characters are illegal
(($mUcs4 & 0xFFFFF800) == 0xD800) OR
// Codepoints outside the Unicode range are illegal
($mUcs4 > 0x10FFFF))
{
trigger_error('utf8::to_unicode: Illegal sequence or codepoint in UTF-8 at byte '.$i, E_USER_WARNING);
return FALSE;
}
if (0xFEFF != $mUcs4)
{
// BOM is legal but we don't want to output it
$out[] = $mUcs4;
}
// Initialize UTF-8 cache
$mState = 0;
$mUcs4 = 0;
$mBytes = 1;
}
}
else
{
// ((0xC0 & (*in) != 0x80) AND (mState != 0))
// Incomplete multi-octet sequence
trigger_error('utf8::to_unicode: Incomplete multi-octet sequence in UTF-8 at byte '.$i, E_USER_WARNING);
return FALSE;
}
}
}
return $out;
}

View File

@ -0,0 +1,77 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::transliterate_to_ascii
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _transliterate_to_ascii($str, $case = 0)
{
static $UTF8_LOWER_ACCENTS = NULL;
static $UTF8_UPPER_ACCENTS = NULL;
if ($case <= 0)
{
if ($UTF8_LOWER_ACCENTS === NULL)
{
$UTF8_LOWER_ACCENTS = array(
'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o',
'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k',
'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o',
'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o',
'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c',
'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't',
'ū' => 'u', 'č' => 'c', 'ö' => 'o', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l',
'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z',
'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't',
'ŗ' => 'r', 'ä' => 'a', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'u', 'ò' => 'o',
'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j',
'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o',
'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g',
'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a',
'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e',
);
}
$str = str_replace(
array_keys($UTF8_LOWER_ACCENTS),
array_values($UTF8_LOWER_ACCENTS),
$str
);
}
if ($case >= 0)
{
if ($UTF8_UPPER_ACCENTS === NULL)
{
$UTF8_UPPER_ACCENTS = array(
'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O',
'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K', 'Ĕ' => 'E',
'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O',
'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O',
'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C',
'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T',
'Ū' => 'U', 'Č' => 'C', 'Ö' => 'O', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L',
'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z',
'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T',
'Ŗ' => 'R', 'Ä' => 'A', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'U', 'Ò' => 'O',
'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J',
'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O',
'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G',
'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A',
'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae',
);
}
$str = str_replace(
array_keys($UTF8_UPPER_ACCENTS),
array_values($UTF8_UPPER_ACCENTS),
$str
);
}
return $str;
}

View File

@ -0,0 +1,17 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::trim
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _trim($str, $charlist = NULL)
{
if ($charlist === NULL)
return trim($str);
return utf8::ltrim(utf8::rtrim($str, $charlist), $charlist);
}

View File

@ -0,0 +1,18 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::ucfirst
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ucfirst($str)
{
if (utf8::is_ascii($str))
return ucfirst($str);
preg_match('/^(.?)(.*)$/us', $str, $matches);
return utf8::strtoupper($matches[1]).$matches[2];
}

View File

@ -0,0 +1,26 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* utf8::ucwords
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007 Kohana Team
* @copyright (c) 2005 Harry Fuecks
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
*/
function _ucwords($str)
{
if (SERVER_UTF8)
return mb_convert_case($str, MB_CASE_TITLE);
if (utf8::is_ascii($str))
return ucwords($str);
// [\x0c\x09\x0b\x0a\x0d\x20] matches form feeds, horizontal tabs, vertical tabs, linefeeds and carriage returns.
// This corresponds to the definition of a 'word' defined at http://php.net/ucwords
return preg_replace(
'/(?<=^|[\x0c\x09\x0b\x0a\x0d\x20])[^\x0c\x09\x0b\x0a\x0d\x20]/ue',
'utf8::strtoupper(\'$0\')',
$str
);
}

Binary file not shown.

View File

@ -0,0 +1,99 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
Bitstream Vera Fonts Copyright
------------------------------
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:
The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.
The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".
This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.
The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.
Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.
Arev Fonts Copyright
------------------------------
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:
The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.
The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".
This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.
The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $

View File

@ -0,0 +1,312 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Array helper class.
*
* $Id: arr.php 4346 2009-05-11 17:08:15Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class arr_Core {
/**
* Return a callback array from a string, eg: limit[10,20] would become
* array('limit', array('10', '20'))
*
* @param string callback string
* @return array
*/
public static function callback_string($str)
{
// command[param,param]
if (preg_match('/([^\[]*+)\[(.+)\]/', (string) $str, $match))
{
// command
$command = $match[1];
// param,param
$params = preg_split('/(?<!\\\\),/', $match[2]);
$params = str_replace('\,', ',', $params);
}
else
{
// command
$command = $str;
// No params
$params = NULL;
}
return array($command, $params);
}
/**
* Rotates a 2D array clockwise.
* Example, turns a 2x3 array into a 3x2 array.
*
* @param array array to rotate
* @param boolean keep the keys in the final rotated array. the sub arrays of the source array need to have the same key values.
* if your subkeys might not match, you need to pass FALSE here!
* @return array
*/
public static function rotate($source_array, $keep_keys = TRUE)
{
$new_array = array();
foreach ($source_array as $key => $value)
{
$value = ($keep_keys === TRUE) ? $value : array_values($value);
foreach ($value as $k => $v)
{
$new_array[$k][$key] = $v;
}
}
return $new_array;
}
/**
* Removes a key from an array and returns the value.
*
* @param string key to return
* @param array array to work on
* @return mixed value of the requested array key
*/
public static function remove($key, & $array)
{
if ( ! array_key_exists($key, $array))
return NULL;
$val = $array[$key];
unset($array[$key]);
return $val;
}
/**
* Extract one or more keys from an array. Each key given after the first
* argument (the array) will be extracted. Keys that do not exist in the
* search array will be NULL in the extracted data.
*
* @param array array to search
* @param string key name
* @return array
*/
public static function extract(array $search, $keys)
{
// Get the keys, removing the $search array
$keys = array_slice(func_get_args(), 1);
$found = array();
foreach ($keys as $key)
{
if (isset($search[$key]))
{
$found[$key] = $search[$key];
}
else
{
$found[$key] = NULL;
}
}
return $found;
}
/**
* Because PHP does not have this function.
*
* @param array array to unshift
* @param string key to unshift
* @param mixed value to unshift
* @return array
*/
public static function unshift_assoc( array & $array, $key, $val)
{
$array = array_reverse($array, TRUE);
$array[$key] = $val;
$array = array_reverse($array, TRUE);
return $array;
}
/**
* Because PHP does not have this function, and array_walk_recursive creates
* references in arrays and is not truly recursive.
*
* @param mixed callback to apply to each member of the array
* @param array array to map to
* @return array
*/
public static function map_recursive($callback, array $array)
{
foreach ($array as $key => $val)
{
// Map the callback to the key
$array[$key] = is_array($val) ? arr::map_recursive($callback, $val) : call_user_func($callback, $val);
}
return $array;
}
/**
* @param mixed $needle the value to search for
* @param array $haystack an array of values to search in
* @param boolean $sort sort the array now
* @return integer|FALSE the index of the match or FALSE when not found
*/
public static function binary_search($needle, $haystack, $sort = FALSE)
{
if ($sort)
{
sort($haystack);
}
$high = count($haystack) - 1;
$low = 0;
while ($low <= $high)
{
$mid = ($low + $high) >> 1;
if ($haystack[$mid] < $needle)
{
$low = $mid + 1;
}
elseif ($haystack[$mid] > $needle)
{
$high = $mid - 1;
}
else
{
return $mid;
}
}
return FALSE;
}
/**
* Emulates array_merge_recursive, but appends numeric keys and replaces
* associative keys, instead of appending all keys.
*
* @param array any number of arrays
* @return array
*/
public static function merge()
{
$total = func_num_args();
$result = array();
for ($i = 0; $i < $total; $i++)
{
foreach (func_get_arg($i) as $key => $val)
{
if (isset($result[$key]))
{
if (is_array($val))
{
// Arrays are merged recursively
$result[$key] = arr::merge($result[$key], $val);
}
elseif (is_int($key))
{
// Indexed arrays are appended
array_push($result, $val);
}
else
{
// Associative arrays are replaced
$result[$key] = $val;
}
}
else
{
// New values are added
$result[$key] = $val;
}
}
}
return $result;
}
/**
* Overwrites an array with values from input array(s).
* Non-existing keys will not be appended!
*
* @param array key array
* @param array input array(s) that will overwrite key array values
* @return array
*/
public static function overwrite($array1, $array2)
{
foreach (array_intersect_key($array2, $array1) as $key => $value)
{
$array1[$key] = $value;
}
if (func_num_args() > 2)
{
foreach (array_slice(func_get_args(), 2) as $array2)
{
foreach (array_intersect_key($array2, $array1) as $key => $value)
{
$array1[$key] = $value;
}
}
}
return $array1;
}
/**
* Fill an array with a range of numbers.
*
* @param integer stepping
* @param integer ending number
* @return array
*/
public static function range($step = 10, $max = 100)
{
if ($step < 1)
return array();
$array = array();
for ($i = $step; $i <= $max; $i += $step)
{
$array[$i] = $i;
}
return $array;
}
/**
* Recursively convert an array to an object.
*
* @param array array to convert
* @return object
*/
public static function to_object(array $array, $class = 'stdClass')
{
$object = new $class;
foreach ($array as $key => $value)
{
if (is_array($value))
{
// Convert the array to an object
$value = arr::to_object($value, $class);
}
// Add the value to the object
$object->{$key} = $value;
}
return $object;
}
} // End arr

View File

@ -0,0 +1,84 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Cookie helper class.
*
* $Id: cookie.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class cookie_Core {
/**
* Sets a cookie with the given parameters.
*
* @param string cookie name or array of config options
* @param string cookie value
* @param integer number of seconds before the cookie expires
* @param string URL path to allow
* @param string URL domain to allow
* @param boolean HTTPS only
* @param boolean HTTP only (requires PHP 5.2 or higher)
* @return boolean
*/
public static function set($name, $value = NULL, $expire = NULL, $path = NULL, $domain = NULL, $secure = NULL, $httponly = NULL)
{
if (headers_sent())
return FALSE;
// If the name param is an array, we import it
is_array($name) and extract($name, EXTR_OVERWRITE);
// Fetch default options
$config = Kohana::config('cookie');
foreach (array('value', 'expire', 'domain', 'path', 'secure', 'httponly') as $item)
{
if ($$item === NULL AND isset($config[$item]))
{
$$item = $config[$item];
}
}
// Expiration timestamp
$expire = ($expire == 0) ? 0 : time() + (int) $expire;
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
/**
* Fetch a cookie value, using the Input library.
*
* @param string cookie name
* @param mixed default value
* @param boolean use XSS cleaning on the value
* @return string
*/
public static function get($name, $default = NULL, $xss_clean = FALSE)
{
return Input::instance()->cookie($name, $default, $xss_clean);
}
/**
* Nullify and unset a cookie.
*
* @param string cookie name
* @param string URL path
* @param string URL domain
* @return boolean
*/
public static function delete($name, $path = NULL, $domain = NULL)
{
if ( ! isset($_COOKIE[$name]))
return FALSE;
// Delete the cookie from globals
unset($_COOKIE[$name]);
// Sets the cookie value to an empty string, and the expiration to 24 hours ago
return cookie::set($name, '', -86400, $path, $domain, FALSE, FALSE);
}
} // End cookie

View File

@ -0,0 +1,405 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Date helper class.
*
* $Id: date.php 4316 2009-05-04 01:03:54Z kiall $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class date_Core {
/**
* Converts a UNIX timestamp to DOS format.
*
* @param integer UNIX timestamp
* @return integer
*/
public static function unix2dos($timestamp = FALSE)
{
$timestamp = ($timestamp === FALSE) ? getdate() : getdate($timestamp);
if ($timestamp['year'] < 1980)
{
return (1 << 21 | 1 << 16);
}
$timestamp['year'] -= 1980;
// What voodoo is this? I have no idea... Geert can explain it though,
// and that's good enough for me.
return ($timestamp['year'] << 25 | $timestamp['mon'] << 21 |
$timestamp['mday'] << 16 | $timestamp['hours'] << 11 |
$timestamp['minutes'] << 5 | $timestamp['seconds'] >> 1);
}
/**
* Converts a DOS timestamp to UNIX format.
*
* @param integer DOS timestamp
* @return integer
*/
public static function dos2unix($timestamp = FALSE)
{
$sec = 2 * ($timestamp & 0x1f);
$min = ($timestamp >> 5) & 0x3f;
$hrs = ($timestamp >> 11) & 0x1f;
$day = ($timestamp >> 16) & 0x1f;
$mon = ($timestamp >> 21) & 0x0f;
$year = ($timestamp >> 25) & 0x7f;
return mktime($hrs, $min, $sec, $mon, $day, $year + 1980);
}
/**
* Returns the offset (in seconds) between two time zones.
* @see http://php.net/timezones
*
* @param string timezone that to find the offset of
* @param string|boolean timezone used as the baseline
* @return integer
*/
public static function offset($remote, $local = TRUE)
{
static $offsets;
// Default values
$remote = (string) $remote;
$local = ($local === TRUE) ? date_default_timezone_get() : (string) $local;
// Cache key name
$cache = $remote.$local;
if (empty($offsets[$cache]))
{
// Create timezone objects
$remote = new DateTimeZone($remote);
$local = new DateTimeZone($local);
// Create date objects from timezones
$time_there = new DateTime('now', $remote);
$time_here = new DateTime('now', $local);
// Find the offset
$offsets[$cache] = $remote->getOffset($time_there) - $local->getOffset($time_here);
}
return $offsets[$cache];
}
/**
* Number of seconds in a minute, incrementing by a step.
*
* @param integer amount to increment each step by, 1 to 30
* @param integer start value
* @param integer end value
* @return array A mirrored (foo => foo) array from 1-60.
*/
public static function seconds($step = 1, $start = 0, $end = 60)
{
// Always integer
$step = (int) $step;
$seconds = array();
for ($i = $start; $i < $end; $i += $step)
{
$seconds[$i] = ($i < 10) ? '0'.$i : $i;
}
return $seconds;
}
/**
* Number of minutes in an hour, incrementing by a step.
*
* @param integer amount to increment each step by, 1 to 30
* @return array A mirrored (foo => foo) array from 1-60.
*/
public static function minutes($step = 5)
{
// Because there are the same number of minutes as seconds in this set,
// we choose to re-use seconds(), rather than creating an entirely new
// function. Shhhh, it's cheating! ;) There are several more of these
// in the following methods.
return date::seconds($step);
}
/**
* Number of hours in a day.
*
* @param integer amount to increment each step by
* @param boolean use 24-hour time
* @param integer the hour to start at
* @return array A mirrored (foo => foo) array from start-12 or start-23.
*/
public static function hours($step = 1, $long = FALSE, $start = NULL)
{
// Default values
$step = (int) $step;
$long = (bool) $long;
$hours = array();
// Set the default start if none was specified.
if ($start === NULL)
{
$start = ($long === FALSE) ? 1 : 0;
}
$hours = array();
// 24-hour time has 24 hours, instead of 12
$size = ($long === TRUE) ? 23 : 12;
for ($i = $start; $i <= $size; $i += $step)
{
$hours[$i] = $i;
}
return $hours;
}
/**
* Returns AM or PM, based on a given hour.
*
* @param integer number of the hour
* @return string
*/
public static function ampm($hour)
{
// Always integer
$hour = (int) $hour;
return ($hour > 11) ? 'PM' : 'AM';
}
/**
* Adjusts a non-24-hour number into a 24-hour number.
*
* @param integer hour to adjust
* @param string AM or PM
* @return string
*/
public static function adjust($hour, $ampm)
{
$hour = (int) $hour;
$ampm = strtolower($ampm);
switch ($ampm)
{
case 'am':
if ($hour == 12)
$hour = 0;
break;
case 'pm':
if ($hour < 12)
$hour += 12;
break;
}
return sprintf('%02s', $hour);
}
/**
* Number of days in month.
*
* @param integer number of month
* @param integer number of year to check month, defaults to the current year
* @return array A mirrored (foo => foo) array of the days.
*/
public static function days($month, $year = FALSE)
{
static $months;
// Always integers
$month = (int) $month;
$year = (int) $year;
// Use the current year by default
$year = ($year == FALSE) ? date('Y') : $year;
// We use caching for months, because time functions are used
if (empty($months[$year][$month]))
{
$months[$year][$month] = array();
// Use date to find the number of days in the given month
$total = date('t', mktime(1, 0, 0, $month, 1, $year)) + 1;
for ($i = 1; $i < $total; $i++)
{
$months[$year][$month][$i] = $i;
}
}
return $months[$year][$month];
}
/**
* Number of months in a year
*
* @return array A mirrored (foo => foo) array from 1-12.
*/
public static function months()
{
return date::hours();
}
/**
* Returns an array of years between a starting and ending year.
* Uses the current year +/- 5 as the max/min.
*
* @param integer starting year
* @param integer ending year
* @return array
*/
public static function years($start = FALSE, $end = FALSE)
{
// Default values
$start = ($start === FALSE) ? date('Y') - 5 : (int) $start;
$end = ($end === FALSE) ? date('Y') + 5 : (int) $end;
$years = array();
// Add one, so that "less than" works
$end += 1;
for ($i = $start; $i < $end; $i++)
{
$years[$i] = $i;
}
return $years;
}
/**
* Returns time difference between two timestamps, in human readable format.
*
* @param integer timestamp
* @param integer timestamp, defaults to the current time
* @param string formatting string
* @return string|array
*/
public static function timespan($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
{
// Array with the output formats
$output = preg_split('/[^a-z]+/', strtolower((string) $output));
// Invalid output
if (empty($output))
return FALSE;
// Make the output values into keys
extract(array_flip($output), EXTR_SKIP);
// Default values
$time1 = max(0, (int) $time1);
$time2 = empty($time2) ? time() : max(0, (int) $time2);
// Calculate timespan (seconds)
$timespan = abs($time1 - $time2);
// All values found using Google Calculator.
// Years and months do not match the formula exactly, due to leap years.
// Years ago, 60 * 60 * 24 * 365
isset($years) and $timespan -= 31556926 * ($years = (int) floor($timespan / 31556926));
// Months ago, 60 * 60 * 24 * 30
isset($months) and $timespan -= 2629744 * ($months = (int) floor($timespan / 2629743.83));
// Weeks ago, 60 * 60 * 24 * 7
isset($weeks) and $timespan -= 604800 * ($weeks = (int) floor($timespan / 604800));
// Days ago, 60 * 60 * 24
isset($days) and $timespan -= 86400 * ($days = (int) floor($timespan / 86400));
// Hours ago, 60 * 60
isset($hours) and $timespan -= 3600 * ($hours = (int) floor($timespan / 3600));
// Minutes ago, 60
isset($minutes) and $timespan -= 60 * ($minutes = (int) floor($timespan / 60));
// Seconds ago, 1
isset($seconds) and $seconds = $timespan;
// Remove the variables that cannot be accessed
unset($timespan, $time1, $time2);
// Deny access to these variables
$deny = array_flip(array('deny', 'key', 'difference', 'output'));
// Return the difference
$difference = array();
foreach ($output as $key)
{
if (isset($$key) AND ! isset($deny[$key]))
{
// Add requested key to the output
$difference[$key] = $$key;
}
}
// Invalid output formats string
if (empty($difference))
return FALSE;
// If only one output format was asked, don't put it in an array
if (count($difference) === 1)
return current($difference);
// Return array
return $difference;
}
/**
* Returns time difference between two timestamps, in the format:
* N year, N months, N weeks, N days, N hours, N minutes, and N seconds ago
*
* @param integer timestamp
* @param integer timestamp, defaults to the current time
* @param string formatting string
* @return string
*/
public static function timespan_string($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds')
{
if ($difference = date::timespan($time1, $time2, $output) AND is_array($difference))
{
// Determine the key of the last item in the array
$last = end($difference);
$last = key($difference);
$span = array();
foreach ($difference as $name => $amount)
{
if ($amount === 0)
{
// Skip empty amounts
continue;
}
// Add the amount to the span
$span[] = ($name === $last ? ' and ' : ', ').$amount.' '.($amount === 1 ? inflector::singular($name) : $name);
}
// If the difference is less than 60 seconds, remove the preceding and.
if (count($span) === 1)
{
$span[0] = ltrim($span[0], 'and ');
}
// Replace difference by making the span into a string
$difference = trim(implode('', $span), ',');
}
elseif (is_int($difference))
{
// Single-value return
$difference = $difference.' '.($difference === 1 ? inflector::singular($output) : $output);
}
return $difference;
}
} // End date

View File

@ -0,0 +1,105 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Download helper class.
*
* $Id: download.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class download_Core {
/**
* Force a download of a file to the user's browser. This function is
* binary-safe and will work with any MIME type that Kohana is aware of.
*
* @param string a file path or file name
* @param mixed data to be sent if the filename does not exist
* @param string suggested filename to display in the download
* @return void
*/
public static function force($filename = NULL, $data = NULL, $nicename = NULL)
{
if (empty($filename))
return FALSE;
if (is_file($filename))
{
// Get the real path
$filepath = str_replace('\\', '/', realpath($filename));
// Set filesize
$filesize = filesize($filepath);
// Get filename
$filename = substr(strrchr('/'.$filepath, '/'), 1);
// Get extension
$extension = strtolower(substr(strrchr($filepath, '.'), 1));
}
else
{
// Get filesize
$filesize = strlen($data);
// Make sure the filename does not have directory info
$filename = substr(strrchr('/'.$filename, '/'), 1);
// Get extension
$extension = strtolower(substr(strrchr($filename, '.'), 1));
}
// Get the mime type of the file
$mime = Kohana::config('mimes.'.$extension);
if (empty($mime))
{
// Set a default mime if none was found
$mime = array('application/octet-stream');
}
// Generate the server headers
header('Content-Type: '.$mime[0]);
header('Content-Disposition: attachment; filename="'.(empty($nicename) ? $filename : $nicename).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.sprintf('%d', $filesize));
// More caching prevention
header('Expires: 0');
if (Kohana::user_agent('browser') === 'Internet Explorer')
{
// Send IE headers
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
// Send normal headers
header('Pragma: no-cache');
}
// Clear the output buffer
Kohana::close_buffers(FALSE);
if (isset($filepath))
{
// Open the file
$handle = fopen($filepath, 'rb');
// Send the file data
fpassthru($handle);
// Close the file
fclose($handle);
}
else
{
// Send the file data
echo $data;
}
}
} // End download

View File

@ -0,0 +1,181 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Email helper class.
*
* $Id: email.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class email_Core {
// SwiftMailer instance
protected static $mail;
/**
* Creates a SwiftMailer instance.
*
* @param string DSN connection string
* @return object Swift object
*/
public static function connect($config = NULL)
{
if ( ! class_exists('Swift', FALSE))
{
// Load SwiftMailer
require Kohana::find_file('vendor', 'swift/Swift');
// Register the Swift ClassLoader as an autoload
spl_autoload_register(array('Swift_ClassLoader', 'load'));
}
// Load default configuration
($config === NULL) and $config = Kohana::config('email');
switch ($config['driver'])
{
case 'smtp':
// Set port
$port = empty($config['options']['port']) ? NULL : (int) $config['options']['port'];
if (empty($config['options']['encryption']))
{
// No encryption
$encryption = Swift_Connection_SMTP::ENC_OFF;
}
else
{
// Set encryption
switch (strtolower($config['options']['encryption']))
{
case 'tls': $encryption = Swift_Connection_SMTP::ENC_TLS; break;
case 'ssl': $encryption = Swift_Connection_SMTP::ENC_SSL; break;
}
}
// Create a SMTP connection
$connection = new Swift_Connection_SMTP($config['options']['hostname'], $port, $encryption);
// Do authentication, if part of the DSN
empty($config['options']['username']) or $connection->setUsername($config['options']['username']);
empty($config['options']['password']) or $connection->setPassword($config['options']['password']);
if ( ! empty($config['options']['auth']))
{
// Get the class name and params
list ($class, $params) = arr::callback_string($config['options']['auth']);
if ($class === 'PopB4Smtp')
{
// Load the PopB4Smtp class manually, due to its odd filename
require Kohana::find_file('vendor', 'swift/Swift/Authenticator/$PopB4Smtp$');
}
// Prepare the class name for auto-loading
$class = 'Swift_Authenticator_'.$class;
// Attach the authenticator
$connection->attachAuthenticator(($params === NULL) ? new $class : new $class($params[0]));
}
// Set the timeout to 5 seconds
$connection->setTimeout(empty($config['options']['timeout']) ? 5 : (int) $config['options']['timeout']);
break;
case 'sendmail':
// Create a sendmail connection
$connection = new Swift_Connection_Sendmail
(
empty($config['options']) ? Swift_Connection_Sendmail::AUTO_DETECT : $config['options']
);
// Set the timeout to 5 seconds
$connection->setTimeout(5);
break;
default:
// Use the native connection
$connection = new Swift_Connection_NativeMail($config['options']);
break;
}
// Create the SwiftMailer instance
return email::$mail = new Swift($connection);
}
/**
* Send an email message.
*
* @param string|array recipient email (and name), or an array of To, Cc, Bcc names
* @param string|array sender email (and name)
* @param string message subject
* @param string message body
* @param boolean send email as HTML
* @return integer number of emails sent
*/
public static function send($to, $from, $subject, $message, $html = FALSE)
{
// Connect to SwiftMailer
(email::$mail === NULL) and email::connect();
// Determine the message type
$html = ($html === TRUE) ? 'text/html' : 'text/plain';
// Create the message
$message = new Swift_Message($subject, $message, $html, '8bit', 'utf-8');
if (is_string($to))
{
// Single recipient
$recipients = new Swift_Address($to);
}
elseif (is_array($to))
{
if (isset($to[0]) AND isset($to[1]))
{
// Create To: address set
$to = array('to' => $to);
}
// Create a list of recipients
$recipients = new Swift_RecipientList;
foreach ($to as $method => $set)
{
if ( ! in_array($method, array('to', 'cc', 'bcc')))
{
// Use To: by default
$method = 'to';
}
// Create method name
$method = 'add'.ucfirst($method);
if (is_array($set))
{
// Add a recipient with name
$recipients->$method($set[0], $set[1]);
}
else
{
// Add a recipient without name
$recipients->$method($set);
}
}
}
if (is_string($from))
{
// From without a name
$from = new Swift_Address($from);
}
elseif (is_array($from))
{
// From with a name
$from = new Swift_Address($from[0], $from[1]);
}
return email::$mail->send($message, $recipients, $from);
}
} // End email

View File

@ -0,0 +1,111 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Controls headers that effect client caching of pages
*
* $Id: expires.php 4272 2009-04-25 21:47:26Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class expires_Core {
/**
* Sets the amount of time before a page expires
*
* @param integer Seconds before the page expires
* @return boolean
*/
public static function set($seconds = 60)
{
if (expires::check_headers())
{
$now = $expires = time();
// Set the expiration timestamp
$expires += $seconds;
// Send headers
header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $now));
header('Expires: '.gmdate('D, d M Y H:i:s T', $expires));
header('Cache-Control: max-age='.$seconds);
return $expires;
}
return FALSE;
}
/**
* Checks to see if a page should be updated or send Not Modified status
*
* @param integer Seconds added to the modified time received to calculate what should be sent
* @return bool FALSE when the request needs to be updated
*/
public static function check($seconds = 60)
{
if ( ! empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) AND expires::check_headers())
{
if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== FALSE)
{
// IE6 and perhaps other IE versions send length too, compensate here
$mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
}
else
{
$mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
$mod_time = strtotime($mod_time);
$mod_time_diff = $mod_time + $seconds - time();
if ($mod_time_diff > 0)
{
// Re-send headers
header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $mod_time));
header('Expires: '.gmdate('D, d M Y H:i:s T', time() + $mod_time_diff));
header('Cache-Control: max-age='.$mod_time_diff);
header('Status: 304 Not Modified', TRUE, 304);
// Prevent any output
Event::add('system.display', array('expires', 'prevent_output'));
// Exit to prevent other output
exit;
}
}
return FALSE;
}
/**
* Check headers already created to not step on download or Img_lib's feet
*
* @return boolean
*/
public static function check_headers()
{
foreach (headers_list() as $header)
{
if ((session_cache_limiter() == '' AND stripos($header, 'Last-Modified:') === 0)
OR stripos($header, 'Expires:') === 0)
{
return FALSE;
}
}
return TRUE;
}
/**
* Prevent any output from being displayed. Executed during system.display.
*
* @return void
*/
public static function prevent_output()
{
Kohana::$output = '';
}
} // End expires

View File

@ -0,0 +1,122 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Feed helper class.
*
* $Id: feed.php 4152 2009-04-03 23:26:23Z ixmatus $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class feed_Core {
/**
* Parses a remote feed into an array.
*
* @param string remote feed URL
* @param integer item limit to fetch
* @return array
*/
public static function parse($feed, $limit = 0)
{
// Check if SimpleXML is installed
if( ! function_exists('simplexml_load_file'))
throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
// Make limit an integer
$limit = (int) $limit;
// Disable error reporting while opening the feed
$ER = error_reporting(0);
// Allow loading by filename or raw XML string
$load = (is_file($feed) OR valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
// Load the feed
$feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
// Restore error reporting
error_reporting($ER);
// Feed could not be loaded
if ($feed === FALSE)
return array();
// Detect the feed type. RSS 1.0/2.0 and Atom 1.0 are supported.
$feed = isset($feed->channel) ? $feed->xpath('//item') : $feed->entry;
$i = 0;
$items = array();
foreach ($feed as $item)
{
if ($limit > 0 AND $i++ === $limit)
break;
$items[] = (array) $item;
}
return $items;
}
/**
* Creates a feed from the given parameters.
*
* @param array feed information
* @param array items to add to the feed
* @param string define which format to use
* @param string define which encoding to use
* @return string
*/
public static function create($info, $items, $format = 'rss2', $encoding = 'UTF-8')
{
$info += array('title' => 'Generated Feed', 'link' => '', 'generator' => 'KohanaPHP');
$feed = '<?xml version="1.0" encoding="'.$encoding.'"?><rss version="2.0"><channel></channel></rss>';
$feed = simplexml_load_string($feed);
foreach ($info as $name => $value)
{
if (($name === 'pubDate' OR $name === 'lastBuildDate') AND (is_int($value) OR ctype_digit($value)))
{
// Convert timestamps to RFC 822 formatted dates
$value = date(DATE_RFC822, $value);
}
elseif (($name === 'link' OR $name === 'docs') AND strpos($value, '://') === FALSE)
{
// Convert URIs to URLs
$value = url::site($value, 'http');
}
// Add the info to the channel
$feed->channel->addChild($name, $value);
}
foreach ($items as $item)
{
// Add the item to the channel
$row = $feed->channel->addChild('item');
foreach ($item as $name => $value)
{
if ($name === 'pubDate' AND (is_int($value) OR ctype_digit($value)))
{
// Convert timestamps to RFC 822 formatted dates
$value = date(DATE_RFC822, $value);
}
elseif (($name === 'link' OR $name === 'guid') AND strpos($value, '://') === FALSE)
{
// Convert URIs to URLs
$value = url::site($value, 'http');
}
// Add the info to the row
$row->addChild($name, $value);
}
}
return $feed->asXML();
}
} // End feed

View File

@ -0,0 +1,186 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* File helper class.
*
* $Id: file.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class file_Core {
/**
* Attempt to get the mime type from a file. This method is horribly
* unreliable, due to PHP being horribly unreliable when it comes to
* determining the mime-type of a file.
*
* @param string filename
* @return string mime-type, if found
* @return boolean FALSE, if not found
*/
public static function mime($filename)
{
// Make sure the file is readable
if ( ! (is_file($filename) AND is_readable($filename)))
return FALSE;
// Get the extension from the filename
$extension = strtolower(substr(strrchr($filename, '.'), 1));
if (preg_match('/^(?:jpe?g|png|[gt]if|bmp|swf)$/', $extension))
{
// Disable error reporting
$ER = error_reporting(0);
// Use getimagesize() to find the mime type on images
$mime = getimagesize($filename);
// Turn error reporting back on
error_reporting($ER);
// Return the mime type
if (isset($mime['mime']))
return $mime['mime'];
}
if (function_exists('finfo_open'))
{
// Use the fileinfo extension
$finfo = finfo_open(FILEINFO_MIME);
$mime = finfo_file($finfo, $filename);
finfo_close($finfo);
// Return the mime type
return $mime;
}
if (ini_get('mime_magic.magicfile') AND function_exists('mime_content_type'))
{
// Return the mime type using mime_content_type
return mime_content_type($filename);
}
if ( ! KOHANA_IS_WIN)
{
// Attempt to locate use the file command, checking the return value
if ($command = trim(exec('which file', $output, $return)) AND $return === 0)
{
return trim(exec($command.' -bi '.escapeshellarg($filename)));
}
}
if ( ! empty($extension) AND is_array($mime = Kohana::config('mimes.'.$extension)))
{
// Return the mime-type guess, based on the extension
return $mime[0];
}
// Unable to find the mime-type
return FALSE;
}
/**
* Split a file into pieces matching a specific size.
*
* @param string file to be split
* @param string directory to output to, defaults to the same directory as the file
* @param integer size, in MB, for each chunk to be
* @return integer The number of pieces that were created.
*/
public static function split($filename, $output_dir = FALSE, $piece_size = 10)
{
// Find output dir
$output_dir = ($output_dir == FALSE) ? pathinfo(str_replace('\\', '/', realpath($filename)), PATHINFO_DIRNAME) : str_replace('\\', '/', realpath($output_dir));
$output_dir = rtrim($output_dir, '/').'/';
// Open files for writing
$input_file = fopen($filename, 'rb');
// Change the piece size to bytes
$piece_size = 1024 * 1024 * (int) $piece_size; // Size in bytes
// Set up reading variables
$read = 0; // Number of bytes read
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Split the file
while ( ! feof($input_file))
{
// Open a new piece
$piece_name = $filename.'.'.str_pad($piece, 3, '0', STR_PAD_LEFT);
$piece_open = @fopen($piece_name, 'wb+') or die('Could not write piece '.$piece_name);
// Fill the current piece
while ($read < $piece_size AND $data = fread($input_file, $chunk))
{
fwrite($piece_open, $data) or die('Could not write to open piece '.$piece_name);
$read += $chunk;
}
// Close the current piece
fclose($piece_open);
// Prepare to open a new piece
$read = 0;
$piece++;
// Make sure that piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded, try a larger piece size');
}
// Close input file
fclose($input_file);
// Returns the number of pieces that were created
return ($piece - 1);
}
/**
* Join a split file into a whole file.
*
* @param string split filename, without .000 extension
* @param string output filename, if different then an the filename
* @return integer The number of pieces that were joined.
*/
public static function join($filename, $output = FALSE)
{
if ($output == FALSE)
$output = $filename;
// Set up reading variables
$piece = 1; // Current piece
$chunk = 1024 * 8; // Chunk size to read
// Open output file
$output_file = @fopen($output, 'wb+') or die('Could not open output file '.$output);
// Read each piece
while ($piece_open = @fopen(($piece_name = $filename.'.'.str_pad($piece, 3, '0', STR_PAD_LEFT)), 'rb'))
{
// Write the piece into the output file
while ( ! feof($piece_open))
{
fwrite($output_file, fread($piece_open, $chunk));
}
// Close the current piece
fclose($piece_open);
// Prepare for a new piece
$piece++;
// Make sure piece is valid
($piece < 999) or die('Maximum of 999 pieces exceeded');
}
// Close the output file
fclose($output_file);
// Return the number of pieces joined
return ($piece - 1);
}
} // End file

View File

@ -0,0 +1,542 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Form helper class.
*
* $Id: form.php 4291 2009-04-29 22:51:58Z kiall $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class form_Core {
/**
* Generates an opening HTML form tag.
*
* @param string form action attribute
* @param array extra attributes
* @param array hidden fields to be created immediately after the form tag
* @return string
*/
public static function open($action = NULL, $attr = array(), $hidden = NULL)
{
// Make sure that the method is always set
empty($attr['method']) and $attr['method'] = 'post';
if ($attr['method'] !== 'post' AND $attr['method'] !== 'get')
{
// If the method is invalid, use post
$attr['method'] = 'post';
}
if ($action === NULL)
{
// Use the current URL as the default action
$action = url::site(Router::$complete_uri);
}
elseif (strpos($action, '://') === FALSE)
{
// Make the action URI into a URL
$action = url::site($action);
}
// Set action
$attr['action'] = $action;
// Form opening tag
$form = '<form'.form::attributes($attr).'>'."\n";
// Add hidden fields immediate after opening tag
empty($hidden) or $form .= form::hidden($hidden);
return $form;
}
/**
* Generates an opening HTML form tag that can be used for uploading files.
*
* @param string form action attribute
* @param array extra attributes
* @param array hidden fields to be created immediately after the form tag
* @return string
*/
public static function open_multipart($action = NULL, $attr = array(), $hidden = array())
{
// Set multi-part form type
$attr['enctype'] = 'multipart/form-data';
return form::open($action, $attr, $hidden);
}
/**
* Generates a fieldset opening tag.
*
* @param array html attributes
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function open_fieldset($data = NULL, $extra = '')
{
return '<fieldset'.html::attributes((array) $data).' '.$extra.'>'."\n";
}
/**
* Generates a fieldset closing tag.
*
* @return string
*/
public static function close_fieldset()
{
return '</fieldset>'."\n";
}
/**
* Generates a legend tag for use with a fieldset.
*
* @param string legend text
* @param array HTML attributes
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function legend($text = '', $data = NULL, $extra = '')
{
return '<legend'.form::attributes((array) $data).' '.$extra.'>'.$text.'</legend>'."\n";
}
/**
* Generates hidden form fields.
* You can pass a simple key/value string or an associative array with multiple values.
*
* @param string|array input name (string) or key/value pairs (array)
* @param string input value, if using an input name
* @return string
*/
public static function hidden($data, $value = '')
{
if ( ! is_array($data))
{
$data = array
(
$data => $value
);
}
$input = '';
foreach ($data as $name => $value)
{
$attr = array
(
'type' => 'hidden',
'name' => $name,
'value' => $value
);
$input .= form::input($attr)."\n";
}
return $input;
}
/**
* Creates an HTML form input tag. Defaults to a text type.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function input($data, $value = '', $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
// Type and value are required attributes
$data += array
(
'type' => 'text',
'value' => $value
);
return '<input'.form::attributes($data).' '.$extra.' />';
}
/**
* Creates a HTML form password input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function password($data, $value = '', $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
$data['type'] = 'password';
return form::input($data, $value, $extra);
}
/**
* Creates an HTML form upload input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function upload($data, $value = '', $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
$data['type'] = 'file';
return form::input($data, $value, $extra);
}
/**
* Creates an HTML form textarea tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @param boolean encode existing entities
* @return string
*/
public static function textarea($data, $value = '', $extra = '', $double_encode = TRUE)
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
// Use the value from $data if possible, or use $value
$value = isset($data['value']) ? $data['value'] : $value;
// Value is not part of the attributes
unset($data['value']);
return '<textarea'.form::attributes($data, 'textarea').' '.$extra.'>'.html::specialchars($value, $double_encode).'</textarea>';
}
/**
* Creates an HTML form select tag, or "dropdown menu".
*
* @param string|array input name or an array of HTML attributes
* @param array select options, when using a name
* @param string|array option key(s) that should be selected by default
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function dropdown($data, $options = NULL, $selected = NULL, $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
else
{
if (isset($data['options']))
{
// Use data options
$options = $data['options'];
}
if (isset($data['selected']))
{
// Use data selected
$selected = $data['selected'];
}
}
if (is_array($selected))
{
// Multi-select box
$data['multiple'] = 'multiple';
}
else
{
// Single selection (but converted to an array)
$selected = array($selected);
}
$input = '<select'.form::attributes($data, 'select').' '.$extra.'>'."\n";
foreach ((array) $options as $key => $val)
{
// Key should always be a string
$key = (string) $key;
if (is_array($val))
{
$input .= '<optgroup label="'.$key.'">'."\n";
foreach ($val as $inner_key => $inner_val)
{
// Inner key should always be a string
$inner_key = (string) $inner_key;
$sel = in_array($inner_key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="'.$inner_key.'"'.$sel.'>'.$inner_val.'</option>'."\n";
}
$input .= '</optgroup>'."\n";
}
else
{
$sel = in_array($key, $selected) ? ' selected="selected"' : '';
$input .= '<option value="'.$key.'"'.$sel.'>'.$val.'</option>'."\n";
}
}
$input .= '</select>';
return $input;
}
/**
* Creates an HTML form checkbox input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param boolean make the checkbox checked by default
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function checkbox($data, $value = '', $checked = FALSE, $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
$data['type'] = 'checkbox';
if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
{
$data['checked'] = 'checked';
}
else
{
unset($data['checked']);
}
return form::input($data, $value, $extra);
}
/**
* Creates an HTML form radio input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param boolean make the radio selected by default
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function radio($data = '', $value = '', $checked = FALSE, $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
$data['type'] = 'radio';
if ($checked == TRUE OR (isset($data['checked']) AND $data['checked'] == TRUE))
{
$data['checked'] = 'checked';
}
else
{
unset($data['checked']);
}
return form::input($data, $value, $extra);
}
/**
* Creates an HTML form submit input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function submit($data = '', $value = '', $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
if (empty($data['name']))
{
// Remove the name if it is empty
unset($data['name']);
}
$data['type'] = 'submit';
return form::input($data, $value, $extra);
}
/**
* Creates an HTML form button input tag.
*
* @param string|array input name or an array of HTML attributes
* @param string input value, when using a name
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function button($data = '', $value = '', $extra = '')
{
if ( ! is_array($data))
{
$data = array('name' => $data);
}
if (empty($data['name']))
{
// Remove the name if it is empty
unset($data['name']);
}
if (isset($data['value']) AND empty($value))
{
$value = arr::remove('value', $data);
}
return '<button'.form::attributes($data, 'button').' '.$extra.'>'.$value.'</button>';
}
/**
* Closes an open form tag.
*
* @param string string to be attached after the closing tag
* @return string
*/
public static function close($extra = '')
{
return '</form>'."\n".$extra;
}
/**
* Creates an HTML form label tag.
*
* @param string|array label "for" name or an array of HTML attributes
* @param string label text or HTML
* @param string a string to be attached to the end of the attributes
* @return string
*/
public static function label($data = '', $text = NULL, $extra = '')
{
if ( ! is_array($data))
{
if (is_string($data))
{
// Specify the input this label is for
$data = array('for' => $data);
}
else
{
// No input specified
$data = array();
}
}
if ($text === NULL AND isset($data['for']))
{
// Make the text the human-readable input name
$text = ucwords(inflector::humanize($data['for']));
}
return '<label'.form::attributes($data).' '.$extra.'>'.$text.'</label>';
}
/**
* Sorts a key/value array of HTML attributes, putting form attributes first,
* and returns an attribute string.
*
* @param array HTML attributes array
* @return string
*/
public static function attributes($attr, $type = NULL)
{
if (empty($attr))
return '';
if (isset($attr['name']) AND empty($attr['id']) AND strpos($attr['name'], '[') === FALSE)
{
if ($type === NULL AND ! empty($attr['type']))
{
// Set the type by the attributes
$type = $attr['type'];
}
switch ($type)
{
case 'text':
case 'textarea':
case 'password':
case 'select':
case 'checkbox':
case 'file':
case 'image':
case 'button':
case 'submit':
// Only specific types of inputs use name to id matching
$attr['id'] = $attr['name'];
break;
}
}
$order = array
(
'action',
'method',
'type',
'id',
'name',
'value',
'src',
'size',
'maxlength',
'rows',
'cols',
'accept',
'tabindex',
'accesskey',
'align',
'alt',
'title',
'class',
'style',
'selected',
'checked',
'readonly',
'disabled'
);
$sorted = array();
foreach ($order as $key)
{
if (isset($attr[$key]))
{
// Move the attribute to the sorted array
$sorted[$key] = $attr[$key];
// Remove the attribute from unsorted array
unset($attr[$key]);
}
}
// Combine the sorted and unsorted attributes and create an HTML string
return html::attributes(array_merge($sorted, $attr));
}
} // End form

View File

@ -0,0 +1,66 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Format helper class.
*
* $Id: format.php 4070 2009-03-11 20:37:38Z Geert $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class format_Core {
/**
* Formats a phone number according to the specified format.
*
* @param string phone number
* @param string format string
* @return string
*/
public static function phone($number, $format = '3-3-4')
{
// Get rid of all non-digit characters in number string
$number_clean = preg_replace('/\D+/', '', (string) $number);
// Array of digits we need for a valid format
$format_parts = preg_split('/[^1-9][^0-9]*/', $format, -1, PREG_SPLIT_NO_EMPTY);
// Number must match digit count of a valid format
if (strlen($number_clean) !== array_sum($format_parts))
return $number;
// Build regex
$regex = '(\d{'.implode('})(\d{', $format_parts).'})';
// Build replace string
for ($i = 1, $c = count($format_parts); $i <= $c; $i++)
{
$format = preg_replace('/(?<!\$)[1-9][0-9]*/', '\$'.$i, $format, 1);
}
// Hocus pocus!
return preg_replace('/^'.$regex.'$/', $format, $number_clean);
}
/**
* Formats a URL to contain a protocol at the beginning.
*
* @param string possibly incomplete URL
* @return string
*/
public static function url($str = '')
{
// Clear protocol-only strings like "http://"
if ($str === '' OR substr($str, -3) === '://')
return '';
// If no protocol given, prepend "http://" by default
if (strpos($str, '://') === FALSE)
return 'http://'.$str;
// Return the original URL
return $str;
}
} // End format

View File

@ -0,0 +1,446 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* HTML helper class.
*
* $Id: html.php 4376 2009-06-01 11:40:39Z samsoir $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class html_Core {
// Enable or disable automatic setting of target="_blank"
public static $windowed_urls = FALSE;
/**
* Convert special characters to HTML entities
*
* @param string string to convert
* @param boolean encode existing entities
* @return string
*/
public static function specialchars($str, $double_encode = TRUE)
{
// Force the string to be a string
$str = (string) $str;
// Do encode existing HTML entities (default)
if ($double_encode === TRUE)
{
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
else
{
// Do not encode existing HTML entities
// From PHP 5.2.3 this functionality is built-in, otherwise use a regex
if (version_compare(PHP_VERSION, '5.2.3', '>='))
{
$str = htmlspecialchars($str, ENT_QUOTES, 'UTF-8', FALSE);
}
else
{
$str = preg_replace('/&(?!(?:#\d++|[a-z]++);)/ui', '&amp;', $str);
$str = str_replace(array('<', '>', '\'', '"'), array('&lt;', '&gt;', '&#39;', '&quot;'), $str);
}
}
return $str;
}
/**
* Perform a html::specialchars() with additional URL specific encoding.
*
* @param string string to convert
* @param boolean encode existing entities
* @return string
*/
public static function specialurlencode($str, $double_encode = TRUE)
{
return str_replace(' ', '%20', html::specialchars($str, $double_encode));
}
/**
* Create HTML link anchors.
*
* @param string URL or URI string
* @param string link text
* @param array HTML anchor attributes
* @param string non-default protocol, eg: https
* @param boolean option to escape the title that is output
* @return string
*/
public static function anchor($uri, $title = NULL, $attributes = NULL, $protocol = NULL, $escape_title = FALSE)
{
if ($uri === '')
{
$site_url = url::base(FALSE);
}
elseif (strpos($uri, '#') === 0)
{
// This is an id target link, not a URL
$site_url = $uri;
}
elseif (strpos($uri, '://') === FALSE)
{
$site_url = url::site($uri, $protocol);
}
else
{
if (html::$windowed_urls === TRUE AND empty($attributes['target']))
{
$attributes['target'] = '_blank';
}
$site_url = $uri;
}
return
// Parsed URL
'<a href="'.html::specialurlencode($site_url, FALSE).'"'
// Attributes empty? Use an empty string
.(is_array($attributes) ? html::attributes($attributes) : '').'>'
// Title empty? Use the parsed URL
.($escape_title ? html::specialchars((($title === NULL) ? $site_url : $title), FALSE) : (($title === NULL) ? $site_url : $title)).'</a>';
}
/**
* Creates an HTML anchor to a file.
*
* @param string name of file to link to
* @param string link text
* @param array HTML anchor attributes
* @param string non-default protocol, eg: ftp
* @return string
*/
public static function file_anchor($file, $title = NULL, $attributes = NULL, $protocol = NULL)
{
return
// Base URL + URI = full URL
'<a href="'.html::specialurlencode(url::base(FALSE, $protocol).$file, FALSE).'"'
// Attributes empty? Use an empty string
.(is_array($attributes) ? html::attributes($attributes) : '').'>'
// Title empty? Use the filename part of the URI
.(($title === NULL) ? end(explode('/', $file)) : $title) .'</a>';
}
/**
* Similar to anchor, but with the protocol parameter first.
*
* @param string link protocol
* @param string URI or URL to link to
* @param string link text
* @param array HTML anchor attributes
* @return string
*/
public static function panchor($protocol, $uri, $title = NULL, $attributes = FALSE)
{
return html::anchor($uri, $title, $attributes, $protocol);
}
/**
* Create an array of anchors from an array of link/title pairs.
*
* @param array link/title pairs
* @return array
*/
public static function anchor_array(array $array)
{
$anchors = array();
foreach ($array as $link => $title)
{
// Create list of anchors
$anchors[] = html::anchor($link, $title);
}
return $anchors;
}
/**
* Generates an obfuscated version of an email address.
*
* @param string email address
* @return string
*/
public static function email($email)
{
$safe = '';
foreach (str_split($email) as $letter)
{
switch (($letter === '@') ? rand(1, 2) : rand(1, 3))
{
// HTML entity code
case 1: $safe .= '&#'.ord($letter).';'; break;
// Hex character code
case 2: $safe .= '&#x'.dechex(ord($letter)).';'; break;
// Raw (no) encoding
case 3: $safe .= $letter;
}
}
return $safe;
}
/**
* Creates an email anchor.
*
* @param string email address to send to
* @param string link text
* @param array HTML anchor attributes
* @return string
*/
public static function mailto($email, $title = NULL, $attributes = NULL)
{
if (empty($email))
return $title;
// Remove the subject or other parameters that do not need to be encoded
if (strpos($email, '?') !== FALSE)
{
// Extract the parameters from the email address
list ($email, $params) = explode('?', $email, 2);
// Make the params into a query string, replacing spaces
$params = '?'.str_replace(' ', '%20', $params);
}
else
{
// No parameters
$params = '';
}
// Obfuscate email address
$safe = html::email($email);
// Title defaults to the encoded email address
empty($title) and $title = $safe;
// Parse attributes
empty($attributes) or $attributes = html::attributes($attributes);
// Encoded start of the href="" is a static encoded version of 'mailto:'
return '<a href="&#109;&#097;&#105;&#108;&#116;&#111;&#058;'.$safe.$params.'"'.$attributes.'>'.$title.'</a>';
}
/**
* Generate a "breadcrumb" list of anchors representing the URI.
*
* @param array segments to use as breadcrumbs, defaults to using Router::$segments
* @return string
*/
public static function breadcrumb($segments = NULL)
{
empty($segments) and $segments = Router::$segments;
$array = array();
while ($segment = array_pop($segments))
{
$array[] = html::anchor
(
// Complete URI for the URL
implode('/', $segments).'/'.$segment,
// Title for the current segment
ucwords(inflector::humanize($segment))
);
}
// Retrun the array of all the segments
return array_reverse($array);
}
/**
* Creates a meta tag.
*
* @param string|array tag name, or an array of tags
* @param string tag "content" value
* @return string
*/
public static function meta($tag, $value = NULL)
{
if (is_array($tag))
{
$tags = array();
foreach ($tag as $t => $v)
{
// Build each tag and add it to the array
$tags[] = html::meta($t, $v);
}
// Return all of the tags as a string
return implode("\n", $tags);
}
// Set the meta attribute value
$attr = in_array(strtolower($tag), Kohana::config('http.meta_equiv')) ? 'http-equiv' : 'name';
return '<meta '.$attr.'="'.$tag.'" content="'.$value.'" />';
}
/**
* Creates a stylesheet link.
*
* @param string|array filename, or array of filenames to match to array of medias
* @param string|array media type of stylesheet, or array to match filenames
* @param boolean include the index_page in the link
* @return string
*/
public static function stylesheet($style, $media = FALSE, $index = FALSE)
{
return html::link($style, 'stylesheet', 'text/css', '.css', $media, $index);
}
/**
* Creates a link tag.
*
* @param string|array filename
* @param string|array relationship
* @param string|array mimetype
* @param string specifies suffix of the file
* @param string|array specifies on what device the document will be displayed
* @param boolean include the index_page in the link
* @return string
*/
public static function link($href, $rel, $type, $suffix = FALSE, $media = FALSE, $index = FALSE)
{
$compiled = '';
if (is_array($href))
{
foreach ($href as $_href)
{
$_rel = is_array($rel) ? array_shift($rel) : $rel;
$_type = is_array($type) ? array_shift($type) : $type;
$_media = is_array($media) ? array_shift($media) : $media;
$compiled .= html::link($_href, $_rel, $_type, $suffix, $_media, $index);
}
}
else
{
if (strpos($href, '://') === FALSE)
{
// Make the URL absolute
$href = url::base($index).$href;
}
$length = strlen($suffix);
if ( $length > 0 AND substr_compare($href, $suffix, -$length, $length, FALSE) !== 0)
{
// Add the defined suffix
$href .= $suffix;
}
$attr = array
(
'rel' => $rel,
'type' => $type,
'href' => $href,
);
if ( ! empty($media))
{
// Add the media type to the attributes
$attr['media'] = $media;
}
$compiled = '<link'.html::attributes($attr).' />';
}
return $compiled."\n";
}
/**
* Creates a script link.
*
* @param string|array filename
* @param boolean include the index_page in the link
* @return string
*/
public static function script($script, $index = FALSE)
{
$compiled = '';
if (is_array($script))
{
foreach ($script as $name)
{
$compiled .= html::script($name, $index);
}
}
else
{
if (strpos($script, '://') === FALSE)
{
// Add the suffix only when it's not already present
$script = url::base((bool) $index).$script;
}
if (substr_compare($script, '.js', -3, 3, FALSE) !== 0)
{
// Add the javascript suffix
$script .= '.js';
}
$compiled = '<script type="text/javascript" src="'.$script.'"></script>';
}
return $compiled."\n";
}
/**
* Creates a image link.
*
* @param string image source, or an array of attributes
* @param string|array image alt attribute, or an array of attributes
* @param boolean include the index_page in the link
* @return string
*/
public static function image($src = NULL, $alt = NULL, $index = FALSE)
{
// Create attribute list
$attributes = is_array($src) ? $src : array('src' => $src);
if (is_array($alt))
{
$attributes += $alt;
}
elseif ( ! empty($alt))
{
// Add alt to attributes
$attributes['alt'] = $alt;
}
if (strpos($attributes['src'], '://') === FALSE)
{
// Make the src attribute into an absolute URL
$attributes['src'] = url::base($index).$attributes['src'];
}
return '<img'.html::attributes($attributes).' />';
}
/**
* Compiles an array of HTML attributes into an attribute string.
*
* @param string|array array of attributes
* @return string
*/
public static function attributes($attrs)
{
if (empty($attrs))
return '';
if (is_string($attrs))
return ' '.$attrs;
$compiled = '';
foreach ($attrs as $key => $val)
{
$compiled .= ' '.$key.'="'.html::specialchars($val).'"';
}
return $compiled;
}
} // End html

View File

@ -0,0 +1,193 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Inflector helper class.
*
* $Id: inflector.php 4072 2009-03-13 17:20:38Z jheathco $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class inflector_Core {
// Cached inflections
protected static $cache = array();
// Uncountable and irregular words
protected static $uncountable;
protected static $irregular;
/**
* Checks if a word is defined as uncountable.
*
* @param string word to check
* @return boolean
*/
public static function uncountable($str)
{
if (inflector::$uncountable === NULL)
{
// Cache uncountables
inflector::$uncountable = Kohana::config('inflector.uncountable');
// Make uncountables mirroed
inflector::$uncountable = array_combine(inflector::$uncountable, inflector::$uncountable);
}
return isset(inflector::$uncountable[strtolower($str)]);
}
/**
* Makes a plural word singular.
*
* @param string word to singularize
* @param integer number of things
* @return string
*/
public static function singular($str, $count = NULL)
{
// Remove garbage
$str = strtolower(trim($str));
if (is_string($count))
{
// Convert to integer when using a digit string
$count = (int) $count;
}
// Do nothing with a single count
if ($count === 0 OR $count > 1)
return $str;
// Cache key name
$key = 'singular_'.$str.$count;
if (isset(inflector::$cache[$key]))
return inflector::$cache[$key];
if (inflector::uncountable($str))
return inflector::$cache[$key] = $str;
if (empty(inflector::$irregular))
{
// Cache irregular words
inflector::$irregular = Kohana::config('inflector.irregular');
}
if ($irregular = array_search($str, inflector::$irregular))
{
$str = $irregular;
}
elseif (preg_match('/[sxz]es$/', $str) OR preg_match('/[^aeioudgkprt]hes$/', $str))
{
// Remove "es"
$str = substr($str, 0, -2);
}
elseif (preg_match('/[^aeiou]ies$/', $str))
{
$str = substr($str, 0, -3).'y';
}
elseif (substr($str, -1) === 's' AND substr($str, -2) !== 'ss')
{
$str = substr($str, 0, -1);
}
return inflector::$cache[$key] = $str;
}
/**
* Makes a singular word plural.
*
* @param string word to pluralize
* @return string
*/
public static function plural($str, $count = NULL)
{
// Remove garbage
$str = strtolower(trim($str));
if (is_string($count))
{
// Convert to integer when using a digit string
$count = (int) $count;
}
// Do nothing with singular
if ($count === 1)
return $str;
// Cache key name
$key = 'plural_'.$str.$count;
if (isset(inflector::$cache[$key]))
return inflector::$cache[$key];
if (inflector::uncountable($str))
return inflector::$cache[$key] = $str;
if (empty(inflector::$irregular))
{
// Cache irregular words
inflector::$irregular = Kohana::config('inflector.irregular');
}
if (isset(inflector::$irregular[$str]))
{
$str = inflector::$irregular[$str];
}
elseif (preg_match('/[sxz]$/', $str) OR preg_match('/[^aeioudgkprt]h$/', $str))
{
$str .= 'es';
}
elseif (preg_match('/[^aeiou]y$/', $str))
{
// Change "y" to "ies"
$str = substr_replace($str, 'ies', -1);
}
else
{
$str .= 's';
}
// Set the cache and return
return inflector::$cache[$key] = $str;
}
/**
* Makes a phrase camel case.
*
* @param string phrase to camelize
* @return string
*/
public static function camelize($str)
{
$str = 'x'.strtolower(trim($str));
$str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
return substr(str_replace(' ', '', $str), 1);
}
/**
* Makes a phrase underscored instead of spaced.
*
* @param string phrase to underscore
* @return string
*/
public static function underscore($str)
{
return preg_replace('/\s+/', '_', trim($str));
}
/**
* Makes an underscored or dashed phrase human-reable.
*
* @param string phrase to make human-reable
* @return string
*/
public static function humanize($str)
{
return preg_replace('/[_-]+/', ' ', trim($str));
}
} // End inflector

View File

@ -0,0 +1,26 @@
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Number helper class.
*
* $Id: num.php 3769 2008-12-15 00:48:56Z zombor $
*
* @package Core
* @author Kohana Team
* @copyright (c) 2007-2008 Kohana Team
* @license http://kohanaphp.com/license.html
*/
class num_Core {
/**
* Round a number to the nearest nth
*
* @param integer number to round
* @param integer number to round to
* @return integer
*/
public static function round($number, $nearest = 5)
{
return round($number / $nearest) * $nearest;
}
} // End num

Some files were not shown because too many files have changed in this diff Show More