Merged devel branch into beta and fixed merge conflicts

Merge branch 'devel' into beta

Conflicts:

	ChangeLog
	src/include/functions_common.php
This commit is contained in:
Andre Lorbach 2008-09-24 16:00:34 +02:00
commit 5e7a2d2103
153 changed files with 29678 additions and 3182 deletions

118
ChangeLog
View File

@ -2,16 +2,81 @@
Version 2.4.0 (v2-stable), 2008-09-24
- Merged beta branch into v2-stable branch.
---------------------------------------------------------------------------
Version 2.5.9 (devel), 2008-09-19
- Implemented support to analyze Webserver logfiles from Apache and
Microsoft IIS Webserver. There is a collection of new fields available,
filtering is possible. . In order to read Apache or IIS logfiles,
you need to use the "iis" or "apache2" message parser in your disk
sources.
- Added a new page called "asktheoracle.php" which will be automatically
linked on IP's and domain names. It is a simple helper page which
creates a bunch of usefull filter links.
- Added some basic documentation into the doc folder. phpLogCon
does also link to this documentation now (Help Menu Entry).
- Added a general option to limit the display of string fields.
- Added a general option to configure the timeout value of popup menus.
- Added a general option to alter the php scrip timeout. This is of course
only possible if the php interpreter is allowed to change the script
timeout.
- Added checks for the script timeout in the disk logstream, this avoids
that the script is suddenly stopped by the php interpreter.
- Fixed a sorting bug in the disk logstream, which removed numeric
values in the charts
- Added support to filter for a + character as well now. In order to filter
for strings containing the + character, just add replace it with ++.
A single + will still be equal to a space character in the filter engine.
---------------------------------------------------------------------------
Version 2.5.8 (devel), 2008-09-16
- Added Bitstream Vera Fonts into the package which will be used by the
chart generator. So there won't be a problem of missing truetype fonts
anymore.
- Tweaked the visual appereance of all chart types.
---------------------------------------------------------------------------
Version 2.5.7 (devel), 2008-09-15
- Added Statistics page for chart generation. The following charts are
possible right now: Pie, bars vertical and bars horicontal.
All charts can be configured within the Admin Center, if the user system
is installed and enabled. Custom charts can be added as well.
- Added filter / search support for processid, event category and the
event user field
- Added database update, as we now have a new table to store
configured charts into.
- Fixed a few minor filtering issues, specially with numeric filters.
---------------------------------------------------------------------------
Version 2.3.11 (beta), 2008-09-08
- Fix another parsing issue in the logline parser. Most of RFC 3164
formatted syslog messages should now be correctly splitted into their
fields.
---------------------------------------------------------------------------
Version 2.5.6 (devel), 2008-09-03
- Implemented Message Parser facility. This new extendable facility of
phpLogCon helps splitting messages into fields. And the fields can
be filtered and searched for, this expands the full potential of
phpLogCon. A message parser for windows eventlog logfiles generated
by Adiscon products is included.
- Linebreaks within messages are now displayed in the popup window,
and the detail page.
- Added Database Upgrade functionalety, the reason is simple, because
there was an update to the database structure. If you are using the
User Management system, you will be prompted to upgrade your database
next time you login.
---------------------------------------------------------------------------
Version 2.5.5 (devel), 2008-08-28
- Added option to send debug messages (warnings and error's) from
phpLogCon to the local syslog server on linux. On Windows, the debug
messages will appear in the application event log.
- Enhanced the PDO Logstream Driver for better performance on large
databases. On MYSQL and POSTGRES, the PDO Logstream does not uses the
LIMIT statement to minimize database usage.
---------------------------------------------------------------------------
Version 2.3.10 (beta), 2008-08-27
- Fixed a few parsing issues with prior RFC 3164 syslog messages.
These messages are now correctly parsed, or better do not cause
any parsing problems anymore.
---------------------------------------------------------------------------
Version 2.5.4 (devel), 2008-08-05
- Included fixed from Beta v2.3.9
---------------------------------------------------------------------------
Version 2.3.9 (beta), 2008-08-07
- Fixed a bug in the parsing of RFC 3164 date and time stamps which
occured from the 1st to the 9th of each month. During this time, the
@ -20,6 +85,44 @@ Version 2.3.9 (beta), 2008-08-07
annoying. It still can be turned off very easily.
- Fixed an image alignment problem of the message once and for all.
---------------------------------------------------------------------------
Version 2.5.3 (devel), 2008-08-05
- Added support to export the current visible events into a XML or CSV
file. If you have further recommendations for useful export file
formats, just let us know in the phpLogCon forums or mailinglist.
- Extended Filter Engine to support Full and Partial Text searches on
string fields. The submenu buttons also now use the Full Text search
by default, which performs much better on database logstream sources.
- A new menu entry on each value on each field in the main EventView
gives you the option to search for this field only, or extend an
existing filterset.
---------------------------------------------------------------------------
Version 2.5.2 (devel), 2008-08-01
- General Options are now configureable on user basis, if UserDB System
is installed of course. This means first, phpLogCon used the global
configured options, then the user configured - if available.
- When you add new Sources, the source is checked with better error details.
If you have a database connection, even the existence of the configured
table is checked. This helps locating configuration problems.
- Fixed minor bug in the installer which was added in v2.5.0.
- Fixed spelling errors in the admin index template.
- Error messages in the admin center contain more useful details now.
---------------------------------------------------------------------------
Version 2.5.1 (devel), 2008-07-29
- Added a new option to suppress displaying multiple messages. This
means if you have two or more messages of the exact same text one after
another, only ONE message will be shown. This helps to "compress" the
logview a little bit.
- New feature, added Maximize/Normalize button into the menu. You can
hide the header now by using this feature for maximum log display.
- If the UserDB System is enabled, the donate button will only being
shown within the Admin Center.
- Fixed a bug in the input checking of files when a Diskfile source
was added or reconfigured.
- Fixed minor bug reading the correct default view for sources from DB.
- Fixed a problem in the Views Admin, a set of predefined columns could be
in the list.
- Enhanced error display in all admin templates.
---------------------------------------------------------------------------
Version 2.3.8 (beta), 2008-07-28
- Fixed a "notice" bug in the installer, which was missing to save the
DBType for MYSQL Datasource.
@ -29,11 +132,26 @@ Version 2.3.8 (beta), 2008-07-28
not linked to whois anymore.
- Fixed Line Ending to Unix in some code files.
---------------------------------------------------------------------------
Version 2.5.0 (devel), 2008-07-24
- Fully implemented the UserDB System. This is the next major milestone
in the development of phpLogCon. The new UserDB System allows you to
fully customize phpLogCon using an admin interface and offers the
following sub-features: Users, Groups, Sources, Views, Searches and
general options. Exiting configurations can be imported into the
user system using the convert.php script. The installer has an option
to install the user system.
- Added Icons to all Topmenu entries, as well as into the Admin
Topmenu entries.
- Improved stylesheets
---------------------------------------------------------------------------
Version 2.3.7 (beta), 2008-07-07
- Added missing db mapping for program field of syslogng - thanks to
Micha "Wolvverine" Panasiewicz
- Added translation for Brazilian Portuguese, thanks to Ricardo Maraschini
---------------------------------------------------------------------------
Version 2.5.0 (devel), 2008-06-10
- Moved older devel branch to beta branch. Increment Version minor number.
---------------------------------------------------------------------------
Version 2.2.0 (v2-stable), 2008-06-10
- Moved beta branch to v2-stable branch.
---------------------------------------------------------------------------

54
doc/free_support.html Normal file
View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>Free Support for phpLogCon</title>
</head>
<body>
<h1>Free Services for phpLogCon</h1>
<p><i>A personal word from the authors of phpLogCon:</i>
<p><b>The phpLogCon community provides ample free support resources. Please see our
<a href="troubleshoot.html">troubleshooting guide</a> to get started.</b></p>
<p>Every now and then we receive private mail with support questions. We appreciate
all feedback, but we must limit my resources so that we can help drive a great project
forward.
<p>To do so, we have decided not to reply to unsolicited support emails, at least not
with a solution (but rather a link to this page ;)). We hope this does not offend you. The
reason is quite simple: If we do personal support, you gain some advantage without
contributing something back. Think about it: if you ask your question on the public
forum or mailing list, others with the same problem can see it and, most importantly, even
years later find your post (and the answer) and get the problem solved. So by
solving your issue in public, you help create a great community ressource and also
help your fellow users finding solutions quicker. In the long term, this
also contributes to improved code because the more questions users can find
solutions to themselves, the fewer we need to look at.
<p>But it comes even better: the phpLogCon community is much broader than the authors ;) - there
are helpful other members hanging around at the public places. They often answer
questions, so that we do not need to look at them (btw, once again a big "thank you", folks!).
And, more important, those folks have different background than us. So they often
either know better how to solve your problem (e.g. because it is distro-specific)
or they know how to better phrase it.
So you do yourself a favor if you use the public places.
<p>An excellent place to go to is the
<a href="http://kb.monitorware.com/phpLogCon-f39.html">phpLogCon forum</a> inside the
knowledge base (which in itself is a great place to visit!). For those used to
mailing lists, the
<a href="http://lists.adiscon.net/mailman/listinfo/phplogcon">phpLogCon mailing list</a>
also offers excellent advise.
<p><b>Don't like to post your question in a public place?</b> Well, then you should
consider purchasing <a href="professional_support.html">phpLogCon professional support</a>.
The fees are very low and help fund the project. If you use phpLogCon seriously inside
a corporate environment, there is no excuse for not getting one of the support
packages ;)
<p>Of course, things are different when we ask you to mail us privately. We'll usually do
that when we think it makes sense, for example when we exchange debug logs.
<p>I hope you now understand the free support options and the reasoning for them.
I hope we haven't offended you with our words - this is not our intension. We just needed to
make clear why there are some limits on our responsiveness. Happy analyzing!
<p>[<a href="manual.html">manual index</a>] [<a href="http://www.phplogcon.com/">phpLogCon site</a>]</p>
<p><font size="2">This documentation is part of the
<a href="http://www.phplogcon.com/">phpLogCon</a>
project.<br>
Copyright &copy; 2008 by
<a href="http://www.adiscon.com/">Adiscon</a>.
Released under the GNU GPL version 3 or higher.</font></p>
</body></html>

56
doc/manual.html Normal file
View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>phpLogCon documentation</title></head>
<body>
<h1>phpLogCon - Documentation</h1>
<p>The <b><a href="http://www.phplogcon.com/">phpLogCon</a>
project provides an easy to use but powerful front end for
searching, reviewing and analyzing network event data, including
syslog, windows event log and many other event sources.</b>
It focusses on the user-interface side of this project, so the
data itself needs to be gathered by another program,
for example the stock syslogd,
<a href="http://www.rsyslog.com">rsyslog</a> (often the distro's default syslogd),
<a href="http://www.winsyslog.com">WinSyslog</a> or
<a href="http://www.mwagent.com">MonitorWare Agent</a>.
PhpLogCon works equally well on Linux and
Windows. It is a free, GPLed open source application written mostly in php.
Data can be obtained from databases but also from plain text files, for
example those that are written by the syslgod.
<p><b>Follow the links below for the</b><br></p>
<ul>
<li><xa href="">phpLogCon Search syntax</a></li>
<li><xa href="">phpLogCon configuration parameters</a></li>
<li><a href="troubleshoot.html">troubleshooting phpLogCon problems</a></li>
<li><a href="professional_services.html">phpLogCon professional services</a></li>
</ul>
<!--
<p><b>We have some in-depth papers on</b></p>
<ul>
<li><a href="install.html">installing phpLogCon</a></li>
<li><a href="debug.html">debug support in rsyslog</a></li>
</ul>
-->
<p><b>You can also browse the following online resources:</b></p>
<ul>
<li>the <a href="http://http://wiki.rsyslog.com/index.php/PhpLogCon/">phpLogCon
wiki</a>, a community resource, part of the greater rsyslog wiki.
<li><a href="http://www.phplogcon.org">phpLogCon online documentation (most current version only)</a></li>
<li><a href="http://kb.monitorware.com/phplogcon-f39.html">phpLogCon
discussion forum - use this for technical support</a></li>
<li><a href="http://www.rsyslog.com/Topic4.phtml">phpLogCon change log (<b>currently outdated)</b></a></li>
<li><a href="http://wiki.rsyslog.com/index.php/PhpLogCon_FAQ">phpLogCon FAQ</a></li>
<li><a href="http://www.monitorware.com/en/syslog-enabled-products/">syslog
device configuration guide</a> (off-site)</li>
<li><a href="http://www.rsyslog.com/doc-rsyslog_high_database_rate.html">writing massive amounts of syslog messages to a database via rsyslog</a> (this may be useful if you have lots of messages,
want to store them in databases but have performance issues doing so)</li>
</ul>
<p>And don't forget about the
<a href="http://lists.adiscon.net/mailman/listinfo/phplogcon">phplogcon
mailing list</a>. If you are interested in the "backstage" behind the overall idea that
phpLogCon contributes to, you may find
<a href="http://www.gerhards.net/rainer">Rainer</a>'s
<a href="http://blog.gerhards.net/">blog</a> an interesting read.
<p>Feedback is always welcome, but if you have a support question, please do not
mail the authors directly (<a href="free_support.html">why not?</a>).
</body></html>

View File

@ -0,0 +1,60 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
</head>
<body>
<h1>Professional Services for phpLogCon</h1>
<p>Professional services are being offered by <a href="http://www.adiscon.com">Adiscon</a>, the company
that sponsors <a href="http://www.phplogcon.org/">phpLogCon</a>
development. For details, please contact
<a href="mailto:info%40adiscon.com">Adiscon Sales</a>.</p>
<h3>EMail Support Service</h3>
Price: 99.00 EURO <br>
Duration: 180 days
<br>
Support level: 8x5
<p>Purchase phpLogCon support directly from the source. This
contract provides priority email support. It is a great option if you
need to provide proof of software support in your organization. This
contract provides</p>
<ul>
<li>unlimited email support tickets during validity</li>
<li><b>fixes for</b> current and <b>past phpLogCon releases</b></li>
<li>advise on how to implement phpLogCon in the best possible way.</li>
</ul>
<p>Under this contract, fixes for old phpLogCon releases will be
provided / created, assuming it is possible to do that with the
code base in question. Phone support is not included.</p>
<h3>Custom Development</h3>
<p>Do you need an exotic feature that otherwise would not be implemented?
Do you need something really quick, quicker than it is available via
the regular development schedule? Then, you may consider funding
development for a specific functionality. We are always looking for
interesting projects. If you hire us to to do the job, you can be sure
to get the best possible and probably quickest solution, because we are
obviously at the heart of the source code. No need to get aquainted to
anything, no risk of misunderstanding core concepts. Benefit from
our vast logging and auditing experience.</p>
<p>Please note that custom development is not limited to phpLogCon. We offer
a number of logging solutions and can also work as part of your time
for specific requirements. The opportunities are endless, just ask. We
will work with you on your requirements and provide a quote on the
estimated cost. Just write to <a href="mailto:sales@adiscon.com">sales@adiscon.com</a> for details.</p><h3>Consulting Services</h3>
<p>Do you have demanding logging requirements? Why not talk to a
real logging professional? Instead of trying to find the solution
like a needle in the haystack, talk to the team that brought rsyslog,
phpLogCon, the Windows MonitorWare products and other logging
solutions. We sweat logging for over 15 years now and can help quickly.
Depending on your needs, consulting can be carried out via email, the
phone or on your premises (for larger or local projects). Everything is
possible, it just depends on your needs. Consulting services are
available in English and German. Just mail <a href="mailto:sales@adiscon.com">sales@adiscon.com</a> what you are interested in and we will work with you on a proposal that fits your needs.
</p><p></p>
<p>All agreements are governed under German law.</p>
<p>[<a href="manual.html">manual index</a>] [<a href="http://www.phplogcon.com/">phpLogCon site</a>]</p>
<p><font size="2">This documentation is part of the
<a href="http://www.phplogcon.com/">phpLogCon</a> project.<br>
Copyright &copy; 2008 by <a href="http://www.adiscon.com/">Adiscon</a>.
Released under the GNU GPL version 3 or higher.</font></p>
</body></html>

43
doc/troubleshoot.html Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>troubleshooting phpLogCon</title></head>
<body>
<h2>troubleshooting phpLogCon</h2>
<p><b>Having trouble with <a href="http://www.phplogcon.com">phpLogCon</a>?</b>
This page provides some tips on where to look for help and what to do
if you need to ask for assistance. This page is continously being expanded.
<p>Useful troublehshooting ressources are:
<ul>
<li>The <a href="http://www.phplogcon.com/doc">phpLogCon documentation</a> - note that the online version always covers
the most recent development version. However, there is a version-specific
doc set in each tarball. If you installed phpLogCon from a package, there usually
is a phpLogCon-doc package, that often needs to be installed separately. If running the default
installation, you should simply be able to get to the correct documentation version
by clicking on the "help" button on any phpLogCon page.
<li>The <a href="http://wiki.rsyslog.com/index.php/PhpLogCon">phpLogCon wiki</a>
(part of the larger rsyslog wiki) provides user tips and experiences.
<li>Check <a href="http://bugzilla.adiscon.com">the bugzilla</a> to see if your problem is a known
(and even fixed ;)) bug.
</ul>
<p><b>Configuration Problems</b>
<p>Validate your text configuration settings and, if you use the user system, also the
configuration stored in your database. Some very few configuration settings can only
be applied in the text config files.
<p><b>Asking for Help</b>
<p>If you can't find the answer yourself, you should look at these places for
community help.
<ul>
<li>The <a href="http://kb.monitorware.com/phpLogCon-f39.html">phpLogCon forum</a>. This is
the preferred method of obtaining support.
<li>The <a href="http://lists.adiscon.net/mailman/listinfo/phplogcon">phpLogCon mailing list</a>.
This is a low-volume list which occasional gets traffic spikes.
The mailing list is probably a good place for complex questions.
</ul>
<p>[<a href="manual.html">manual index</a>]
[<a href="http://www.phplogcon.com/">phpLogCon site</a>]</p>
<p><font size="2">This documentation is part of the
<a href="http://www.phplogcon.com/">phpLogCon</a> project.<br>
Copyright &copy; 2008 by <a href="http://www.adiscon.com/">Adiscon</a>.
Released under the GNU GPL version 2 or higher.</font></p>
</body>
</html>

View File

@ -0,0 +1,124 @@
Bitstream Vera Fonts Copyright
The fonts have a generous copyright, allowing derivative works (as
long as "Bitstream" or "Vera" are not in the names), and full
redistribution (so long as they are not *sold* by themselves). They
can be be bundled, redistributed and sold with any software.
The fonts are distributed under the following copyright:
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.
Copyright FAQ
=============
1. I don't understand the resale restriction... What gives?
Bitstream is giving away these fonts, but wishes to ensure its
competitors can't just drop the fonts as is into a font sale system
and sell them as is. It seems fair that if Bitstream can't make money
from the Bitstream Vera fonts, their competitors should not be able to
do so either. You can sell the fonts as part of any software package,
however.
2. I want to package these fonts separately for distribution and
sale as part of a larger software package or system. Can I do so?
Yes. A RPM or Debian package is a "larger software package" to begin
with, and you aren't selling them independently by themselves.
See 1. above.
3. Are derivative works allowed?
Yes!
4. Can I change or add to the font(s)?
Yes, but you must change the name(s) of the font(s).
5. Under what terms are derivative works allowed?
You must change the name(s) of the fonts. This is to ensure the
quality of the fonts, both to protect Bitstream and Gnome. We want to
ensure that if an application has opened a font specifically of these
names, it gets what it expects (though of course, using fontconfig,
substitutions could still could have occurred during font
opening). You must include the Bitstream copyright. Additional
copyrights can be added, as per copyright law. Happy Font Hacking!
6. If I have improvements for Bitstream Vera, is it possible they might get
adopted in future versions?
Yes. The contract between the Gnome Foundation and Bitstream has
provisions for working with Bitstream to ensure quality additions to
the Bitstream Vera font family. Please contact us if you have such
additions. Note, that in general, we will want such additions for the
entire family, not just a single font, and that you'll have to keep
both Gnome and Jim Lyles, Vera's designer, happy! To make sense to add
glyphs to the font, they must be stylistically in keeping with Vera's
design. Vera cannot become a "ransom note" font. Jim Lyles will be
providing a document describing the design elements used in Vera, as a
guide and aid for people interested in contributing to Vera.
7. I want to sell a software package that uses these fonts: Can I do so?
Sure. Bundle the fonts with your software and sell your software
with the fonts. That is the intent of the copyright.
8. If applications have built the names "Bitstream Vera" into them,
can I override this somehow to use fonts of my choosing?
This depends on exact details of the software. Most open source
systems and software (e.g., Gnome, KDE, etc.) are now converting to
use fontconfig (see www.fontconfig.org) to handle font configuration,
selection and substitution; it has provisions for overriding font
names and subsituting alternatives. An example is provided by the
supplied local.conf file, which chooses the family Bitstream Vera for
"sans", "serif" and "monospace". Other software (e.g., the XFree86
core server) has other mechanisms for font substitution.

View File

@ -0,0 +1,11 @@
Contained herin is the Bitstream Vera font family.
The Copyright information is found in the COPYRIGHT.TXT file (along
with being incoporated into the fonts themselves).
The releases notes are found in the file "RELEASENOTES.TXT".
We hope you enjoy Vera!
Bitstream, Inc.
The Gnome Project

View File

@ -0,0 +1,162 @@
Bitstream Vera Fonts - April 16, 2003
=====================================
The version number of these fonts is 1.10 to distinguish them from the
beta test fonts.
Note that the Vera copyright is incorporated in the fonts themselves.
The License field in the fonts contains the copyright license as it
appears below. The TrueType copyright field is not large enough to
contain the full license, so the license is incorporated (as you might
think if you thought about it) into the license field, which
unfortunately can be obscure to find. (In pfaedit, see: Element->Font
Info->TTFNames->License).
Our apologies for it taking longer to complete the fonts than planned.
Beta testers requested a tighter line spacing (less leading) and Jim
Lyles redesigned Vera's accents to bring its line spacing to more
typical of other fonts. This took additional time and effort. Our
thanks to Jim for this effort above and beyond the call of duty.
There are four monospace and sans faces (normal, oblique, bold, bold
oblique) and two serif faces (normal and bold). Fontconfig/Xft2 (see
www.fontconfig.org) can artificially oblique the serif faces for you:
this loses hinting and distorts the faces slightly, but is visibly
different than normal and bold, and reasonably pleasing.
On systems with fontconfig 2.0 or 2.1 installed, making your sans,
serif and monospace fonts default to these fonts is very easy. Just
drop the file local.conf into your /etc/fonts directory. This will
make the Bitstream fonts your default fonts for all applications using
fontconfig (if sans, serif, or monospace names are used, as they often
are as default values in many desktops). The XML in local.conf may
need modification to enable subpixel decimation, if appropriate,
however, the commented out phrase does so for XFree86 4.3, in the case
that the server does not have sufficient information to identify the
use of a flat panel. Fontconfig 2.2 adds Vera to the list of font
families and will, by default use it as the default sans, serif and
monospace fonts.
During the testing of the final Vera fonts, we learned that screen
fonts in general are only typically hinted to work correctly at
integer pixel sizes. Vera is coded internally for integer sizes only.
We need to investigate further to see if there are commonly used fonts
that are hinted to be rounded but are not rounded to integer sizes due
to oversights in their coding.
Most fonts work best at 8 pixels and below if anti-aliased only, as
the amount of work required to hint well at smaller and smaller sizes
becomes astronomical. GASP tables are typically used to control
whether hinting is used or not, but Freetype/Xft does not currently
support GASP tables (which are present in Vera).
To mitigate this problem, both for Vera and other fonts, there will be
(very shortly) a new fontconfig 2.2 release that will, by default not
apply hints if the size is below 8 pixels. if you should have a font
that in fact has been hinted more agressively, you can use fontconfig
to note this exception. We believe this should improve many hinted
fonts in addition to Vera, though implemeting GASP support is likely
the right long term solution.
Font rendering in Gnome or KDE is the combination of algorithms in
Xft2 and Freetype, along with hinting in the fonts themselves. It is
vital to have sufficient information to disentangle problems that you
may observe.
Note that having your font rendering system set up correctly is vital
to proper judgement of problems of the fonts:
* Freetype may or may not be configured to in ways that may
implement execution of possibly patented (in some parts of the world)
TrueType hinting algorithms, particularly at small sizes. Best
results are obtained while using these algorithms.
* The freetype autohinter (used when the possibly patented
algorithms are not used) continues to improve with each release. If
you are using the autohinter, please ensure you are using an up to
date version of freetype before reporting problems.
* Please identify what version of freetype you are using in any
bug reports, and how your freetype is configured.
* Make sure you are not using the freetype version included in
XFree86 4.3, as it has bugs that significantly degrade most fonts,
including Vera. if you build XFree86 4.3 from source yourself, you may
have installed this broken version without intending it (as I
did). Vera was verified with the recently released Freetype 2.1.4. On
many systems, 'ldd" can be used to see which freetype shared library
is actually being used.
* Xft/X Render does not (yet) implement gamma correction. This
causes significant problems rendering white text on a black background
(causing partial pixels to be insufficiently shaded) if the gamma of
your monitor has not been compensated for, and minor problems with
black text on a while background. The program "xgamma" can be used to
set a gamma correction value in the X server's color pallette. Most
monitors have a gamma near 2.
* Note that the Vera family uses minimal delta hinting. Your
results on other systems when not used anti-aliased may not be
entirely satisfying. We are primarily interested in reports of
problems on open source systems implementing Xft2/fontconfig/freetype
(which implements antialiasing and hinting adjustements, and
sophisticated subpixel decimation on flatpanels). Also, the
algorithms used by Xft2 adjust the hints to integer widths and the
results are crisper on open source systems than on Windows or
MacIntosh.
* Your fontconfig may (probably does) predate the release of
fontconfig 2.2, and you may see artifacts not present when the font is
used at very small sizes with hinting enabled. "vc-list -V" can be
used to see what version you have installed.
We believe and hope that these fonts will resolve the problems
reported during beta test. The largest change is the reduction of
leading (interline spacing), which had annoyed a number of people, and
reduced Vera's utility for some applcations. The Vera monospace font
should also now make '0' and 'O' and '1' and 'l' more clearly
distinguishable.
The version of these fonts is version 1.10. Fontconfig should be
choosing the new version of the fonts if both the released fonts and
beta test fonts are installed (though please discard them: they have
names of form tt20[1-12]gn.ttf). Note that older versions of
fontconfig sometimes did not rebuild their cache correctly when new
fonts are installed: please upgrade to fontconfig 2.2. "fc-cache -f"
can be used to force rebuilding fontconfig's cache files.
If you note problems, please send them to fonts at gnome dot org, with
exactly which face and size and unicode point you observe the problem
at. The xfd utility from XFree86 CVS may be useful for this (e.g. "xfd
-fa sans"). A possibly more useful program to examine fonts at a
variety of sizes is the "waterfall" program found in Keith Packard's
CVS.
$ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS login
Logging in to :pserver:anoncvs@keithp.com:2401/local/src/CVS
CVS password: <hit return>
$ cvs -d :pserver:anoncvs@keithp.com:/local/src/CVS co waterfall
$ cd waterfall
$ xmkmf -a
$ make
# make install
# make install.man
Again, please make sure you are running an up-to-date freetype, and
that you are only examining integer sizes.
Reporting Problems
==================
Please send problem reports to fonts at gnome org, with the following
information:
1. Version of Freetype, Xft2 and fontconfig
2. Whether TT hinting is being used, or the autohinter
3. Application being used
4. Character/Unicode code point that has problems (if applicable)
5. Version of which operating system
6. Please include a screenshot, when possible.
Please check the fonts list archives before reporting problems to cut
down on duplication.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,32 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- /etc/fonts.conf file to configure system font access -->
<fontconfig>
<!-- Enable sub-pixel rendering
<match target="font">
<test qual="all" name="rgba">
<const>unknown</const>
</test>
<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
-->
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Bitstream Vera Sans</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Bitstream Vera Sans Mono</family>
</prefer>
</alias>
</fontconfig>

420
src/admin/charts.php Normal file
View File

@ -0,0 +1,420 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Charts Admin File
*
* -> Helps administrating phplogcon charts & graphics
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWCHART'] = "true";
$content['CHART_FORMACTION'] = "addnewchart";
$content['CHART_SENDBUTTON'] = $content['LN_CHARTS_ADD'];
//PreInit these values
$content['Name'] = "MyChart";
$content['chart_type'] = CHART_BARS_VERTICAL;
CreateChartTypesList($content['chart_type']);
$content['chart_enabled'] = 1;
$content['CHECKED_ISCHARTENABLED'] = "checked";
$content['chart_width'] = 400;
$content['maxrecords'] = 5;
$content['showpercent'] = 0;
$content['CHECKED_ISSHOWPERCENT'] = "";
// Chart Field
$content['chart_field'] = SYSLOG_HOST;
CreateChartFields($content['chart_field']);
// COMMON Fields
$content['userid'] = null;
$content['CHECKED_ISUSERONLY'] = "";
$content['CHARTID'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
$content['ISGROUPSAVAILABLE'] = true;
else
$content['ISGROUPSAVAILABLE'] = false;
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWCHART'] = "true";
$content['CHART_FORMACTION'] = "editchart";
$content['CHART_SENDBUTTON'] = $content['LN_CHARTS_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['CHARTID'] = DB_RemoveBadChars($_GET['id']);
// Check if exists
if ( is_numeric($content['CHARTID']) && isset($content['Charts'][ $content['CHARTID'] ]) )
{
// Get Source reference
$myChart = $content['Charts'][ $content['CHARTID'] ];
// Copy basic properties
$content['Name'] = $myChart['DisplayName'];
$content['chart_type'] = $myChart['chart_type'];
CreateChartTypesList($content['chart_type']);
$content['chart_enabled'] = $myChart['chart_enabled'];
if ( $myChart['chart_enabled'] == 1 )
$content['CHECKED_ISCHARTENABLED'] = "checked";
else
$content['CHECKED_ISCHARTENABLED'] = "";
$content['chart_width'] = $myChart['chart_width'];
$content['maxrecords'] = $myChart['maxrecords'];
$content['showpercent'] = $myChart['showpercent'];
if ( $myChart['showpercent'] == 1 )
$content['CHECKED_ISSHOWPERCENT'] = "checked";
else
$content['CHECKED_ISSHOWPERCENT'] = "";
// Chart Field
$content['chart_field'] = $myChart['chart_field'];
CreateChartFields($content['chart_field']);
// COMMON Fields
if ( $myChart['userid'] != null )
$content['CHECKED_ISUSERONLY'] = "checked";
else
$content['CHECKED_ISUSERONLY'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
{
// Process All Groups
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
{
if ( $myChart['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $myChart['groupid'] )
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
else
$content['SUBGROUPS'][$i]['group_selected'] = "";
}
// Enable Group Selection
$content['ISGROUPSAVAILABLE'] = true;
}
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else
{
$content['ISEDITORNEWCHART'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = "!" . $content['LN_CHARTS_ERROR_INVALIDORNOTFOUNDID'];
}
}
else
{
$content['ISEDITORNEWCHART'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_CHARTS_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['CHARTID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
$result = DB_Query("SELECT DisplayName FROM " . DB_CHARTS . " WHERE ID = " . $content['CHARTID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['DisplayName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_IDNOTFOUND'], $content['CHARTID'] );
}
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_CHARTS_WARNDELETESEARCH'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_CHARTS . " WHERE ID = " . $content['CHARTID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_DELCHART'], $content['CHARTID'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "charts.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_CHARTS_ERROR_INVALIDORNOTFOUNDID'];
}
}
}
if ( isset($_POST['op']) )
{
// Read parameters first!
if ( isset($_POST['id']) ) { $content['CHARTID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['CHARTID'] = -1; }
if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; }
if ( isset($_POST['chart_enabled']) ) { $content['chart_enabled'] = intval(DB_RemoveBadChars($_POST['chart_enabled'])); } else {$content['chart_enabled'] = 0; }
if ( isset($_POST['chart_type']) ) { $content['chart_type'] = intval(DB_RemoveBadChars($_POST['chart_type'])); }
if ( isset($_POST['chart_width']) ) { $content['chart_width'] = intval(DB_RemoveBadChars($_POST['chart_width'])); } else {$content['chart_width'] = 400; }
if ( isset($_POST['chart_field']) ) { $content['chart_field'] = DB_RemoveBadChars($_POST['chart_field']); }
if ( isset($_POST['maxrecords']) ) { $content['maxrecords'] = intval(DB_RemoveBadChars($_POST['maxrecords'])); }
if ( isset($_POST['showpercent']) ) { $content['showpercent'] = intval(DB_RemoveBadChars($_POST['showpercent'])); } else {$content['showpercent'] = 0; }
// User & Group handeled specially
if ( isset ($_POST['isuseronly']) )
{
$content['userid'] = $content['SESSION_USERID'];
$content['groupid'] = "null"; // Either user or group not both!
}
else
{
$content['userid'] = "null";
if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 )
$content['groupid'] = intval($_POST['groupid']);
else
$content['groupid'] = "null";
}
// --- Check mandotary values
if ( $content['Name'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_CHARTS_NAME'] );
}
else if ( !isset($content['chart_type']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_CHART_TYPE'] );
}
else if ( !isset($content['chart_field']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_MISSINGPARAM'], $content['LN_CHART_FIELD'] );
}
// --- Now ADD/EDIT do the processing!
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewchart" )
{
// Add custom search now!
$sqlquery = "INSERT INTO " . DB_CHARTS . " (DisplayName, chart_enabled, chart_type, chart_width, chart_field, maxrecords, showpercent, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['chart_enabled'] . ",
" . $content['chart_type'] . ",
" . $content['chart_width'] . ",
'" . $content['chart_field'] . "',
" . $content['maxrecords'] . ",
" . $content['showpercent'] . ",
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENADDED'], $content['Name'] ) , "charts.php" );
}
else if ( $_POST['op'] == "editchart" )
{
$result = DB_Query("SELECT ID FROM " . DB_CHARTS . " WHERE ID = " . $content['CHARTID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_CHARTS_ERROR_IDNOTFOUND'], $content['CHARTID'] );
}
else
{
$sqlquery = "UPDATE " . DB_CHARTS . " SET
DisplayName = '" . $content['Name'] . "',
chart_enabled = " . $content['chart_enabled'] . ",
chart_type = " . $content['chart_type'] . ",
chart_width = " . $content['chart_width'] . ",
chart_field = '" . $content['chart_field'] . "',
maxrecords = " . $content['maxrecords'] . ",
showpercent = " . $content['showpercent'] . ",
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['CHARTID'];
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENEDIT'], $content['Name']) , "charts.php" );
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTCHARTS'] = "true";
// Copy Sources array for further modifications
$content['CHARTS'] = $content['Charts'];
// --- Process Sources
$i = 0; // Help counter!
foreach ($content['CHARTS'] as &$myChart )
{
// --- Set Image for Type
// NonNUMERIC are config files Sources, can not be editied
if ( is_numeric($myChart['ID']) )
{
// Allow EDIT
$myChart['ActionsAllowed'] = true;
if ( $myChart['userid'] != null )
{
$myChart['ChartAssignedToImage'] = $content["MENU_ADMINUSERS"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_USERONLY"];
}
else if ( $myChart['groupid'] != null )
{
$myChart['ChartAssignedToImage'] = $content["MENU_ADMINGROUPS"];
$myChart['ChartAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $myChart['groupname'] );
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myChart['ActionsAllowed'] = false;
}
else
{
$myChart['ChartAssignedToImage'] = $content["MENU_GLOBAL"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_GLOBAL"];
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myChart['ActionsAllowed'] = false;
}
}
else
{
// Disallow EDIT
$myChart['ActionsAllowed'] = false;
$myChart['ChartAssignedToImage'] = $content["MENU_INTERNAL"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_CONFIGFILE"];
}
// ---
// --- Set SourceType
if ( $myChart['chart_type'] == CHART_CAKE )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_CAKE"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_CAKE"];
}
else if ( $myChart['chart_type'] == CHART_BARS_VERTICAL )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_BARSVERT"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_BARS_VERTICAL"];
}
else if ( $myChart['chart_type'] == CHART_BARS_HORIZONTAL )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_BARSHORI"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_BARS_HORIZONTAL"];
}
// ---
// --- Set enabled or disabled state
if ( $myChart['chart_enabled'] == 1 )
$myChart['ChartEnabledImage'] = $content["MENU_SELECTION_ENABLED"];
else
$myChart['ChartEnabledImage'] = $content["MENU_SELECTION_DISABLED"];
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$myChart['cssclass'] = "line1";
else
$myChart['cssclass'] = "line2";
$i++;
// ---
}
// ---
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_CHARTOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_charts.html");
$page -> output();
// ---
?>

494
src/admin/groups.php Normal file
View File

@ -0,0 +1,494 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Group Admin File
*
* -> Helps administrating groups
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
// Only if the user is an admin!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWGROUP'] = "true";
$content['GROUP_FORMACTION'] = "addnewgroup";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADD'];
//PreInit these values
$content['groupname'] = "";
$content['groupdescription'] = "";
}
else if ($_GET['op'] == "adduser" && isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) );
// Set Mode to add
$content['ISADDUSER'] = "true";
$content['GROUP_FORMACTION'] = "adduser";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_ADDUSER'];
// --- Get Groupname
$sqlquery = "SELECT " .
DB_GROUPS . ".groupname " .
" FROM " . DB_GROUPS .
" WHERE " . DB_GROUPS . ".id = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$tmparray = DB_GetSingleRow($result, true);
if ( isset($tmparray) )
{
// Copy Groupname
$content['GROUPNAME'] = $tmparray['groupname'];
// --- Get Group Members
$sqlquery = "SELECT " .
DB_GROUPMEMBERS. ".userid " .
" FROM " . DB_GROUPMEMBERS .
" WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$tmparray = DB_GetAllRows($result, true);
if ( count($tmparray) > 0 )
{
// Add UserID's to where clause!
foreach ($tmparray as $datarow)
{
if ( isset($whereclause) )
$whereclause .= ", " . $datarow['userid'];
else
$whereclause = " WHERE " . DB_USERS . ".id NOT IN (" . $datarow['userid'];
}
// Finish whereclause
$whereclause .= ") ";
}
else
$whereclause = "";
// ---
// --- Create LIST of Users which are available for selection
$sqlquery = "SELECT " .
DB_USERS. ".ID as userid, " .
DB_USERS. ".username " .
" FROM " . DB_USERS .
" LEFT OUTER JOIN (" . DB_GROUPMEMBERS .
") ON (" .
DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " .
$whereclause .
" ORDER BY " . DB_USERS . ".username";
$result = DB_Query($sqlquery);
$content['SUBUSERS'] = DB_GetAllRows($result, true);
if ( count($content['SUBUSERS']) <= 0 )
{
// Disable FORM:
$content['ISADDUSER'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOMOREUSERS'], $content['GROUPNAME'] );
}
}
else
{
// Disable FORM:
$content['ISADDUSER'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
// ---
}
else if ($_GET['op'] == "removeuser" && isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = intval( DB_RemoveBadChars($_GET['id']) );
// Set Mode to add
$content['ISREMOVEUSER'] = "true";
$content['GROUP_FORMACTION'] = "removeuser";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_USERDELETE'];
// --- Get Groupname
$sqlquery = "SELECT " .
DB_GROUPS . ".groupname " .
" FROM " . DB_GROUPS .
" WHERE " . DB_GROUPS . ".id = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$tmparray = DB_GetSingleRow($result, true);
if ( isset($tmparray) )
{
// Copy Groupname
$content['GROUPNAME'] = $tmparray['groupname'];
// --- Get Group Members
$sqlquery = "SELECT " .
DB_GROUPMEMBERS. ".userid, " .
DB_USERS. ".username " .
" FROM " . DB_GROUPMEMBERS .
" INNER JOIN (" . DB_USERS .
") ON (" .
DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " .
" WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$content['SUBRMUSERS'] = DB_GetAllRows($result, true);
if ( count($content['SUBRMUSERS']) <= 0 )
{
// Disable FORM:
$content['ISREMOVEUSER'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERRORNOUSERSINGROUP'], $content['GROUPNAME'] );
}
}
else
{
// Disable FORM:
$content['ISREMOVEUSER'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWGROUP'] = "true";
$content['GROUP_FORMACTION'] = "editgroup";
$content['GROUP_SENDBUTTON'] = $content['LN_GROUP_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = DB_RemoveBadChars($_GET['id']);
$sqlquery = "SELECT * " .
" FROM " . DB_GROUPS .
" WHERE ID = " . $content['GROUPID'];
$result = DB_Query($sqlquery);
$myuser = DB_GetSingleRow($result, true);
if ( isset($myuser['groupname']) )
{
$content['GROUPID'] = $myuser['ID'];
$content['groupname'] = $myuser['groupname'];
$content['groupdescription'] = $myuser['groupdescription'];
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['GROUPID'] = DB_RemoveBadChars($_GET['id']);
// Get GroupInfo
$result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['groupname']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['USERID'] );
}
else
{
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_GROUP_WARNDELETEGROUP'], $myrow['groupname'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_DELGROUP'], $content['USERID'] );
}
else
DB_FreeQuery($result);
// TODO: DELETE GROUP SETTINGS, GROUP MEMBERSHIP ...
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENDEL'], $myrow['groupname'] ) , "groups.php" );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_INVALIDGROUP'];
}
}
}
if ( isset($_POST['op']) )
{
if ( isset ($_POST['id']) ) { $content['GROUPID'] = intval( DB_RemoveBadChars($_POST['id']) ); } else {$content['GROUPID'] = ""; }
if ( isset ($_POST['groupname']) ) { $content['groupname'] = DB_RemoveBadChars($_POST['groupname']); } else {$content['groupname'] = ""; }
if ( isset ($_POST['groupdescription']) ) { $content['groupdescription'] = DB_RemoveBadChars($_POST['groupdescription']); } else {$content['groupdescription'] = ""; }
// Check mandotary values
if ( $content['groupname'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPEMPTY'];
}
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewgroup" )
{
$result = DB_Query("SELECT groupname FROM " . DB_GROUPS . " WHERE groupname = '" . $content['groupname'] . "'");
$myrow = DB_GetSingleRow($result, true);
if ( isset($myrow['groupname']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_GROUPNAMETAKEN'];
}
else
{
// Add new Group now!
$result = DB_Query("INSERT INTO " . DB_GROUPS . " (groupname, groupdescription)
VALUES ( '" . $content['groupname'] . "',
'" . $content['groupdescription'] . "' )");
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], $content['groupname'] ) , "groups.php" );
}
}
else if ( $_POST['op'] == "editgroup" )
{
$result = DB_Query("SELECT ID FROM " . DB_GROUPS . " WHERE ID = " . $content['GROUPID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_IDNOTFOUND'], $content['GROUPID'] );
}
else
{
// Edit the User now!
$result = DB_Query("UPDATE " . DB_GROUPS . " SET
groupname = '" . $content['groupname'] . "',
groupdescription = '" . $content['groupdescription'] . "'
WHERE ID = " . $content['GROUPID']);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], $content['groupname']) , "groups.php" );
}
}
else if ( $_POST['op'] == "adduser" )
{
if ( isset($_POST['userid']) )
{
// Copy UserID
$content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) );
$result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']);
$myrow = DB_GetSingleRow($result, true);
if ( isset($myrow['username']) )
{
// Add Groupmembership now!
$result = DB_Query("INSERT INTO " . DB_GROUPMEMBERS . " (groupid, userid, is_member)
VALUES ( " . $content['GROUPID'] . ",
" . $content['USERID'] . ",
1 )");
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENADDEDGROUP'], $myrow['username'], $content['groupname'] ) , "groups.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING'];
}
}
else if ( $_POST['op'] == "removeuser" )
{
if ( isset($_POST['userid']) )
{
// Copy UserID
$content['USERID'] = intval( DB_RemoveBadChars($_POST['userid']) );
$result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE id = " . $content['USERID']);
$myrow = DB_GetSingleRow($result, true);
if ( isset($myrow['username']) )
{
// remove user from group
$result = DB_Query( "DELETE FROM " . DB_GROUPMEMBERS . " WHERE userid = " . $content['USERID'] . " AND groupid = " . $content['GROUPID']);
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_GROUP_ERROR_REMUSERFROMGROUP'], $myrow['username'], $content['groupname'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_USERHASBEENREMOVED'], $myrow['username'], $content['groupname'] ) , "groups.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_GROUP_ERROR_USERIDMISSING'];
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Groups
$content['LISTGROUPS'] = "true";
// Read all Groupentries
$sqlquery = "SELECT ID, " .
" groupname, " .
" groupdescription " .
" FROM " . DB_GROUPS.
" ORDER BY ID ";
$result = DB_Query($sqlquery);
$content['GROUPS'] = DB_GetAllRows($result, true);
if ( count($content['GROUPS']) > 0 )
{
// --- Process Groups
for($i = 0; $i < count($content['GROUPS']); $i++)
{
// --- Set CSS Class
if ( $i % 2 == 0 )
$content['GROUPS'][$i]['cssclass'] = "line1";
else
$content['GROUPS'][$i]['cssclass'] = "line2";
// ---
// --- Read all Memberentries for this group
$sqlquery = "SELECT " .
DB_USERS. ".username, " .
DB_GROUPMEMBERS . ".userid, " .
DB_GROUPMEMBERS . ".groupid, " .
DB_GROUPMEMBERS . ".is_member " .
" FROM " . DB_GROUPMEMBERS .
" INNER JOIN (" . DB_USERS .
") ON (" .
DB_GROUPMEMBERS . ".userid=" . DB_USERS . ".ID) " .
" WHERE " . DB_GROUPMEMBERS . ".groupid = " . $content['GROUPS'][$i]['ID'] .
" ORDER BY " . DB_USERS . ".username";
$result = DB_Query($sqlquery);
$content['GROUPS'][$i]['USERS'] = DB_GetAllRows($result, true);
if ( count($content['GROUPS'][$i]['USERS']) > 0 )
{
// Enable Groupmembers
$content['GROUPS'][$i]['GROUPMEMBERS'] = true;
// Process Groups
$subUserCount = count($content['GROUPS'][$i]['USERS']);
for($j = 0; $j < $subUserCount; $j++)
$content['GROUPS'][$i]['USERS'][$j]['seperator'] = ", ";
$content['GROUPS'][$i]['USERS'][$subUserCount-1]['seperator'] = ""; // last one is empty
}
// ---
}
// ---
}
else
$content['EMPTYGROUPS'] = "true";
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GROUPOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_groups.html");
$page -> output();
// ---
?>

373
src/admin/index.php Normal file
View File

@ -0,0 +1,373 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Admin Index File
*
* -> Shows ...
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Include LogStream facility
// include($gl_root_path . 'classes/logstream.class.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// --- BEGIN Custom Code
if ( isset($_SESSION['SESSION_ISADMIN']) && $_SESSION['SESSION_ISADMIN'] == 1 )
{
$content['EditAllowed'] = true;
$content['DISABLE_GLOBALEDIT_FORMCONTROL'] = "";
}
else
{
$content['EditAllowed'] = false;
$content['DISABLE_GLOBALEDIT_FORMCONTROL'] = "disabled";
}
// --- First thing to do is to check the op get parameter!
// Check for changes first | Abort if Edit is not allowed
if ( isset($_GET['op']) && isset($_GET['value']) )
{
if ( $_GET['op'] == "enableuserops" )
{
$iNewVal = intval($_GET['value']);
if ( $iNewVal == 1 )
$USERCFG['UserOverwriteOptions'] = 1;
else
$USERCFG['UserOverwriteOptions'] = 0;
// Enable User Options!
WriteConfigValue( "UserOverwriteOptions", false, $content['SESSION_USERID'] );
}
}
// ---
// --- Check if user wants to overwrite
$UserOverwriteOptions = GetConfigSetting("UserOverwriteOptions", 0, CFGLEVEL_USER);
if ( $UserOverwriteOptions == 1 )
{
$content['ENABLEUSEROPTIONS'] = true;
}
else
{
$content['ENABLEUSEROPTIONS'] = false;
}
// ---
// Check for changes first | Abort if Edit is not allowed
if ( isset($_POST['op']) )
{
if ( $_POST['op'] == "edit" )
{
// Do if User is ADMIN
if ( $content['EditAllowed'] )
{
// Language needs special treatment
if ( isset ($_POST['ViewDefaultLanguage']) )
{
$tmpvar = DB_RemoveBadChars($_POST['ViewDefaultLanguage']);
if ( VerifyLanguage($tmpvar) )
$content['ViewDefaultLanguage'] = $tmpvar;
}
// Read default theme
if ( isset ($_POST['ViewDefaultTheme']) ) { $content['ViewDefaultTheme'] = $_POST['ViewDefaultTheme']; }
// Read default VIEW | Check if View exists as well!
if ( isset ($_POST['DefaultViewsID']) && isset($content['Views'][$_POST['DefaultViewsID']] )) { $content['DefaultViewsID'] = $_POST['DefaultViewsID']; }
// Read default SOURCES | Check if Source exists as well!
if ( isset ($_POST['DefaultSourceID']) && isset($content['Sources'][$_POST['DefaultSourceID']] )) { $content['DefaultSourceID'] = $_POST['DefaultSourceID']; }
// Read checkboxes
if ( isset ($_POST['ViewUseTodayYesterday']) ) { $content['ViewUseTodayYesterday'] = 1; } else { $content['ViewUseTodayYesterday'] = 0; }
if ( isset ($_POST['ViewEnableDetailPopups']) ) { $content['ViewEnableDetailPopups'] = 1; } else { $content['ViewEnableDetailPopups'] = 0; }
if ( isset ($_POST['EnableIPAddressResolve']) ) { $content['EnableIPAddressResolve'] = 1; } else { $content['EnableIPAddressResolve'] = 0; }
if ( isset ($_POST['MiscShowDebugMsg']) ) { $content['MiscShowDebugMsg'] = 1; } else { $content['MiscShowDebugMsg'] = 0; }
if ( isset ($_POST['MiscShowDebugGridCounter']) ) { $content['MiscShowDebugGridCounter'] = 1; } else { $content['MiscShowDebugGridCounter'] = 0; }
if ( isset ($_POST['MiscShowPageRenderStats']) ) { $content['MiscShowPageRenderStats'] = 1; } else { $content['MiscShowPageRenderStats'] = 0; }
if ( isset ($_POST['MiscEnableGzipCompression']) ) { $content['MiscEnableGzipCompression'] = 1; } else { $content['MiscEnableGzipCompression'] = 0; }
if ( isset ($_POST['SuppressDuplicatedMessages']) ) { $content['SuppressDuplicatedMessages'] = 1; } else { $content['SuppressDuplicatedMessages'] = 0; }
if ( isset ($_POST['TreatNotFoundFiltersAsTrue']) ) { $content['TreatNotFoundFiltersAsTrue'] = 1; } else { $content['TreatNotFoundFiltersAsTrue'] = 0; }
if ( isset ($_POST['DebugUserLogin']) ) { $content['DebugUserLogin'] = 1; } else { $content['DebugUserLogin'] = 0; }
if ( isset ($_POST['MiscDebugToSyslog']) ) { $content['MiscDebugToSyslog'] = 1; } else { $content['MiscDebugToSyslog'] = 0; }
// Read Text number fields
if ( isset ($_POST['ViewMessageCharacterLimit']) && is_numeric($_POST['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_POST['ViewMessageCharacterLimit']; }
if ( isset ($_POST['ViewStringCharacterLimit']) && is_numeric($_POST['ViewStringCharacterLimit']) ) { $content['ViewStringCharacterLimit'] = $_POST['ViewStringCharacterLimit']; }
if ( isset ($_POST['PopupMenuTimeout']) && is_numeric($_POST['PopupMenuTimeout']) ) { $content['PopupMenuTimeout'] = $_POST['PopupMenuTimeout']; }
if ( isset ($_POST['ViewEntriesPerPage']) && is_numeric($_POST['ViewEntriesPerPage']) ) { $content['ViewEntriesPerPage'] = $_POST['ViewEntriesPerPage']; }
if ( isset ($_POST['ViewEnableAutoReloadSeconds']) && is_numeric($_POST['ViewEnableAutoReloadSeconds']) ) { $content['ViewEnableAutoReloadSeconds'] = $_POST['ViewEnableAutoReloadSeconds']; }
if ( isset ($_POST['MiscMaxExecutionTime']) && is_numeric($_POST['MiscMaxExecutionTime']) ) { $content['MiscMaxExecutionTime'] = $_POST['MiscMaxExecutionTime']; }
// Read Text fields
if ( isset ($_POST['PrependTitle']) ) { $content['PrependTitle'] = $_POST['PrependTitle']; }
if ( isset ($_POST['SearchCustomButtonCaption']) ) { $content['SearchCustomButtonCaption'] = $_POST['SearchCustomButtonCaption']; }
if ( isset ($_POST['SearchCustomButtonSearch']) ) { $content['SearchCustomButtonSearch'] = $_POST['SearchCustomButtonSearch']; }
// Save configuration variables now
SaveGeneralSettingsIntoDB();
}
// Do if User wants extra options
if ( $content['ENABLEUSEROPTIONS'] )
{
// Language needs special treatment
if ( isset ($_POST['User_ViewDefaultLanguage']) )
{
$tmpvar = DB_RemoveBadChars($_POST['User_ViewDefaultLanguage']);
if ( VerifyLanguage($tmpvar) )
$USERCFG['ViewDefaultLanguage'] = $tmpvar;
}
// Read default theme
if ( isset ($_POST['User_ViewDefaultTheme']) ) { $USERCFG['ViewDefaultTheme'] = $_POST['User_ViewDefaultTheme']; }
// Read default VIEW | Check if View exists as well!
if ( isset ($_POST['User_DefaultViewsID']) && isset($content['Views'][$_POST['User_DefaultViewsID']] )) { $USERCFG['DefaultViewsID'] = $_POST['User_DefaultViewsID']; }
// Read default SOURCES | Check if Source exists as well!
if ( isset ($_POST['User_DefaultSourceID']) && isset($content['Sources'][$_POST['User_DefaultSourceID']] )) { $USERCFG['DefaultSourceID'] = $_POST['User_DefaultSourceID']; }
// Read checkboxes
if ( isset ($_POST['User_ViewUseTodayYesterday']) ) { $USERCFG['ViewUseTodayYesterday'] = 1; } else { $USERCFG['ViewUseTodayYesterday'] = 0; }
if ( isset ($_POST['User_ViewEnableDetailPopups']) ) { $USERCFG['ViewEnableDetailPopups'] = 1; } else { $USERCFG['ViewEnableDetailPopups'] = 0; }
if ( isset ($_POST['User_EnableIPAddressResolve']) ) { $USERCFG['EnableIPAddressResolve'] = 1; } else { $USERCFG['EnableIPAddressResolve'] = 0; }
if ( isset ($_POST['User_MiscShowDebugMsg']) ) { $USERCFG['MiscShowDebugMsg'] = 1; } else { $USERCFG['MiscShowDebugMsg'] = 0; }
if ( isset ($_POST['User_MiscShowDebugGridCounter']) ) { $USERCFG['MiscShowDebugGridCounter'] = 1; } else { $USERCFG['MiscShowDebugGridCounter'] = 0; }
if ( isset ($_POST['User_MiscShowPageRenderStats']) ) { $USERCFG['MiscShowPageRenderStats'] = 1; } else { $USERCFG['MiscShowPageRenderStats'] = 0; }
if ( isset ($_POST['User_MiscEnableGzipCompression']) ) { $USERCFG['MiscEnableGzipCompression'] = 1; } else { $USERCFG['MiscEnableGzipCompression'] = 0; }
if ( isset ($_POST['User_SuppressDuplicatedMessages']) ) { $USERCFG['SuppressDuplicatedMessages'] = 1; } else { $USERCFG['SuppressDuplicatedMessages'] = 0; }
if ( isset ($_POST['User_TreatNotFoundFiltersAsTrue']) ) { $USERCFG['TreatNotFoundFiltersAsTrue'] = 1; } else { $USERCFG['TreatNotFoundFiltersAsTrue'] = 0; }
// Read Text number fields
if ( isset ($_POST['User_ViewMessageCharacterLimit']) && is_numeric($_POST['User_ViewMessageCharacterLimit']) ) { $USERCFG['ViewMessageCharacterLimit'] = $_POST['User_ViewMessageCharacterLimit']; }
if ( isset ($_POST['User_ViewStringCharacterLimit']) && is_numeric($_POST['User_ViewStringCharacterLimit']) ) { $USERCFG['ViewStringCharacterLimit'] = $_POST['User_ViewStringCharacterLimit']; }
if ( isset ($_POST['User_PopupMenuTimeout']) && is_numeric($_POST['User_PopupMenuTimeout']) ) { $USERCFG['PopupMenuTimeout'] = $_POST['User_PopupMenuTimeout']; }
if ( isset ($_POST['User_ViewEntriesPerPage']) && is_numeric($_POST['User_ViewEntriesPerPage']) ) { $USERCFG['ViewEntriesPerPage'] = $_POST['User_ViewEntriesPerPage']; }
if ( isset ($_POST['User_ViewEnableAutoReloadSeconds']) && is_numeric($_POST['User_ViewEnableAutoReloadSeconds']) ) { $USERCFG['ViewEnableAutoReloadSeconds'] = $_POST['User_ViewEnableAutoReloadSeconds']; }
// TODO!!!!!!!!!!!111111111
// Read Text fields
if ( isset ($_POST['User_PrependTitle']) ) { $USERCFG['PrependTitle'] = $_POST['User_PrependTitle']; }
if ( isset ($_POST['User_SearchCustomButtonCaption']) ) { $USERCFG['SearchCustomButtonCaption'] = $_POST['User_SearchCustomButtonCaption']; }
if ( isset ($_POST['User_SearchCustomButtonSearch']) ) { $USERCFG['SearchCustomButtonSearch'] = $_POST['User_SearchCustomButtonSearch']; }
// Save configuration variables now
SaveUserGeneralSettingsIntoDB();
}
// Do a redirect
RedirectResult( $content['LN_GEN_SUCCESSFULLYSAVED'], "index.php" );
}
}
// Set checkbox States
if (isset($content['ViewUseTodayYesterday']) && $content['ViewUseTodayYesterday'] == 1) { $content['ViewUseTodayYesterday_checked'] = "checked"; } else { $content['ViewUseTodayYesterday_checked'] = ""; }
if (isset($content['ViewEnableDetailPopups']) && $content['ViewEnableDetailPopups'] == 1) { $content['ViewEnableDetailPopups_checked'] = "checked"; } else { $content['ViewEnableDetailPopups_checked'] = ""; }
if (isset($content['EnableIPAddressResolve']) && $content['EnableIPAddressResolve'] == 1) { $content['EnableIPAddressResolve_checked'] = "checked"; } else { $content['EnableIPAddressResolve_checked'] = ""; }
if (isset($content['MiscShowDebugMsg']) && $content['MiscShowDebugMsg'] == 1) { $content['MiscShowDebugMsg_checked'] = "checked"; } else { $content['MiscShowDebugMsg_checked'] = ""; }
if (isset($content['MiscShowDebugGridCounter']) && $content['MiscShowDebugGridCounter'] == 1) { $content['MiscShowDebugGridCounter_checked'] = "checked"; } else { $content['MiscShowDebugGridCounter_checked'] = ""; }
if (isset($content['MiscShowPageRenderStats']) && $content['MiscShowPageRenderStats'] == 1) { $content['MiscShowPageRenderStats_checked'] = "checked"; } else { $content['MiscShowPageRenderStats_checked'] = ""; }
if (isset($content['MiscEnableGzipCompression']) && $content['MiscEnableGzipCompression'] == 1) { $content['MiscEnableGzipCompression_checked'] = "checked"; } else { $content['MiscEnableGzipCompression_checked'] = ""; }
if (isset($content['SuppressDuplicatedMessages']) && $content['SuppressDuplicatedMessages'] == 1) { $content['SuppressDuplicatedMessages_checked'] = "checked"; } else { $content['SuppressDuplicatedMessages_checked'] = ""; }
if (isset($content['TreatNotFoundFiltersAsTrue']) && $content['TreatNotFoundFiltersAsTrue'] == 1) { $content['TreatNotFoundFiltersAsTrue_checked'] = "checked"; } else { $content['TreatNotFoundFiltersAsTrue_checked'] = ""; }
if (isset($content['DebugUserLogin']) && $content['DebugUserLogin'] == 1) { $content['DebugUserLogin_checked'] = "checked"; } else { $content['DebugUserLogin_checked'] = ""; }
if (isset($content['MiscDebugToSyslog']) && $content['MiscDebugToSyslog'] == 1) { $content['MiscDebugToSyslog_checked'] = "checked"; } else { $content['MiscDebugToSyslog_checked'] = ""; }
// ---
// --- Init for Style field!
// copy STYLES Array
$content['GLOBAL_STYLES'] = $content['STYLES'];
$defaultStyleID = GetConfigSetting('ViewDefaultTheme', "default", CFGLEVEL_GLOBAL);
foreach ( $content['GLOBAL_STYLES'] as &$myStyle )
{
if ( $myStyle['StyleName'] == $defaultStyleID )
$myStyle['selected'] = "selected";
else
$myStyle['selected'] = "";
}
// ---
// --- Init for ViewDefaultLanguage field!
// copy LANGUAGES Array
$content['GLOBAL_LANGUAGES'] = $content['LANGUAGES'];
$defaultLangID = GetConfigSetting('ViewDefaultLanguage', "en", CFGLEVEL_GLOBAL);
foreach ( $content['GLOBAL_LANGUAGES'] as &$myLang )
{
if ( $myLang['langcode'] == $defaultLangID )
$myLang['selected'] = "selected";
else
$myLang['selected'] = "";
}
// ---
// --- Init for DefaultView field!
// copy Views Array
$content['VIEWS'] = $content['Views'];
if ( !isset($content['DefaultViewsID']) ) { $content['DefaultViewsID'] = 'SYSLOG'; }
foreach ( $content['VIEWS'] as &$myView )
{
if ( $myView['ID'] == $content['DefaultViewsID'] )
$myView['selected'] = "selected";
else
$myView['selected'] = "";
}
// ---
// --- Init for DefaultSource field!
// copy Sources Array
$content['SOURCES'] = $content['Sources'];
if ( !isset($content['DefaultSourceID']) ) { $content['DefaultSourceID'] = ''; }
foreach ( $content['SOURCES'] as &$mySource )
{
if ( $mySource['ID'] == $content['DefaultSourceID'] )
$mySource['selected'] = "selected";
else
$mySource['selected'] = "";
}
// ---
// Do if User wants extra options
if ( $content['ENABLEUSEROPTIONS'] )
{
// Set checkbox States
if ( GetConfigSetting('ViewUseTodayYesterday', $content['ViewUseTodayYesterday'], CFGLEVEL_USER) == 1) { $content['User_ViewUseTodayYesterday_checked'] = "checked"; } else { $content['User_ViewUseTodayYesterday_checked'] = ""; }
if ( GetConfigSetting('ViewEnableDetailPopups', $content['ViewEnableDetailPopups'], CFGLEVEL_USER) == 1) { $content['User_ViewEnableDetailPopups_checked'] = "checked"; } else { $content['User_ViewEnableDetailPopups_checked'] = ""; }
if ( GetConfigSetting('EnableIPAddressResolve', $content['EnableIPAddressResolve'], CFGLEVEL_USER) == 1) { $content['User_EnableIPAddressResolve_checked'] = "checked"; } else { $content['User_EnableIPAddressResolve_checked'] = ""; }
if ( GetConfigSetting('MiscShowDebugMsg', $content['MiscShowDebugMsg'], CFGLEVEL_USER) == 1) { $content['User_MiscShowDebugMsg_checked'] = "checked"; } else { $content['User_MiscShowDebugMsg_checked'] = ""; }
if ( GetConfigSetting('MiscShowDebugGridCounter', $content['MiscShowDebugGridCounter'], CFGLEVEL_USER) == 1) { $content['User_MiscShowDebugGridCounter_checked'] = "checked"; } else { $content['User_MiscShowDebugGridCounter_checked'] = ""; }
if ( GetConfigSetting('MiscShowPageRenderStats', $content['MiscShowPageRenderStats'], CFGLEVEL_USER) == 1) { $content['User_MiscShowPageRenderStats_checked'] = "checked"; } else { $content['User_MiscShowPageRenderStats_checked'] = ""; }
if ( GetConfigSetting('MiscEnableGzipCompression', $content['MiscEnableGzipCompression'], CFGLEVEL_USER) == 1) { $content['User_MiscEnableGzipCompression_checked'] = "checked"; } else { $content['User_MiscEnableGzipCompression_checked'] = ""; }
if ( GetConfigSetting('SuppressDuplicatedMessages', $content['SuppressDuplicatedMessages'], CFGLEVEL_USER) == 1) { $content['User_SuppressDuplicatedMessages_checked'] = "checked"; } else { $content['User_SuppressDuplicatedMessages_checked'] = ""; }
if ( GetConfigSetting('TreatNotFoundFiltersAsTrue', $content['TreatNotFoundFiltersAsTrue'], CFGLEVEL_USER) == 1) { $content['User_TreatNotFoundFiltersAsTrue_checked'] = "checked"; } else { $content['User_TreatNotFoundFiltersAsTrue_checked'] = ""; }
// ---
// --- Set TextFields!
$content['User_PrependTitle'] = GetConfigSetting('PrependTitle', $content['PrependTitle'], CFGLEVEL_USER);
$content['User_ViewMessageCharacterLimit'] = GetConfigSetting('ViewMessageCharacterLimit', $content['ViewMessageCharacterLimit'], CFGLEVEL_USER);
$content['User_ViewStringCharacterLimit'] = GetConfigSetting('ViewStringCharacterLimit', $content['ViewStringCharacterLimit'], CFGLEVEL_USER);
$content['User_PopupMenuTimeout'] = GetConfigSetting('PopupMenuTimeout', $content['PopupMenuTimeout'], CFGLEVEL_USER);
$content['User_ViewEntriesPerPage'] = GetConfigSetting('ViewEntriesPerPage', $content['ViewEntriesPerPage'], CFGLEVEL_USER);
$content['User_ViewEnableAutoReloadSeconds'] = GetConfigSetting('ViewEnableAutoReloadSeconds', $content['ViewEnableAutoReloadSeconds'], CFGLEVEL_USER);
$content['User_SearchCustomButtonCaption'] = GetConfigSetting('SearchCustomButtonCaption', $content['SearchCustomButtonCaption'], CFGLEVEL_USER);
$content['User_SearchCustomButtonSearch'] = GetConfigSetting('SearchCustomButtonSearch', $content['SearchCustomButtonSearch'], CFGLEVEL_USER);
// ---
// --- Init for ViewDefaultTheme field!
// copy STYLES Array
$content['USER_STYLES'] = $content['STYLES'];
$userStyleID = GetConfigSetting('ViewDefaultTheme', $content['ViewDefaultTheme'], CFGLEVEL_USER);
foreach ( $content['USER_STYLES'] as &$myStyle )
{
if ( $myStyle['StyleName'] == $userStyleID )
$myStyle['selected'] = "selected";
else
$myStyle['selected'] = "";
}
// ---
// --- Init for ViewDefaultLanguage field!
// copy LANGUAGES Array
$content['USER_LANGUAGES'] = $content['LANGUAGES'];
$userLangID = GetConfigSetting('ViewDefaultLanguage', $content['ViewDefaultLanguage'], CFGLEVEL_USER);
foreach ( $content['USER_LANGUAGES'] as &$myLang )
{
if ( $myLang['langcode'] == $userLangID )
$myLang['selected'] = "selected";
else
$myLang['selected'] = "";
}
// ---
// --- Init for DefaultView field!
// copy Views Array
$content['USER_VIEWS'] = $content['Views'];
$userViewID = GetConfigSetting('DefaultViewsID', $content['DefaultViewsID'], CFGLEVEL_USER);
foreach ( $content['USER_VIEWS'] as &$myView )
{
if ( $myView['ID'] == $userViewID )
$myView['selected'] = "selected";
else
$myView['selected'] = "";
}
// ---
// --- Init for DefaultSource field!
// copy Sources Array
$content['USER_SOURCES'] = $content['Sources'];
$userSourceID = GetConfigSetting('DefaultSourceID', $content['DefaultSourceID'], CFGLEVEL_USER);
foreach ( $content['USER_SOURCES'] as &$mySource )
{
if ( $mySource['ID'] == $userSourceID )
$mySource['selected'] = "selected";
else
$mySource['selected'] = "";
}
// ---
}
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GENOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_index.html");
$page -> output();
// ---
?>

87
src/admin/result.php Normal file
View File

@ -0,0 +1,87 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Admin Index File
*
* -> Shows ...
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Include LogStream facility
// include($gl_root_path . 'classes/logstream.class.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// Hardcoded atm
$content['REDIRSECONDS'] = 2;
// *** *** //
// --- CONTENT Vars
if ( isset($_GET['redir']) )
{
$content['EXTRA_METATAGS'] = '<meta HTTP-EQUIV="REFRESH" CONTENT="' . $content['REDIRSECONDS'] . '; URL=' . urldecode($_GET['redir']) . '">';
$content['SZREDIR'] = urldecode($_GET['redir']);
}
else
{
$_GET['redir'] = "index.php";
}
if ( isset($_GET['msg']) )
$content['SZMSG'] = urldecode($_GET['msg']);
else
$content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"];
$content['TITLE'] = "phpLogCon - Redirecting to '" . $content['SZREDIR'] . "' in 5 seconds"; // Title of the Page
// ---
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/result.html");
$page -> output();
// ---
?>

332
src/admin/searches.php Normal file
View File

@ -0,0 +1,332 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Search Admin File
*
* -> Helps administrating custom searches
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWSEARCH'] = "true";
$content['SEARCH_FORMACTION'] = "addnewsearch";
$content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_ADD'];
//PreInit these values
$content['DisplayName'] = "";
$content['SearchQuery'] = "";
// General stuff
$content['userid'] = null;
$content['CHECKED_ISUSERONLY'] = "";
$content['SEARCHID'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
$content['ISGROUPSAVAILABLE'] = true;
else
$content['ISGROUPSAVAILABLE'] = false;
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWSEARCH'] = "true";
$content['SEARCH_FORMACTION'] = "editsearch";
$content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SEARCHID'] = DB_RemoveBadChars($_GET['id']);
$sqlquery = "SELECT * " .
" FROM " . DB_SEARCHES .
" WHERE ID = " . $content['SEARCHID'];
$result = DB_Query($sqlquery);
$mysearch = DB_GetSingleRow($result, true);
if ( isset($mysearch['DisplayName']) )
{
$content['SEARCHID'] = $mysearch['ID'];
$content['DisplayName'] = $mysearch['DisplayName'];
$content['SearchQuery'] = $mysearch['SearchQuery'];
if ( $mysearch['userid'] != null )
$content['CHECKED_ISUSERONLY'] = "checked";
else
$content['CHECKED_ISUSERONLY'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
{
// Process All Groups
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
{
if ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] )
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
else
$content['SUBGROUPS'][$i]['group_selected'] = "";
}
// Enable Group Selection
$content['ISGROUPSAVAILABLE'] = true;
}
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else
{
$content['ISEDITORNEWSEARCH'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
}
}
else
{
$content['ISEDITORNEWSEARCH'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SEARCHID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
$result = DB_Query("SELECT DisplayName FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['DisplayName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
}
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SEARCH_WARNDELETESEARCH'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_DELSEARCH'], $content['SEARCHID'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "searches.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID'];
}
}
}
if ( isset($_POST['op']) )
{
if ( isset ($_POST['id']) ) { $content['SEARCHID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SEARCHID'] = -1; }
if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; }
if ( isset ($_POST['SearchQuery']) ) { $content['SearchQuery'] = DB_RemoveBadChars($_POST['SearchQuery']); } else {$content['SearchQuery'] = ""; }
// User & Group handeled specially
if ( isset ($_POST['isuseronly']) )
{
$content['userid'] = $content['SESSION_USERID'];
$content['groupid'] = "null"; // Either user or group not both!
}
else
{
$content['userid'] = "null";
if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 )
$content['groupid'] = intval($_POST['groupid']);
else
$content['groupid'] = "null";
}
// --- Check mandotary values
if ( $content['DisplayName'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY'];
}
else if ( $content['SearchQuery'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY'];
}
// ---
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewsearch" )
{
// Add custom search now!
$sqlquery = "INSERT INTO " . DB_SEARCHES . " (DisplayName, SearchQuery, userid, groupid)
VALUES ('" . $content['DisplayName'] . "',
'" . $content['SearchQuery'] . "',
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" );
}
else if ( $_POST['op'] == "editsearch" )
{
$result = DB_Query("SELECT ID FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
}
else
{
// Edit the Search Entry now!
$result = DB_Query("UPDATE " . DB_SEARCHES . " SET
DisplayName = '" . $content['DisplayName'] . "',
SearchQuery = '" . $content['SearchQuery'] . "',
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['SEARCHID']);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" );
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTSEARCHES'] = "true";
// Copy Search array for further modifications
$content['SEARCHES'] = $content['Search'];
$i = 0; // Help counter!
foreach ($content['SEARCHES'] as &$mySearch )
{
$mySearch['SearchQuery_Display'] = strlen($mySearch['SearchQuery']) > 25 ? substr($mySearch['SearchQuery'], 0, 25) . " ..." : $mySearch['SearchQuery'];
// Allow EDIT
$mySearch['ActionsAllowed'] = true;
// --- Set Image for Type
if ( $mySearch['userid'] != null )
{
$mySearch['SearchTypeImage'] = $content["MENU_ADMINUSERS"];
$mySearch['SearchTypeText'] = $content["LN_GEN_USERONLY"];
}
else if ( $mySearch['groupid'] != null )
{
$mySearch['SearchTypeImage'] = $content["MENU_ADMINGROUPS"];
$mySearch['SearchTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySearch['groupname'] );
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$mySearch['ActionsAllowed'] = false;
}
else
{
$mySearch['SearchTypeImage'] = $content["MENU_GLOBAL"];
$mySearch['SearchTypeText'] = $content["LN_GEN_GLOBAL"];
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$mySearch['ActionsAllowed'] = false;
}
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$mySearch['cssclass'] = "line1";
else
$mySearch['cssclass'] = "line2";
$i++;
// ---
}
// ---
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SEARCHOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_searches.html");
$page -> output();
// ---
?>

671
src/admin/sources.php Normal file
View File

@ -0,0 +1,671 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Sources Admin File
*
* -> Helps administrating phplogcon datasources
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWSOURCE'] = "true";
$content['SOURCE_FORMACTION'] = "addnewsource";
$content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_ADD'];
//PreInit these values
$content['Name'] = "";
$content['SourceType'] = SOURCE_DISK;
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = "";
$content['MsgNormalize'] = 0;
$content['CHECKED_ISNORMALIZEMSG'] = "";
// Init View List!
$content['SourceViewID'] = 'SYSLOG';
$content['VIEWS'] = $content['Views'];
foreach ( $content['VIEWS'] as $myView )
{
if ( $myView['ID'] == $content['SourceViewID'] )
$content['VIEWS'][ $myView['ID'] ]['selected'] = "selected";
else
$content['VIEWS'][ $myView['ID'] ]['selected'] = "";
}
// SOURCE_DISK specific
$content['SourceLogLineType'] = "";
CreateLogLineTypesList($content['SourceLogLineType']);
$content['SourceDiskFile'] = "/var/log/syslog";
// SOURCE_DB specific
$content['SourceDBType'] = DB_MYSQL;
CreateDBTypesList($content['SourceDBType']);
$content['SourceDBName'] = "phplogcon";
$content['SourceDBTableType'] = "monitorware";
$content['SourceDBServer'] = "localhost";
$content['SourceDBTableName'] = "systemevents";
$content['SourceDBUser'] = "user";
$content['SourceDBPassword'] = "";
$content['SourceDBEnableRowCounting'] = "false";
$content['SourceDBEnableRowCounting_true'] = "";
$content['SourceDBEnableRowCounting_false'] = "checked";
// General stuff
$content['userid'] = null;
$content['CHECKED_ISUSERONLY'] = "";
$content['SOURCEID'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
$content['ISGROUPSAVAILABLE'] = true;
else
$content['ISGROUPSAVAILABLE'] = false;
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWSOURCE'] = "true";
$content['SOURCE_FORMACTION'] = "editsource";
$content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
// Check if exists
if ( is_numeric($content['SOURCEID']) && isset($content['Sources'][ $content['SOURCEID'] ]) )
{
// Get Source reference
$mysource = $content['Sources'][ $content['SOURCEID'] ];
// Copy basic properties
$content['Name'] = $mysource['Name'];
$content['SourceType'] = $mysource['SourceType'];
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = $mysource['MsgParserList'];
$content['MsgNormalize'] = $mysource['MsgNormalize'];
if ( $mysource['MsgNormalize'] == 1 )
$content['CHECKED_ISNORMALIZEMSG'] = "checked";
else
$content['CHECKED_ISNORMALIZEMSG'] = "";
// Init View List!
$content['SourceViewID'] = $mysource['ViewID'];
$content['VIEWS'] = $content['Views'];
foreach ( $content['VIEWS'] as $myView )
{
if ( $myView['ID'] == $content['SourceViewID'] )
$content['VIEWS'][ $myView['ID'] ]['selected'] = "selected";
else
$content['VIEWS'][ $myView['ID'] ]['selected'] = "";
}
// SOURCE_DISK specific
$content['SourceLogLineType'] = $mysource['LogLineType'];
CreateLogLineTypesList($content['SourceLogLineType']);
$content['SourceDiskFile'] = $mysource['DiskFile'];
// SOURCE_DB specific
$content['SourceDBType'] = $mysource['DBType'];
CreateDBTypesList($content['SourceDBType']);
$content['SourceDBName'] = $mysource['DBName'];
$content['SourceDBTableType'] = $mysource['DBTableType'];
$content['SourceDBServer'] = $mysource['DBServer'];
$content['SourceDBTableName'] = $mysource['DBTableName'];
$content['SourceDBUser'] = $mysource['DBUser'];
$content['SourceDBPassword'] = $mysource['DBPassword'];
$content['SourceDBEnableRowCounting'] = $mysource['DBEnableRowCounting'];
if ( $content['SourceDBEnableRowCounting'] == 1 )
{
$content['SourceDBEnableRowCounting_true'] = "checked";
$content['SourceDBEnableRowCounting_false'] = "";
}
else
{
$content['SourceDBEnableRowCounting_true'] = "";
$content['SourceDBEnableRowCounting_false'] = "checked";
}
if ( $mysource['userid'] != null )
$content['CHECKED_ISUSERONLY'] = "checked";
else
$content['CHECKED_ISUSERONLY'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
{
// Process All Groups
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
{
if ( $mysource['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysource['groupid'] )
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
else
$content['SUBGROUPS'][$i]['group_selected'] = "";
}
// Enable Group Selection
$content['ISGROUPSAVAILABLE'] = true;
}
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else
{
$content['ISEDITORNEWSOURCE'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'];
}
}
else
{
$content['ISEDITORNEWSEARCH'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
$result = DB_Query("SELECT Name FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['Name']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SOURCES_WARNDELETESEARCH'], $myrow['Name'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_DELSOURCE'], $content['SOURCEID'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_HASBEENDEL'], $myrow['Name'] ) , "sources.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'];
}
}
}
if ( isset($_POST['op']) )
{
// Read parameters first!
if ( isset($_POST['id']) ) { $content['SOURCEID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SOURCEID'] = -1; }
if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; }
if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); }
if ( isset($_POST['MsgParserList']) ) { $content['MsgParserList'] = DB_RemoveBadChars($_POST['MsgParserList']); }
if ( isset($_POST['MsgNormalize']) ) { $content['MsgNormalize'] = intval(DB_RemoveBadChars($_POST['MsgNormalize'])); } else {$content['MsgNormalize'] = 0; }
if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); }
if ( isset($content['SourceType']) )
{
// Disk Params
if ( $content['SourceType'] == SOURCE_DISK )
{
if ( isset($_POST['SourceLogLineType']) ) { $content['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); }
if ( isset($_POST['SourceDiskFile']) ) { $content['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); }
}
// DB Params
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
if ( isset($_POST['SourceDBType']) ) { $content['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); }
if ( isset($_POST['SourceDBName']) ) { $content['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); }
if ( isset($_POST['SourceDBTableType']) ) { $content['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); }
if ( isset($_POST['SourceDBServer']) ) { $content['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); }
if ( isset($_POST['SourceDBTableName']) ) { $content['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); }
if ( isset($_POST['SourceDBUser']) ) { $content['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); }
if ( isset($_POST['SourceDBPassword']) ) { $content['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); } else {$content['SourceDBPassword'] = ""; }
if ( isset($_POST['SourceDBEnableRowCounting']) ) { $content['SourceDBEnableRowCounting'] = DB_RemoveBadChars($_POST['SourceDBEnableRowCounting']); }
// Extra Check for this property
if ( $content['SourceDBEnableRowCounting'] != "true" )
$content['SourceDBEnableRowCounting'] = "false";
}
}
// User & Group handeled specially
if ( isset ($_POST['isuseronly']) )
{
$content['userid'] = $content['SESSION_USERID'];
$content['groupid'] = "null"; // Either user or group not both!
}
else
{
$content['userid'] = "null";
if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 )
$content['groupid'] = intval($_POST['groupid']);
else
$content['groupid'] = "null";
}
// --- Check mandotary values
if ( $content['Name'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_NAMEOFTHESOURCE'] );
}
else if ( !isset($content['SourceType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SOURCETYPE'] );
}
else if ( !isset($content['SourceViewID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_VIEW'] );
}
else
{
// Disk Params
if ( $content['SourceType'] == SOURCE_DISK )
{
if ( !isset($content['SourceLogLineType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_LOGLINETYPE'] );
}
else if ( !isset($content['SourceDiskFile']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SYSLOGFILE'] );
}
// Check if file is accessable!
else
{
// Get plain filename for testing!
$content['SourceDiskFileTesting'] = DB_StripSlahes($content['SourceDiskFile']);
// Take as it is if rootpath!
if (
( ($pos = strpos($content['SourceDiskFileTesting'], "/")) !== FALSE && $pos == 0) ||
( ($pos = strpos($content['SourceDiskFileTesting'], "\\\\")) !== FALSE && $pos == 0) ||
( ($pos = strpos($content['SourceDiskFileTesting'], ":\\")) !== FALSE ) ||
( ($pos = strpos($content['SourceDiskFileTesting'], ":/")) !== FALSE )
)
{
// Nothing really todo
true;
}
else // prepend basepath!
$content['SourceDiskFileTesting'] = $gl_root_path . $content['SourceDiskFileTesting'];
/*
if ( !is_file($content['SourceDiskFileTesting']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOTAVALIDFILE'], $szFileName );
}
*/
}
}
// DB Params
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
if ( !isset($content['SourceDBType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DATABASETYPEOPTIONS'] );
}
else if ( !isset($content['SourceDBName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBNAME'] );
}
else if ( !isset($content['SourceDBTableType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLETYPE'] );
}
else if ( !isset($content['SourceDBServer']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBSERVER'] );
}
else if ( !isset($content['SourceDBTableName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLENAME'] );
}
else if ( !isset($content['SourceDBUser']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBUSER'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_UNKNOWNSOURCE'], $content['SourceDBType'] );
}
// --- Verify the Source and report and error if needed!
// Include LogStream facility
include($gl_root_path . 'classes/logstream.class.php');
// First create a tmp source array
$tmpSource['ID'] = $content['SOURCEID'];
$tmpSource['Name'] = $content['Name'];
$tmpSource['SourceType'] = $content['SourceType'];
$tmpSource['MsgParserList'] = $content['MsgParserList'];
$tmpSource['MsgNormalize'] = $content['MsgNormalize'];
$tmpSource['ViewID'] = $content['SourceViewID'];
if ( $tmpSource['SourceType'] == SOURCE_DISK )
{
$tmpSource['LogLineType'] = $content['SourceLogLineType'];
$tmpSource['DiskFile'] = $content['SourceDiskFileTesting']; // use SourceDiskFileTesting rather then SourceDiskFile as it is corrected
}
// DB Params
else if ( $tmpSource['SourceType'] == SOURCE_DB || $tmpSource['SourceType'] == SOURCE_PDO )
{
$tmpSource['DBType'] = $content['SourceDBType'];
$tmpSource['DBName'] = $content['SourceDBName'];
$tmpSource['DBTableType'] = $content['SourceDBTableType'];
$tmpSource['DBServer'] = $content['SourceDBServer'];
$tmpSource['DBTableName'] = $content['SourceDBTableName'];
$tmpSource['DBUser'] = $content['SourceDBUser'];
$tmpSource['DBPassword'] = $content['SourceDBPassword'];
$tmpSource['DBEnableRowCounting'] = $content['SourceDBEnableRowCounting'];
$tmpSource['userid'] = $content['userid'];
$tmpSource['groupid'] = $content['groupid'];
}
// Init the source
InitSource($tmpSource);
// Create LogStream Object
$stream = $tmpSource['ObjRef']->LogStreamFactory($tmpSource['ObjRef']);
$res = $stream->Verify();
if ( $res != SUCCESS )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_WITHINSOURCE'], $tmpSource['Name'], GetErrorMessage($res) );
if ( isset($extraErrorDescription) )
$content['ERROR_MSG'] .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
// ---
}
// --- Now ADD/EDIT do the processing!
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewsource" )
{
// Add custom search now!
if ( $content['SourceType'] == SOURCE_DISK )
{
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
'" . $content['SourceViewID'] . "',
'" . $content['SourceLogLineType'] . "',
'" . $content['SourceDiskFile'] . "',
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
}
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
'" . $content['SourceViewID'] . "',
'" . $content['SourceDBTableType'] . "',
" . $content['SourceDBType'] . ",
'" . $content['SourceDBServer'] . "',
'" . $content['SourceDBName'] . "',
'" . $content['SourceDBUser'] . "',
'" . $content['SourceDBPassword'] . "',
'" . $content['SourceDBTableName'] . "',
" . $content['SourceDBEnableRowCounting'] . ",
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
}
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], $content['Name'] ) , "sources.php" );
}
else if ( $_POST['op'] == "editsource" )
{
$result = DB_Query("SELECT ID FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
else
{
// Edit the Search Entry now!
if ( $content['SourceType'] == SOURCE_DISK )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",
ViewID = '" . $content['SourceViewID'] . "',
LogLineType = '" . $content['SourceLogLineType'] . "',
DiskFile = '" . $content['SourceDiskFile'] . "',
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['SOURCEID'];
}
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",
ViewID = '" . $content['SourceViewID'] . "',
DBTableType = '" . $content['SourceDBTableType'] . "',
DBType = " . $content['SourceDBType'] . ",
DBServer = '" . $content['SourceDBServer'] . "',
DBName = '" . $content['SourceDBName'] . "',
DBUser = '" . $content['SourceDBUser'] . "',
DBPassword = '" . $content['SourceDBPassword'] . "',
DBTableName = '" . $content['SourceDBTableName'] . "',
DBEnableRowCounting = " . $content['SourceDBEnableRowCounting'] . ",
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['SOURCEID'];
}
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], $content['Name']) , "sources.php" );
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTSOURCES'] = "true";
// Copy Sources array for further modifications
$content['SOURCES'] = $content['Sources'];
// --- Process Sources
$i = 0; // Help counter!
foreach ($content['SOURCES'] as &$mySource )
{
// --- Set Image for Type
// NonNUMERIC are config files Sources, can not be editied
if ( is_numeric($mySource['ID']) )
{
// Allow EDIT
$mySource['ActionsAllowed'] = true;
if ( $mySource['userid'] != null )
{
$mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"];
$mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"];
}
else if ( $mySource['groupid'] != null )
{
$mySource['SourcesAssignedToImage'] = $content["MENU_ADMINGROUPS"];
$mySource['SourcesAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $mySource['groupname'] );
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$mySource['ActionsAllowed'] = false;
}
else
{
$mySource['SourcesAssignedToImage'] = $content["MENU_GLOBAL"];
$mySource['SourcesAssignedToText'] = $content["LN_GEN_GLOBAL"];
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$mySource['ActionsAllowed'] = false;
}
}
else
{
// Disallow EDIT
$mySource['ActionsAllowed'] = false;
$mySource['SourcesAssignedToImage'] = $content["MENU_INTERNAL"];
$mySource['SourcesAssignedToText'] = $content["LN_GEN_CONFIGFILE"];
}
// ---
// --- Set SourceType
if ( $mySource['SourceType'] == SOURCE_DISK )
{
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DISK"];
$mySource['SourcesTypeText'] = $content["LN_SOURCES_DISK"];
}
else if ( $mySource['SourceType'] == SOURCE_DB )
{
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DB"];
$mySource['SourcesTypeText'] = $content["LN_SOURCES_DB"];
}
else if ( $mySource['SourceType'] == SOURCE_PDO )
{
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_PDO"];
$mySource['SourcesTypeText'] = $content["LN_SOURCES_PDO"];
}
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$mySource['cssclass'] = "line1";
else
$mySource['cssclass'] = "line2";
$i++;
// ---
}
// ---
// print_r ( $content['SOURCES'] );
}
/*
* Helper function to read and init available msg parsers
*/
function ReadMsgParserList()
{
global $gl_root_path, $content;
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SOURCEOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_sources.html");
$page -> output();
// ---
?>

195
src/admin/upgrade.php Normal file
View File

@ -0,0 +1,195 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Sources Admin File
*
* -> Helps administrating phplogcon datasources
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
//include($gl_root_path . 'include/functions_filters.php');
// Set Upgrade Page!
define('IS_UPRGADEPAGE', true);
$content['IS_UPRGADEPAGE'] = true;
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// *** *** //
// --- BEGIN Custom Code
if ( isset($content['database_forcedatabaseupdate']) && $content['database_forcedatabaseupdate'] == "yes" )
{
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "upgrade")
{
// Lets start the uodating!
$content['UPGRADE_RUNNING'] = "1";
$content['sql_sucess'] = 0;
$content['sql_failed'] = 0;
$totaldbdefs = "";
$tblPref = GetConfigSetting("UserDBPref", "logcon");
// +1 so we start at the right DB Version!
for( $i = $content['database_installedversion']+1; $i <= $content['database_internalversion']; $i++ )
{
$myfilename = "db_update_v" . $i . ".txt";
// Lets read the table definitions :)
$handle = @fopen($content['BASEPATH'] . "include/" . $myfilename, "r");
if ($handle === false)
{
$content['ISERROR'] = "true";
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_DBUPGRADE_DBFILENOTFOUND'], $myfilename );
}
else
{
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
$pos = strpos($buffer, "--");
if ($pos === false)
$totaldbdefs .= $buffer;
else if ( $pos > 2 && strlen( trim($buffer) ) > 1 )
$totaldbdefs .= $buffer;
}
fclose($handle);
}
}
if ( !isset($content['ISERROR']) )
{
if ( strlen($totaldbdefs) <= 0 )
{
$content['ISERROR'] = "true";
$content['ERROR_MSG'] = $content['LN_DBUPGRADE_DBDEFFILESHORT'];
}
// Replace stats_ with the custom one ;)
$totaldbdefs = str_replace( "`logcon_", "`" . $tblPref, $totaldbdefs );
// Now split by sql command
$mycommands = split( ";\r\n", $totaldbdefs );
// check for different linefeed
if ( count($mycommands) <= 1 )
$mycommands = split( ";\n", $totaldbdefs );
//Still only one? Abort
if ( count($mycommands) <= 1 )
{
$content['ISERROR'] = "true";
$content['ERROR_MSG'] = $content['LN_DBUPGRADE_DBDEFFILESHORT'];
}
if ( !isset($content['ISERROR']) )
{
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
for($i = 0; $i < count($mycommands); $i++)
{
if ( strlen(trim($mycommands[$i])) > 1 )
{
$result = DB_Query( $mycommands[$i], false );
if ($result == FALSE)
{
$content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = DB_ReturnSimpleErrorMsg();
$content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = $mycommands[$i];
// --- Set CSS Class
if ( $content['sql_failed'] % 2 == 0 )
$content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line1";
else
$content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line2";
// ---
$content['sql_failed']++;
}
else
$content['sql_sucess']++;
// Free result
DB_FreeQuery($result);
}
}
// ---
// --- Upgrade Database Version in Config Table
$content['database_installedversion'] = $content['database_internalversion'];
WriteConfigValue( "database_installedversion", true );
// ---
}
}
}
else
$content['UPGRADE_DEFAULT'] = "1";
}
else
$content['UPGRADE_DEFAULT'] = "1";
}
else
$content['UPGRADE_DEFAULT'] = "0";
// disable running to be save! ;)
if ( isset($content['ISERROR']) )
$content['UPGRADE_RUNNING'] = "0";
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_DBUPGRADE_TITLE'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_upgrade.html");
$page -> output();
// ---
?>

383
src/admin/users.php Normal file
View File

@ -0,0 +1,383 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* User Admin File
*
* -> Helps administrating users
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
// Only if the user is an admin!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
if ( isset($_GET['miniop']) && $_GET['miniop'] == "setisadmin" )
{
if ( isset($_GET['id']) && isset($_GET['newval']) )
{
//PreInit these values
$content['USERID'] = intval(DB_RemoveBadChars($_GET['id']));
$iNewVal = intval(DB_RemoveBadChars($_GET['newval']));
// --- handle special case
if ( $content['USERID'] == $content['SESSION_USERID'] && (!isset($_GET['verify']) || $_GET['verify'] != "yes") && $iNewVal == 0)
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( $content['LN_USER_WARNREMOVEADMIN'], $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// Perform SQL Query!
$sqlquery = "SELECT * " .
" FROM " . DB_USERS .
" WHERE ID = " . $content['USERID'];
$result = DB_Query($sqlquery);
$myuser = DB_GetSingleRow($result, true);
if ( isset($myuser['username']) )
{
// Update is_admin setting!
$result = DB_Query("UPDATE " . DB_USERS . " SET
is_admin = $iNewVal
WHERE ID = " . $content['USERID']);
DB_FreeQuery($result);
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = "Error setting is_admin flat, invalid ID, User not found";
}
}
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWUSER'] = "true";
$content['USER_FORMACTION'] = "addnewuser";
$content['USER_SENDBUTTON'] = $content['LN_USER_ADD'];
//PreInit these values
$content['USERNAME'] = "";
$content['PASSWORD1'] = "";
$content['PASSWORD2'] = "";
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWUSER'] = "true";
$content['USER_FORMACTION'] = "edituser";
$content['USER_SENDBUTTON'] = $content['LN_USER_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['USERID'] = DB_RemoveBadChars($_GET['id']);
$sqlquery = "SELECT * " .
" FROM " . DB_USERS .
" WHERE ID = " . $content['USERID'];
$result = DB_Query($sqlquery);
$myuser = DB_GetSingleRow($result, true);
if ( isset($myuser['username']) )
{
$content['USERID'] = $myuser['ID'];
$content['USERNAME'] = $myuser['username'];
// Set is_admin flag
if ( $myuser['is_admin'] == 1 )
$content['CHECKED_ISADMIN'] = "checked";
else
$content['CHECKED_ISADMIN'] = "";
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['USERID'] = DB_RemoveBadChars($_GET['id']);
if ( !isset($_SESSION['SESSION_USERNAME']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDSESSIONS'];
}
else
{
// Get UserInfo
$result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['username']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
if ( $_SESSION['SESSION_USERNAME'] == $myrow['username'] )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DONOTDELURSLF'], $content['USERID'] );
}
else
{
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_USER_WARNDELETEUSER'], $myrow['username'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_USERS . " WHERE ID = " . $content['USERID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_DELUSER'], $content['USERID'] );
}
else
DB_FreeQuery($result);
// TODO: DELETE PERSONAL SETTINGS, GROUP MEMBERSHIP ...
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENDEL'], $myrow['username'] ) , "users.php" );
}
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_INVALIDID'];
}
}
}
if ( isset($_POST['op']) )
{
if ( isset ($_POST['id']) ) { $content['USERID'] = DB_RemoveBadChars($_POST['id']); } else {$content['USERID'] = ""; }
if ( isset ($_POST['username']) ) { $content['USERNAME'] = DB_RemoveBadChars($_POST['username']); } else {$content['USERNAME'] = ""; }
if ( isset ($_POST['password1']) ) { $content['PASSWORD1'] = DB_RemoveBadChars($_POST['password1']); } else {$content['PASSWORD1'] = ""; }
if ( isset ($_POST['password2']) ) { $content['PASSWORD2'] = DB_RemoveBadChars($_POST['password2']); } else {$content['PASSWORD2'] = ""; }
if ( isset ($_POST['isadmin']) ) { $content['ISADMIN'] = 1; } else {$content['ISADMIN'] = 0; }
// Check mandotary values
if ( $content['USERNAME'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_USEREMPTY'];
}
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewuser" )
{
$result = DB_Query("SELECT username FROM " . DB_USERS . " WHERE username = '" . $content['USERNAME'] . "'");
$myrow = DB_GetSingleRow($result, true);
if ( isset($myrow['username']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_USERNAMETAKEN'];
}
else
{
// Check if Password is set!
if ( strlen($content['PASSWORD1']) <= 0 ||
$content['PASSWORD1'] != $content['PASSWORD2'] )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT'];
}
if ( !isset($content['ISERROR']) )
{
// Create passwordhash now :)!
$content['PASSWORDHASH'] = md5( $content['PASSWORD1'] );
// Add new User now!
$result = DB_Query("INSERT INTO " . DB_USERS . " (username, password, is_admin)
VALUES ('" . $content['USERNAME'] . "',
'" . $content['PASSWORDHASH'] . "',
" . $content['ISADMIN'] . ")");
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENADDED'], $content['USERNAME'] ) , "users.php" );
}
}
}
else if ( $_POST['op'] == "edituser" )
{
$result = DB_Query("SELECT ID FROM " . DB_USERS . " WHERE ID = " . $content['USERID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_USER_ERROR_IDNOTFOUND'], $content['USERID'] );
}
else
{
// Check if Password is enabled
if ( isset($content['PASSWORD1']) && strlen($content['PASSWORD1']) > 0 )
{
if ( $content['PASSWORD1'] != $content['PASSWORD2'] )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_USER_ERROR_PASSSHORT'];
}
if ( !isset($content['ISERROR']) )
{
// Create passwordhash now :)!
$content['PASSWORDHASH'] = md5( $content['PASSWORD1'] );
// Edit the User now!
$result = DB_Query("UPDATE " . DB_USERS . " SET
username = '" . $content['USERNAME'] . "',
password = '" . $content['PASSWORDHASH'] . "',
is_admin = " . $content['ISADMIN'] . "
WHERE ID = " . $content['USERID']);
DB_FreeQuery($result);
}
}
else
{
// Edit the User now!
$result = DB_Query("UPDATE " . DB_USERS . " SET
username = '" . $content['USERNAME'] . "',
is_admin = " . $content['ISADMIN'] . "
WHERE ID = " . $content['USERID']);
DB_FreeQuery($result);
}
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENEDIT'], $content['USERNAME']) , "users.php" );
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Users
$content['LISTUSERS'] = "true";
// Read all Serverentries
$sqlquery = "SELECT ID, " .
" username, " .
" is_admin " .
" FROM " . DB_USERS .
" ORDER BY ID ";
$result = DB_Query($sqlquery);
$content['USERS'] = DB_GetAllRows($result, true);
// --- Process Users
for($i = 0; $i < count($content['USERS']); $i++)
{
// --- Set Image for IsClanMember
if ( $content['USERS'][$i]['is_admin'] == 1 )
{
$content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_ENABLED'];
$content['USERS'][$i]['set_isadmin'] = 0;
}
else
{
$content['USERS'][$i]['is_isadmin_string'] = $content['MENU_SELECTION_DISABLED'];
$content['USERS'][$i]['set_isadmin'] = 1;
}
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$content['USERS'][$i]['cssclass'] = "line1";
else
$content['USERS'][$i]['cssclass'] = "line2";
// ---
}
// ---
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_USEROPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_users.html");
$page -> output();
// ---
?>

585
src/admin/views.php Normal file
View File

@ -0,0 +1,585 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Views Admin File
*
* -> Helps administrating custom user views
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
// Only if the user is an admin!
//if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
// DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
// Init helper variable to empty string
$content['FormUrlAddOP'] = "";
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWVIEW'] = "true";
$content['VIEW_FORMACTION'] = "addnewview";
$content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_ADD'];
//PreInit these values
$content['DisplayName'] = "";
$content['userid'] = null;
$content['CHECKED_ISUSERONLY'] = "";
$content['VIEWID'] = "";
$content['FormUrlAddOP'] = "?op=add";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
$content['ISGROUPSAVAILABLE'] = true;
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWVIEW'] = "true";
$content['VIEW_FORMACTION'] = "editview";
$content['VIEW_SENDBUTTON'] = $content['LN_VIEWS_EDIT'];
// Copy Views array for further modifications
$content['VIEWS'] = $content['Views'];
// View must be loaded as well already!
if ( isset($_GET['id']) && isset($content['VIEWS'][$_GET['id']]) )
{
//PreInit these values
$content['VIEWID'] = DB_RemoveBadChars($_GET['id']);
if ( isset($content['VIEWS'][ $content['VIEWID'] ]) )
{
//Set the FormAdd URL
$content['FormUrlAddOP'] = "?op=edit&id=" . $content['VIEWID'];
$myview = $content['VIEWS'][ $content['VIEWID'] ];
$content['DisplayName'] = $myview['DisplayName'] ;
$content['userid'] = $myview['userid'];
$content['COLUMNS'] = $myview['Columns'];
if ( $content['userid'] != null )
$content['CHECKED_ISUSERONLY'] = "checked";
else
$content['CHECKED_ISUSERONLY'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
{
// Process All Groups
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
{
if ( $myview['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $myview['groupid'] )
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
else
$content['SUBGROUPS'][$i]['group_selected'] = "";
}
// Enable Group Selection
$content['ISGROUPSAVAILABLE'] = true;
}
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else
{
$content['ISEDITORNEWVIEW'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] );
}
}
else
{
$content['ISEDITORNEWVIEW'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_INVALIDID'], isset($_GET['id']) ? $_GET['id'] : "<unknown>" );
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['VIEWID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
$result = DB_Query("SELECT DisplayName FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['DisplayName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] );
}
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_VIEWS_WARNDELETEVIEW'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_DELSEARCH'], $content['VIEWID'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "views.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_INVALIDID'];
}
}
}
// --- Additional work todo for the edit view
if ( isset($content['ISEDITORNEWVIEW']) && $content['ISEDITORNEWVIEW'] )
{
// If Columns are send using POST we use them, otherwise we try to use from the view itself, if available
if ( isset($_POST['Columns']) )
$AllColumns = $_POST['Columns'];
else if ( isset($content['COLUMNS']) )
$AllColumns = $content['COLUMNS'];
// Read Columns from FORM data!
if ( isset($AllColumns) )
{
// --- Read Columns from Formdata
if ( is_array($AllColumns) )
{
// Copy columns ID's
foreach ($AllColumns as $myColKey)
$content['SUBCOLUMNS'][$myColKey]['ColFieldID'] = $myColKey;
}
else // One element only
$content['SUBCOLUMNS'][$AllColumns]['ColFieldID'] = $AllColumns;
// ---
// --- Process Columns for display
$i = 0; // Help counter!
foreach ($content['SUBCOLUMNS'] as $key => &$myColumn )
{
// Set Fieldcaption
if ( isset($fields[$key]) && isset($content[ $fields[$key]['FieldCaptionID'] ]) )
$myColumn['ColCaption'] = $content[ $fields[$key]['FieldCaptionID'] ];
else
$myColumn['ColCaption'] = $key;
// --- Set CSS Class
if ( $i % 2 == 0 )
$myColumn['colcssclass'] = "line1";
else
$myColumn['colcssclass'] = "line2";
$i++;
// ---
}
// ---
}
// --- Copy fields data array
$content['FIELDS'] = $fields;
// removed already added fields
if ( isset($content['SUBCOLUMNS']) )
{
foreach ($content['SUBCOLUMNS'] as $key => &$myColumn )
{
if ( isset($content['FIELDS'][$key]) )
unset($content['FIELDS'][$key]);
}
}
// set fieldcaption
foreach ($content['FIELDS'] as $key => &$myField )
{
// Set Fieldcaption
if ( isset($content[ $myField['FieldCaptionID'] ]) )
$myField['FieldCaption'] = $content[ $myField['FieldCaptionID'] ];
else
$myField['FieldCaption'] = $key;
}
// ---
}
// ---
// --- Process POST Form Data
if ( isset($_POST['op']) )
{
if ( isset ($_POST['id']) ) { $content['VIEWID'] = DB_RemoveBadChars($_POST['id']); } else {$content['VIEWID'] = ""; }
if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; }
// User & Group handeled specially
if ( isset ($_POST['isuseronly']) )
{
$content['userid'] = $content['SESSION_USERID'];
$content['groupid'] = "null"; // Either user or group not both!
}
else
{
$content['userid'] = "null";
if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 )
$content['groupid'] = intval($_POST['groupid']);
else
$content['groupid'] = "null";
}
// --- Check mandotary values
if ( $content['DisplayName'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_DISPLAYNAMEEMPTY'];
}
// ---
if ( !isset($content['ISERROR']) )
{
// Check subop's first!
if ( isset($_POST['subop']) )
{
if ( isset($_POST['newcolumn']) )
{
// Get NewColID
$szColId = DB_RemoveBadChars($_POST['newcolumn']);
// Add a new Column into our list!
if ( $_POST['subop'] == $content['LN_VIEWS_ADDCOLUMN'] && isset($_POST['newcolumn']) )
{
// Add New entry into columnlist
$content['SUBCOLUMNS'][$szColId]['ColFieldID'] = $szColId;
// Set Fieldcaption
if ( isset($content[ $fields[$szColId]['FieldCaptionID'] ]) )
$content['SUBCOLUMNS'][$szColId]['ColCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ];
else
$content['SUBCOLUMNS'][$szColId]['ColCaption'] = $szColId;
// Set CSSClass
$content['SUBCOLUMNS'][$szColId]['colcssclass'] = count($content['SUBCOLUMNS']) % 2 == 0 ? "line1" : "line2";
// Remove from fields list as well
if ( isset($content['FIELDS'][$szColId]) )
unset($content['FIELDS'][$szColId]);
}
}
}
else if ( isset($_POST['subop_delete']) )
{
// Get Column ID
$szColId = DB_RemoveBadChars($_POST['subop_delete']);
// Remove Entry from Columnslist
if ( isset($content['SUBCOLUMNS'][$szColId]) )
unset($content['SUBCOLUMNS'][$szColId]);
// Add removed entry to field list
$content['FIELDS'][$szColId] = $szColId;
// Set Fieldcaption
if ( isset($fields[$szColId]) && isset($content[ $fields[$szColId]['FieldCaptionID'] ]) )
$content['FIELDS'][$szColId]['FieldCaption'] = $content[ $fields[$szColId]['FieldCaptionID'] ];
else
$content['FIELDS'][$szColId]['FieldCaption'] = $szColId;
}
else if ( isset($_POST['subop_moveup']) )
{
// Get Column ID
$szColId = DB_RemoveBadChars($_POST['subop_moveup']);
// --- Move Entry one UP in Columnslist
// Find the entry in the array
$iArrayNum = 0;
foreach ($content['SUBCOLUMNS'] as $key => &$myColumn )
{
if ( $key == $szColId )
break;
$iArrayNum++;
}
// If found move up
if ( $iArrayNum > 0 )
{
// Extract Entry from the array
$EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1);
// Unset Entry from the array
unset( $content['SUBCOLUMNS'][$szColId] );
// Splice the array order!
array_splice($content['SUBCOLUMNS'], $iArrayNum-1, 0, $EntryTwoMove);
}
// ---
}
else if ( isset($_POST['subop_movedown']) )
{
// Get Column ID
$szColId = DB_RemoveBadChars($_POST['subop_movedown']);
// --- Move Entry one DOWN in Columnslist
// Find the entry in the array
$iArrayNum = 0;
foreach ($content['SUBCOLUMNS'] as $key => &$myColumn )
{
if ( $key == $szColId )
break;
$iArrayNum++;
}
// If found move down
if ( $iArrayNum < count($content['SUBCOLUMNS']) )
{
// Extract Entry from the array
$EntryTwoMove = array_slice($content['SUBCOLUMNS'], $iArrayNum, 1);
// Unset Entry from the array
unset( $content['SUBCOLUMNS'][$szColId] );
// Splice the array order!
array_splice($content['SUBCOLUMNS'], $iArrayNum+1, 0, $EntryTwoMove);
}
// ---
}
else // Now SUBOP means normal processing!
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewview" )
{
// Create Columnlist comma seperated!
if ( isset($_POST['Columns']) && is_array($_POST['Columns']) )
{
// Copy columns ID's
foreach ($_POST['Columns'] as $myColKey)
{
if ( isset($content['COLUMNS']) )
$content['COLUMNS'] .= ", " . $myColKey;
else
$content['COLUMNS'] = $myColKey;
}
// Add custom search now!
$sqlquery = "INSERT INTO " . DB_VIEWS. " (DisplayName, Columns, userid, groupid)
VALUES ('" . $content['DisplayName'] . "',
'" . $content['COLUMNS'] . "',
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENADDED'], $content['DisplayName'] ) , "views.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS'];
}
}
else if ( $_POST['op'] == "editview" )
{
$result = DB_Query("SELECT ID FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_VIEWS_ERROR_IDNOTFOUND'], $content['VIEWID'] );
}
else
{
// Create Columnlist comma seperated!
if ( isset($_POST['Columns']) && is_array($_POST['Columns']) )
{
// Copy columns ID's
unset($content['COLUMNS']);
foreach ($_POST['Columns'] as $myColKey)
{
if ( isset($content['COLUMNS']) )
$content['COLUMNS'] .= ", " . $myColKey;
else
$content['COLUMNS'] = $myColKey;
}
// Edit the Search Entry now!
$result = DB_Query("UPDATE " . DB_VIEWS . " SET
DisplayName = '" . $content['DisplayName'] . "',
Columns = '" . $content['COLUMNS'] . "',
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['VIEWID']);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENEDIT'], $content['DisplayName']) , "views.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_VIEWS_ERROR_NOCOLUMNS'];
}
}
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTVIEWS'] = "true";
// Copy Views array for further modifications
$content['VIEWS'] = $content['Views'];
// --- Process Views
$i = 0; // Help counter!
foreach ($content['VIEWS'] as &$myView )
{
// So internal Views can not be edited but seen
if ( is_numeric($myView['ID']) )
{
$myView['ActionsAllowed'] = true;
// --- Set Image for Type
if ( $myView['userid'] != null )
{
$myView['ViewTypeImage'] = $content["MENU_ADMINUSERS"];
$myView['ViewTypeText'] = $content["LN_GEN_USERONLY"];
}
else if ( $myView['groupid'] != null )
{
$myView['ViewTypeImage'] = $content["MENU_ADMINGROUPS"];
$myView['ViewTypeText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $myView['groupname'] );
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myView['ActionsAllowed'] = false;
}
else
{
$myView['ViewTypeImage'] = $content["MENU_GLOBAL"];
$myView['ViewTypeText'] = $content["LN_GEN_GLOBAL"];
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myView['ActionsAllowed'] = false;
}
// ---
}
else
{
$myView['ActionsAllowed'] = false;
$myView['ViewTypeImage'] = $content["MENU_INTERNAL"];
$myView['ViewTypeText'] = $content["LN_GEN_INTERNAL"];
}
// --- Add DisplayNames to columns
$iBegin = true;
foreach ($myView['Columns'] as $myCol )
{
// Get Fieldcaption
if ( isset($fields[$myCol]) && isset($content[ $fields[$myCol]['FieldCaptionID'] ]) )
$myView['COLUMNS'][$myCol]['FieldCaption'] = $content[ $fields[$myCol]['FieldCaptionID'] ];
else
$myView['COLUMNS'][$myCol]['FieldCaption'] = $myCol;
if ( $iBegin )
{
$myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = "";
$iBegin = false;
}
else
$myView['COLUMNS'][$myCol]['FieldCaptionSeperator'] = ", ";
}
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$myView['cssclass'] = "line1";
else
$myView['cssclass'] = "line2";
$i++;
// ---
}
// ---
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_VIEWSOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_views.html");
$page -> output();
// ---
?>

170
src/asktheoracle.php Normal file
View File

@ -0,0 +1,170 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Details File
*
* -> This "oracle" is a helper page which generates and shows a bunch
* of usefull links ;)!
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// ---
// --- Define Extra Stylesheet!
//$content['EXTRA_STYLESHEET'] = '<link rel="stylesheet" href="css/highlight.css" type="text/css">' . "\r\n";
//$content['EXTRA_STYLESHEET'] .= '<link rel="stylesheet" href="css/menu.css" type="text/css">';
// ---
// --- READ Vars
if ( isset($_GET['type']) )
$content['oracle_type'] = $_GET['type'];
else
$content['oracle_type'] = "";
if ( isset($_GET['query']) )
$content['oracle_query'] = $_GET['query'];
else
$content['oracle_query'] = "";
if ( isset($_GET['uid']) )
$content['uid_current'] = $_GET['uid'];
else
$content['uid_current'] = "-1";
// Init
// --- BEGIN Custom Code
// Set readable type
if ( $content['oracle_type'] == "ip" )
{
$content['oracle_type_readable'] = "ip";
$content['oracle_kb_type'] = "ip";
if ( IsInternalIP($content['oracle_query']) )
$content['showonlinesearches'] = false;
else
$content['showonlinesearches'] = true;
}
else if ( $content['oracle_type'] == "domain" )
{
$content['oracle_type_readable'] = "domain";
$content['oracle_kb_type'] = "name";
$content['showonlinesearches'] = true;
}
else
{
$content['oracle_type_readable'] = "unknown type";
$content['oracle_kb_type'] = "";
$content['showonlinesearches'] = false;
}
$content['ORACLE_HELP_DETAIL'] = GetAndReplaceLangStr( $content['LN_ORACLE_HELP_DETAIL'], $content['oracle_type_readable'], $content['oracle_query'] ) ;
$content['ORACLE_HELP_TEXT'] = GetAndReplaceLangStr( $content['LN_ORACLE_HELP_TEXT'], $content['oracle_type_readable'], $content['oracle_query'], $content['LN_ORACLE_HELP_TEXT_EXTERNAL'] ) ;
$content['ORACLE_WHOIS'] = GetAndReplaceLangStr( $content['LN_ORACLE_WHOIS'], $content['oracle_type_readable'], $content['oracle_query'] ) ;
$content['WhoisUrl'] = "http://kb.monitorware.com/kbsearch.php?sa=whois&oid=" . $content['oracle_kb_type'] . "&origin=phplogcon&q=" . urlencode($content['oracle_query']);
// Enable help links!
$content['helplinksenabled'] = true;
// Loop through all Sources
$i = 0;
foreach( $content['Sources'] as $mySource )
{
$myHelpLink['SourceName'] = $mySource['Name'];
$myHelpLink['MsgUrl'] = $content['BASEPATH'] . "index.php?filter=" . urlencode($content['oracle_query']) . "&search=Search&sourceid=" . $mySource['ID'];
// $myHelpLink['MsgDisplayName'] = GetAndReplaceLangStr( $content['LN_ORACLE_SEARCHINFIELD'], "Message" );
$myHelpLink['SourceUrl'] = $content['BASEPATH'] . "index.php?filter=" . urlencode("source:=" . $content['oracle_query']) . "&search=Search&sourceid=" . $mySource['ID'];
// $myHelpLink['SourceDisplayName'] = GetAndReplaceLangStr( $content['LN_ORACLE_SEARCHINFIELD'], "Source" );
// --- Set CSS Class
if ( $i % 2 == 0 )
$myHelpLink['cssclass'] = "line1";
else
$myHelpLink['cssclass'] = "line2";
$i++;
// ---
// Add to help Link array!
$content['HelpLinks'][] = $myHelpLink;
}
/*
if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'] != UID_UNKNOWN ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK )
{
// Obtain and get the Config Object
$stream_config = $content['Sources'][$currentSourceID]['ObjRef'];
// Create LogStream Object
$stream = $stream_config->LogStreamFactory($stream_config);
// $stream->SetFilter($content['searchstr']);
// --- Init the fields we need
foreach($fields as $mycolkey => $myfield)
{
$content['fields'][$mycolkey]['FieldID'] = $mycolkey;
$content['fields'][$mycolkey]['FieldCaption'] = $content[ $myfield['FieldCaptionID'] ];
$content['fields'][$mycolkey]['FieldType'] = $myfield['FieldType'];
$content['fields'][$mycolkey]['DefaultWidth'] = $myfield['DefaultWidth'];
// Append to columns array
$content['AllColumns'][] = $mycolkey;
}
// ---
// Close file!
$stream->Close();
}
*/
// ---
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
// Append custom title part!
$content['TITLE'] .= GetAndReplaceLangStr( $content['LN_ORACLE_TITLE'], $content['oracle_query']);
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "asktheoracle.html");
$page -> output();
// ---
?>

479
src/chartgenerator.php Normal file
View File

@ -0,0 +1,479 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Export Code File
*
* -> This file will create gfx of charts, and handle image caching
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
if ( !defined('IN_PHPLOGCON') )
define('IN_PHPLOGCON', true);
$gl_root_path = './';
// Now include necessary include files!
include_once($gl_root_path . 'include/functions_common.php');
include_once($gl_root_path . 'include/functions_frontendhelpers.php');
include_once($gl_root_path . 'include/functions_filters.php');
// Include LogStream facility
include_once($gl_root_path . 'classes/logstream.class.php');
// Include basic jpgraph lib
require_once ($gl_root_path . "classes/jpgraph/jpgraph.php");
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// ---
// --- READ CONTENT Vars
$content['error_occured'] = false;
if ( isset($_GET['type']) )
$content['chart_type'] = intval($_GET['type']);
else
$content['chart_type'] = CHART_CAKE;
if ( isset($_GET['width']) )
{
$content['chart_width'] = intval($_GET['width']);
// Limit Chart Size for now
if ( $content['chart_width'] < 100 )
$content['chart_width'] = 100;
else if ( $content['chart_width'] > 1000 )
$content['chart_width'] = 1000;
}
else
$content['chart_width'] = 100;
if ( isset($_GET['byfield']) )
{
if ( isset($fields[ $_GET['byfield'] ]) )
{
$content['chart_field'] = $_GET['byfield'];
$content['chart_fieldtype'] = $fields[ $content['chart_field'] ]['FieldType'];
}
else
{
$content['error_occured'] = true;
$content['error_details'] = $content['LN_GEN_ERROR_INVALIDFIELD'];
}
}
else
{
$content['error_occured'] = true;
$content['error_details'] = $content['LN_GEN_ERROR_MISSINGCHARTFIELD'];
}
if ( isset($_GET['maxrecords']) )
{
// read and verify value
$content['maxrecords'] = intval($_GET['maxrecords']);
if ( $content['maxrecords'] < 2 || $content['maxrecords'] > 100 )
$content['maxrecords'] = 10;
}
else
$content['maxrecords'] = 10;
if ( isset($_GET['showpercent']) )
{
// read and verify value
$content['showpercent'] = intval($_GET['showpercent']);
if ( $content['showpercent'] >= 1 )
$content['showpercent'] = 1;
else
$content['showpercent'] = 0;
}
else
$content['showpercent'] = 0;
// ---
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
// --- END CREATE TITLE
// --- BEGIN Custom Code
// Get data and print on the image!
if ( !$content['error_occured'] )
{
if ( isset($content['Sources'][$currentSourceID]) )
{
// Obtain and get the Config Object
$stream_config = $content['Sources'][$currentSourceID]['ObjRef'];
// Create LogStream Object
$stream = $stream_config->LogStreamFactory($stream_config);
$res = $stream->Open( $content['Columns'], true );
if ( $res == SUCCESS )
{
// Obtain data from the logstream!
$chartData = $stream->GetCountSortedByField($content['chart_field'], $content['chart_fieldtype'], $content['maxrecords']);
// If data is valid, we have an array!
if ( is_array($chartData) && count($chartData) > 0 )
{
// Create Y array!
foreach( $chartData as $myKey => $myData)
{
// Convert into filter format for submenus
$szEncodedKeyStr = str_replace(' ', '+', $myKey);
// echo $myKey . "<br>";
$YchartData[] = intval($myData);
$XchartData[] = strlen($myKey) > 0 ? $myKey : "Unknown";
if ( isset($fields[$content['chart_field']]['SearchField']) && strlen($myKey) > 0 )
$chartImageMapLinks[] = $content['BASEPATH'] . "index.php?filter=" . $fields[$content['chart_field']]['SearchField'] . "%3A%3D" . urlencode($szEncodedKeyStr) . "&search=Search";
else
$chartImageMapLinks[] = "";
$chartImageMapAlts[] = $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . ": " . $myKey;
$chartImageMapTargets[] ="_top";
}
if ( $content['chart_type'] == CHART_CAKE )
{
// Include additional code filers for this chart!
include_once ($gl_root_path . "classes/jpgraph/jpgraph_pie.php");
include_once ($gl_root_path . "classes/jpgraph/jpgraph_pie3d.php");
// Create Basic Image, and set basic properties!
$graph = new PieGraph($content['chart_width'], $content['chart_width'], 'auto');
$graph->SetMargin(30,20,30,30); // Adjust margin area
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetBox(); // Box around plotarea
// Set up the title for the graph
// $graph->title->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . '"');
// $graph->title->SetFont(FF_VERDANA,FS_NORMAL,12);
// $graph->title->SetColor("darkred");
// Setup the tab title
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) );
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
$graph->tabtitle->SetPos('left');
// Set Graph footer
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
// $graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
// $graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 8);
// $graph->footer->right->SetColor("darkred");
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Set Fonts for graph!
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,8);
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
$graph->legend->SetFont(FF_VERA,FS_NORMAL,8);
// Create
$p1 = new PiePlot3D($YchartData);
$p1->SetLegends($XchartData);
$p1->SetEdge('#333333', 1);
$p1->SetTheme('earth'); /* "earth" * "pastel" * "sand" * "water" */
$p1->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
// Set label format
if ( $content['showpercent'] == 1 )
{
$p1->SetLabelType(0);
$p1->value->SetFormat("%d%%");
}
else
{
$p1->SetLabelType(1);
$p1->value->SetFormat("%d");
}
// Set label properties
$p1->SetLabelPos(1.0);
$p1->SetSliceColors(array('#FFF584','#CBFF84','#FF6B9E','#FF9584','#EAFF84','#7BFF51','#51FFA6','#51FF52','#6BCFFF','#5170FF','#519CFF','#EAE3AD','#FFF184','#8584FF','#E698FF','#C384FF','#FF84EC','#FF98A3','#E5C285','#FFDA98' ));
$p1->value->SetFont(FF_VERA, FS_NORMAL, 8);
$p1->value->SetColor("black");
// Adjust other Pie Properties
$p1->SetLabelMargin(5);
$p1->SetCenter(0.4,0.65);
$p1->SetSize(0.3);
$p1->SetAngle(60);
$graph->Add($p1);
}
else if ( $content['chart_type'] == CHART_BARS_VERTICAL )
{
// Include additional code filers for this chart!
include_once ($gl_root_path . "classes/jpgraph/jpgraph_bar.php");
include_once ($gl_root_path . "classes/jpgraph/jpgraph_line.php");
// Create Basic Image, and set basic properties!
$graph = new Graph($content['chart_width'], $content['chart_width'], 'auto');
$graph->SetMargin(60,20,30,50); // Adjust margin area
$graph->SetScale("textlin");
$graph->SetMarginColor('white');
$graph->SetBox(); // Box around plotarea
// Setup X-AXIS
// $graph->xaxis->SetFont(FF_VERA,FS_NORMAL,10);
$graph->xaxis->SetTickLabels($XchartData);
if ( count($XchartData) > 5 )
{
$graph->SetMargin(60,20,30,80); // Adjust margin area
$graph->xaxis->SetLabelAngle(45);
$graph->xaxis->SetLabelMargin(2);
}
else
$graph->xaxis->SetLabelAngle(0);
// $graph->xaxis->scale->SetGrace(30); // So the value is readable
// Setup Y-AXIS
$graph->yaxis->scale->SetGrace(10); // So the value is readable
// $graph->yaxis->SetLabelFormat('%d %%');
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Set Fonts for graph!
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,7);
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
// Setup the tab title
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) );
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
$graph->tabtitle->SetPos('left');
// Set Graph footer
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
// Setup the X and Y grid
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Create and Add bar pot
$bplot = new BarPlot($YchartData);
$bplot->SetWidth(0.6);
$fcol='#440000';
$tcol='#FF9090';
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
$graph->Add($bplot);
// Display value in bars
$bplot->value->Show();
$bplot->value->SetFont(FF_VERA,FS_NORMAL,8);
// $bplot->value->SetAlign('left','center');
// $bplot->value->SetColor("black","darkred");
$bplot->value->SetFormat('%d');
// Add links
$bplot->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
// TODO: Make Optional!
// Create and Add filled line plot
$lplot = new LinePlot($YchartData);
$lplot->SetFillColor('skyblue@0.7');
$lplot->SetColor('navy@0.7');
$lplot->SetBarCenter();
$lplot->mark->SetType(MARK_SQUARE);
$lplot->mark->SetColor('blue@0.7');
$lplot->mark->SetFillColor('lightblue');
$lplot->mark->SetSize(6);
$graph->Add($lplot);
}
else if ( $content['chart_type'] == CHART_BARS_HORIZONTAL )
{
// Include additional code filers for this chart!
include_once ($gl_root_path . "classes/jpgraph/jpgraph_bar.php");
include_once ($gl_root_path . "classes/jpgraph/jpgraph_line.php");
// Create Basic Image, and set basic properties!
$graph = new Graph($content['chart_width'], $content['chart_width'], 'auto');
// $graph->SetMargin(60,20,30,50);
$graph->SetScale("textlin");
$graph->Set90AndMargin(80,30,30,50); // Adjust margin area
$graph->SetMarginColor('white');
$graph->SetBox(); // Box around plotarea
// Setup X-AXIS
$graph->xaxis->SetTickLabels($XchartData);
$graph->xaxis->SetLabelAngle(0);
// $graph->xaxis->SetLabelAlign('center','top');
$graph->xaxis->SetPos('min');
$graph->xaxis->SetLabelMargin(5);
$graph->xaxis->SetLabelAlign('right','center');
// Setup Y-AXIS
$graph->yaxis->scale->SetGrace(20); // So the value is readable
$graph->yaxis->SetLabelAlign('center','top');
$graph->yaxis->SetLabelFormat('%d');
$graph->yaxis->SetLabelSide(SIDE_RIGHT);
$graph->yaxis->SetTickSide(SIDE_LEFT);
// $graph->yaxis->SetTitleSide(SIDE_RIGHT);
// $graph->yaxis->SetTitleMargin(35);
$graph->yaxis->SetPos('max');
$graph->yaxis->SetTextLabelInterval(2);
// Show 0 label on Y-axis (default is not to show)
$graph->yscale->ticks->SupressZeroLabel(false);
// Set Fonts for graph!
$graph->xaxis->SetFont(FF_VERA,FS_NORMAL,7);
$graph->yaxis->SetFont(FF_VERA,FS_NORMAL,8);
// Setup the tab title
$graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_CHARTTITLE'], $content['maxrecords'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) );
$graph->tabtitle->SetFont(FF_VERA,FS_BOLD,9);
$graph->tabtitle->SetPos('right');
$graph->tabtitle->SetTabAlign('right');
// Set Graph footer
$graph->footer->left->Set ("phpLogCon v" . $content['BUILDNUMBER'] . "\n" . GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
$graph->footer->left->SetFont( FF_VERA, FS_NORMAL, 7);
// $graph->footer->right->Set ( GetAndReplaceLangStr($content['LN_STATS_GENERATEDAT'], date("Y-m-d")) );
// $graph->footer->right->SetFont( FF_VERA, FS_NORMAL, 8);
// Setup the X and Y grid
$graph->ygrid->SetFill(true,'#DDDDDD@0.5','#BBBBBB@0.5');
$graph->ygrid->SetLineStyle('dashed');
$graph->ygrid->SetColor('gray');
$graph->xgrid->Show();
$graph->xgrid->SetLineStyle('dashed');
$graph->xgrid->SetColor('gray');
// Create and Add bar pot
$bplot = new BarPlot($YchartData);
$bplot->SetWidth(0.6);
$fcol='#440000';
$tcol='#FF9090';
$bplot->SetFillGradient($fcol,$tcol,GRAD_LEFT_REFLECTION);
$graph->Add($bplot);
// Display value in bars
$bplot->value->Show();
$bplot->value->SetFont(FF_VERA,FS_NORMAL, 8);
// $bplot->value->SetAlign('left','center');
// $bplot->value->SetColor("black","darkred");
$bplot->value->SetFormat('%d');
// Add links
$bplot->SetCSIMTargets($chartImageMapLinks, $chartImageMapAlts, $chartImageMapTargets);
// TODO: Make Optional!
// Create and Add filled line plot
$lplot = new LinePlot($YchartData);
$lplot->SetFillColor('skyblue@0.7');
$lplot->SetColor('navy@0.7');
$lplot->SetBarCenter();
$lplot->mark->SetType(MARK_SQUARE);
$lplot->mark->SetColor('blue@0.7');
$lplot->mark->SetFillColor('lightblue');
$lplot->mark->SetSize(6);
$graph->Add($lplot);
}
else
{
$content['error_occured'] = true;
$content['error_details'] = $content['LN_GEN_ERROR_INVALIDTYPE'];
}
}
else
{
$content['error_occured'] = true;
$content['error_details'] = GetErrorMessage($chartData);
if ( isset($extraErrorDescription) )
$content['error_details'] .= "\n\n" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
//$fields[SYSLOG_UID]['FieldID']
}
else
{
// This will disable to Main SyslogView and show an error message
$content['error_occured'] = true;
$content['error_details'] = GetErrorMessage($res);
if ( isset($extraErrorDescription) )
$content['error_details'] .= "\n\n" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
// Close file!
$stream->Close();
}
else
{
$content['error_occured'] = true;
$content['error_details'] = GetAndReplaceLangStr( $content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID);
}
}
if ( $content['error_occured'] )
{
// Use JpGraph to display errors!
$myError = new JpGraphErrObjectImg();
$myError->SetTitle($content['LN_GEN_ERRORDETAILS']);
$myError->Raise($content['error_details'], true);
exit;
/* // QUICK AND DIRTY!
$myImage = imagecreatetruecolor( $content['chart_width'], $content['chart_width']);
$text_color = imagecolorallocate($myImage, 255, 0, 0);
imagestring($myImage, 3, 10, 10, $content['LN_GEN_ERRORDETAILS'], $text_color);
imagestring($myImage, 3, 10, 25, $content['error_details'], $text_color);
header ("Content-type: image/png");
imagepng($myImage); // Outputs the image to the browser
imagedestroy($myImage); // Clean Image resource
*/
}
// ---
// --- Output the image
//$graph->Stroke();
$graph->StrokeCSIM( basename(__FILE__), '', 0);
// ---
?>

View File

@ -98,9 +98,8 @@ class Template {
function parser ($vars = '', $filename = '')
{
// BEGIN DELTA MOD
global $CFG;
// For MiscShowPageRenderStats
if ( $CFG['MiscShowPageRenderStats'] == 1 )
if ( GetConfigSetting("MiscShowPageRenderStats", 1, CFGLEVEL_USER) == 1 )
FinishPageRenderStats( $vars );
// END DELTA MOD

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,229 @@
<?php
//=======================================================================
// File: JPG-CONFIG.INC
// Description: Configuration file for JpGraph library
// Created: 2004-03-27
// Ver: $Id: jpg-config.inc.php 781 2006-10-08 08:07:47Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//------------------------------------------------------------------------
// Directories for cache and font directory.
//
// CACHE_DIR:
// The full absolute name of the directory to be used to store the
// cached image files. This directory will not be used if the USE_CACHE
// define (further down) is false. If you enable the cache please note that
// this directory MUST be readable and writable for the process running PHP.
// Must end with '/'
//
// TTF_DIR:
// Directory where TTF fonts can be found. Must end with '/'
//
// The default values used if these defines are left commented out are:
//
// UNIX:
// CACHE_DIR /tmp/jpgraph_cache/
// TTF_DIR /usr/X11R6/lib/X11/fonts/truetype/
// MBTTF_DIR /usr/share/fonts/ja/TrueType/
//
// WINDOWS:
// CACHE_DIR $SERVER_TEMP/jpgraph_cache/
// TTF_DIR $SERVER_SYSTEMROOT/fonts/
// MBTTF_DIR $SERVER_SYSTEMROOT/fonts/
//
//------------------------------------------------------------------------
// DEFINE("CACHE_DIR","/tmp/jpgraph_cache/");
// DEFINE("TTF_DIR","/usr/X11R6/lib/X11/fonts/truetype/");
DEFINE("TTF_DIR", $gl_root_path . "BitstreamVeraFonts/");
// DEFINE("MBTTF_DIR","/usr/share/fonts/ja/TrueType/");
//-------------------------------------------------------------------------
// Cache directory specification for use with CSIM graphs that are
// using the cache.
// The directory must be the filesysystem name as seen by PHP
// and the 'http' version must be the same directory but as
// seen by the HTTP server relative to the 'htdocs' ddirectory.
// If a relative path is specified it is taken to be relative from where
// the image script is executed.
// Note: The default setting is to create a subdirectory in the
// directory from where the image script is executed and store all files
// there. As ususal this directory must be writeable by the PHP process.
DEFINE("CSIMCACHE_DIR","csimcache/");
DEFINE("CSIMCACHE_HTTP_DIR","csimcache/");
//------------------------------------------------------------------------
// Defines for font setup
//------------------------------------------------------------------------
// Actual name of the TTF file used together with FF_CHINESE aka FF_BIG5
// This is the TTF file being used when the font family is specified as
// either FF_CHINESE or FF_BIG5
DEFINE('CHINESE_TTF_FONT','bkai00mp.ttf');
// Special unicode greek language support
DEFINE("LANGUAGE_GREEK",false);
// If you are setting this config to true the conversion of greek characters
// will assume that the input text is windows 1251
DEFINE("GREEK_FROM_WINDOWS",false);
// Special unicode cyrillic language support
DEFINE("LANGUAGE_CYRILLIC",false);
// If you are setting this config to true the conversion
// will assume that the input text is windows 1251, if
// false it will assume koi8-r
DEFINE("CYRILLIC_FROM_WINDOWS",false);
// The following constant is used to auto-detect
// whether cyrillic conversion is really necessary
// if enabled. Just replace 'windows-1251' with a variable
// containing the input character encoding string
// of your application calling jpgraph.
// A typical such string would be 'UTF-8' or 'utf-8'.
// The comparison is case-insensitive.
// If this charset is not a 'koi8-r' or 'windows-1251'
// derivate then no conversion is done.
//
// This constant can be very important in multi-user
// multi-language environments where a cyrillic conversion
// could be needed for some cyrillic people
// and resulting in just erraneous conversions
// for not-cyrillic language based people.
//
// Example: In the free project management
// software dotproject.net $locale_char_set is dynamically
// set by the language environment the user has chosen.
//
// Usage: DEFINE('LANGUAGE_CHARSET', $locale_char_set);
//
// where $locale_char_set is a GLOBAL (string) variable
// from the application including JpGraph.
//
DEFINE('LANGUAGE_CHARSET', null);
// Japanese TrueType font used with FF_MINCHO, FF_PMINCHO, FF_GOTHIC, FF_PGOTHIC
DEFINE('MINCHO_TTF_FONT','ipam.ttf');
DEFINE('PMINCHO_TTF_FONT','ipamp.ttf');
DEFINE('GOTHIC_TTF_FONT','ipag.ttf');
DEFINE('PGOTHIC_TTF_FONT','ipagp.ttf');
// Assume that Japanese text have been entered in EUC-JP encoding.
// If this define is true then conversion from EUC-JP to UTF8 is done
// automatically in the library using the mbstring module in PHP.
DEFINE('ASSUME_EUCJP_ENCODING',false);
//------------------------------------------------------------------------
// Various JpGraph Settings. Adjust accordingly to your
// preferences. Note that cache functionality is turned off by
// default (Enable by setting USE_CACHE to true)
//------------------------------------------------------------------------
// Deafult locale for error messages.
// This defaults to English = 'en'
DEFINE('DEFAULT_ERR_LOCALE','en');
// Deafult graphic format set to "auto" which will automatically
// choose the best available format in the order png,gif,jpeg
// (The supported format depends on what your PHP installation supports)
DEFINE("DEFAULT_GFORMAT","auto");
// Should the cache be used at all? By setting this to false no
// files will be generated in the cache directory.
// The difference from READ_CACHE being that setting READ_CACHE to
// false will still create the image in the cache directory
// just not use it. By setting USE_CACHE=false no files will even
// be generated in the cache directory.
DEFINE("USE_CACHE",false);
// Should we try to find an image in the cache before generating it?
// Set this define to false to bypass the reading of the cache and always
// regenerate the image. Note that even if reading the cache is
// disabled the cached will still be updated with the newly generated
// image. Set also "USE_CACHE" below.
DEFINE("READ_CACHE",true);
// Determine if the error handler should be image based or purely
// text based. Image based makes it easier since the script will
// always return an image even in case of errors.
DEFINE("USE_IMAGE_ERROR_HANDLER",true);
// Should the library examin the global php_errmsg string and convert
// any error in it to a graphical representation. This is handy for the
// occasions when, for example, header files cannot be found and this results
// in the graph not being created and just a "red-cross" image would be seen.
// This should be turned off for a production site.
DEFINE("CATCH_PHPERRMSG",true);
// Determine if the library should also setup the default PHP
// error handler to generate a graphic error mesage. This is useful
// during development to be able to see the error message as an image
// instead as a "red-cross" in a page where an image is expected.
DEFINE("INSTALL_PHP_ERR_HANDLER",false);
// If the color palette is full should JpGraph try to allocate
// the closest match? If you plan on using background images or
// gradient fills it might be a good idea to enable this.
// If not you will otherwise get an error saying that the color palette is
// exhausted. The drawback of using approximations is that the colors
// might not be exactly what you specified.
// Note1: This does only apply to paletted images, not truecolor
// images since they don't have the limitations of maximum number
// of colors.
DEFINE("USE_APPROX_COLORS",true);
// Should usage of deprecated functions and parameters give a fatal error?
// (Useful to check if code is future proof.)
DEFINE("ERR_DEPRECATED",true);
// Should the time taken to generate each picture be branded to the lower
// left in corner in each generated image? Useful for performace measurements
// generating graphs
DEFINE("BRAND_TIMING",false);
// What format should be used for the timing string?
DEFINE("BRAND_TIME_FORMAT","(%01.3fs)");
//------------------------------------------------------------------------
// The following constants should rarely have to be changed !
//------------------------------------------------------------------------
// What group should the cached file belong to
// (Set to "" will give the default group for the "PHP-user")
// Please note that the Apache user must be a member of the
// specified group since otherwise it is impossible for Apache
// to set the specified group.
DEFINE("CACHE_FILE_GROUP","wwwadmin");
// What permissions should the cached file have
// (Set to "" will give the default persmissions for the "PHP-user")
DEFINE("CACHE_FILE_MOD",0664);
// Decide if we should use the bresenham circle algorithm or the
// built in Arc(). Bresenham gives better visual apperance of circles
// but is more CPU intensive and slower then the built in Arc() function
// in GD. Turned off by default for speed
DEFINE("USE_BRESENHAM",false);
// Special file name to indicate that we only want to calc
// the image map in the call to Graph::Stroke() used
// internally from the GetHTMLCSIM() method.
DEFINE("_CSIM_SPECIALFILE","_csim_special_");
// HTTP GET argument that is used with image map
// to indicate to the script to just generate the image
// and not the full CSIM HTML page.
DEFINE("_CSIM_DISPLAY","_jpg_csimd");
// Special filename for Graph::Stroke(). If this filename is given
// then the image will NOT be streamed to browser of file. Instead the
// Stroke call will return the handler for the created GD image.
DEFINE("_IMG_HANDLER","__handle");
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,278 @@
<?php
//=======================================================================
// File: JPGRAPH_ERRHANDLER.PHP
// Description: Error handler class together with handling of localized
// error messages. All localized error messages are stored
// in a separate file under the "lang/" subdirectory.
// Created: 2006-09-24
// Ver: $Id: jpgraph_errhandler.inc.php 973 2008-03-09 15:29:44Z ljp $
//
// Copyright 2006 (c) Aditus Consulting. All rights reserved.
//========================================================================
GLOBAL $__jpg_err_locale ;
$__jpg_err_locale = DEFAULT_ERR_LOCALE;
class ErrMsgText {
private $lt=NULL;
function ErrMsgText() {
GLOBAL $__jpg_err_locale;
$file = 'lang/'.$__jpg_err_locale.'.inc.php';
// If the chosen locale doesn't exist try english
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
$__jpg_err_locale = 'en';
}
$file = 'lang/'.$__jpg_err_locale.'.inc.php';
if( !file_exists(dirname(__FILE__).'/'.$file) ) {
die('Chosen locale file ("'.$file.'") for error messages does not exist or is not readable for the PHP process. Please make sure that the file exists and that the file permissions are such that the PHP process is allowed to read this file.');
}
require($file);
$this->lt = $_jpg_messages;
}
function Get($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) {
GLOBAL $__jpg_err_locale;
if( !isset($this->lt[$errnbr]) ) {
return 'Internal error: The specified error message ('.$errnbr.') does not exist in the chosen locale ('.$__jpg_err_locale.')';
}
$ea = $this->lt[$errnbr];
$j=0;
if( $a1 !== null ) {
$argv[$j++] = $a1;
if( $a2 !== null ) {
$argv[$j++] = $a2;
if( $a3 !== null ) {
$argv[$j++] = $a3;
if( $a4 !== null ) {
$argv[$j++] = $a4;
if( $a5 !== null ) {
$argv[$j++] = $a5;
}
}
}
}
}
$numargs = $j;
if( $ea[1] != $numargs ) {
// Error message argument count do not match.
// Just return the error message without arguments.
return $ea[0];
}
switch( $numargs ) {
case 1:
$msg = sprintf($ea[0],$argv[0]);
break;
case 2:
$msg = sprintf($ea[0],$argv[0],$argv[1]);
break;
case 3:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2]);
break;
case 4:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3]);
break;
case 5:
$msg = sprintf($ea[0],$argv[0],$argv[1],$argv[2],$argv[3],$argv[4]);
break;
case 0:
default:
$msg = sprintf($ea[0]);
break;
}
return $msg;
}
}
//
// A wrapper class that is used to access the specified error object
// (to hide the global error parameter and avoid having a GLOBAL directive
// in all methods.
//
class JpGraphError {
private static $__jpg_err;
public static function Install($aErrObject) {
self::$__jpg_err = new $aErrObject;
}
public static function Raise($aMsg,$aHalt=true){
self::$__jpg_err->Raise($aMsg,$aHalt);
}
public static function SetErrLocale($aLoc) {
GLOBAL $__jpg_err_locale ;
$__jpg_err_locale = $aLoc;
}
public static function RaiseL($errnbr,$a1=null,$a2=null,$a3=null,$a4=null,$a5=null) {
$t = new ErrMsgText();
$msg = $t->Get($errnbr,$a1,$a2,$a3,$a4,$a5);
self::$__jpg_err->Raise($msg);
}
}
//
// First of all set up a default error handler
//
//=============================================================
// The default trivial text error handler.
//=============================================================
class JpGraphErrObject {
protected $iTitle = "JpGraph Error";
protected $iDest = false;
function JpGraphErrObject() {
// Empty. Reserved for future use
}
function SetTitle($aTitle) {
$this->iTitle = $aTitle;
}
function SetStrokeDest($aDest) {
$this->iDest = $aDest;
}
// If aHalt is true then execution can't continue. Typical used for fatal errors
function Raise($aMsg,$aHalt=true) {
$aMsg = $this->iTitle.' '.$aMsg;
if ($this->iDest) {
$f = @fopen($this->iDest,'a');
if( $f ) {
@fwrite($f,$aMsg);
@fclose($f);
}
}
else {
echo $aMsg;
}
if( $aHalt )
die();
}
}
//==============================================================
// An image based error handler
//==============================================================
class JpGraphErrObjectImg extends JpGraphErrObject {
function Raise($aMsg,$aHalt=true) {
$img_iconerror =
'iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAaV'.
'BMVEX//////2Xy8mLl5V/Z2VvMzFi/v1WyslKlpU+ZmUyMjEh/'.
'f0VyckJlZT9YWDxMTDjAwMDy8sLl5bnY2K/MzKW/v5yyspKlpY'.
'iYmH+MjHY/PzV/f2xycmJlZVlZWU9MTEXY2Ms/PzwyMjLFTjea'.
'AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACx'.
'IAAAsSAdLdfvwAAAAHdElNRQfTBgISOCqusfs5AAABLUlEQVR4'.
'2tWV3XKCMBBGWfkranCIVClKLd/7P2Q3QsgCxjDTq+6FE2cPH+'.
'xJ0Ogn2lQbsT+Wrs+buAZAV4W5T6Bs0YXBBwpKgEuIu+JERAX6'.
'wM2rHjmDdEITmsQEEmWADgZm6rAjhXsoMGY9B/NZBwJzBvn+e3'.
'wHntCAJdGu9SviwIwoZVDxPB9+Rc0TSEbQr0j3SA1gwdSn6Db0'.
'6Tm1KfV6yzWGQO7zdpvyKLKBDmRFjzeB3LYgK7r6A/noDAfjtS'.
'IXaIzbJSv6WgUebTMV4EoRB8a2mQiQjgtF91HdKDKZ1gtFtQjk'.
'YcWaR5OKOhkYt+ZsTFdJRfPAApOpQYJTNHvCRSJR6SJngQadfc'.
'vd69OLMddVOPCGVnmrFD8bVYd3JXfxXPtLR/+mtv59/ALWiiMx'.
'qL72fwAAAABJRU5ErkJggg==' ;
if( function_exists("imagetypes") )
$supported = imagetypes();
else
$supported = 0;
if( !function_exists('imagecreatefromstring') )
$supported = 0;
if( ob_get_length() || headers_sent() || !($supported & IMG_PNG) ) {
// Special case for headers already sent or that the installation doesn't support
// the PNG format (which the error icon is encoded in).
// Dont return an image since it can't be displayed
die($this->iTitle.' '.$aMsg);
}
$aMsg = wordwrap($aMsg,55);
$lines = substr_count($aMsg,"\n");
// Create the error icon GD
$erricon = Image::CreateFromString(base64_decode($img_iconerror));
// Create an image that contains the error text.
$w=400;
$h=100 + 15*max(0,$lines-3);
$img = new Image($w,$h);
// Drop shadow
$img->SetColor("gray");
$img->FilledRectangle(5,5,$w-1,$h-1,10);
$img->SetColor("gray:0.7");
$img->FilledRectangle(5,5,$w-3,$h-3,10);
// Window background
$img->SetColor("lightblue");
$img->FilledRectangle(1,1,$w-5,$h-5);
$img->CopyCanvasH($img->img,$erricon,5,30,0,0,40,40);
// Window border
$img->SetColor("black");
$img->Rectangle(1,1,$w-5,$h-5);
$img->Rectangle(0,0,$w-4,$h-4);
// Window top row
$img->SetColor("darkred");
for($y=3; $y < 18; $y += 2 )
$img->Line(1,$y,$w-6,$y);
// "White shadow"
$img->SetColor("white");
// Left window edge
$img->Line(2,2,2,$h-5);
$img->Line(2,2,$w-6,2);
// "Gray button shadow"
$img->SetColor("darkgray");
// Gray window shadow
$img->Line(2,$h-6,$w-5,$h-6);
$img->Line(3,$h-7,$w-5,$h-7);
// Window title
$m = floor($w/2-5);
$l = 100;
$img->SetColor("lightgray:1.3");
$img->FilledRectangle($m-$l,2,$m+$l,16);
// Stroke text
$img->SetColor("darkred");
$img->SetFont(FF_FONT2,FS_BOLD);
$img->StrokeText($m-50,15,$this->iTitle);
$img->SetColor("black");
$img->SetFont(FF_FONT1,FS_NORMAL);
$txt = new Text($aMsg,52,25);
$txt->Align("left","top");
$txt->Stroke($img);
if ($this->iDest) {
$img->Stream($this->iDest);
} else {
$img->Headers();
$img->Stream();
}
if( $aHalt )
die();
}
}
// Install the default error handler
if( USE_IMAGE_ERROR_HANDLER ) {
JpGraphError::Install("JpGraphErrObjectImg");
}
else {
JpGraphError::Install("JpGraphErrObject");
}
?>

View File

@ -0,0 +1,423 @@
<?php
/*=======================================================================
// File: JPGRAPH_GRADIENT.PHP
// Description: Create a color gradient
// Created: 2003-02-01
// Ver: $Id: jpgraph_gradient.php 947 2007-10-19 22:14:19Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// Styles for gradient color fill
DEFINE("GRAD_VER",1);
DEFINE("GRAD_VERT",1);
DEFINE("GRAD_HOR",2);
DEFINE("GRAD_MIDHOR",3);
DEFINE("GRAD_MIDVER",4);
DEFINE("GRAD_CENTER",5);
DEFINE("GRAD_WIDE_MIDVER",6);
DEFINE("GRAD_WIDE_MIDHOR",7);
DEFINE("GRAD_LEFT_REFLECTION",8);
DEFINE("GRAD_RIGHT_REFLECTION",9);
DEFINE("GRAD_RAISED_PANEL",10);
DEFINE("GRAD_DIAGONAL",11);
//===================================================
// CLASS Gradient
// Description: Handles gradient fills. This is to be
// considered a "friend" class of Class Image.
//===================================================
class Gradient {
private $img=null, $numcolors=100;
//---------------
// CONSTRUCTOR
function Gradient(&$img) {
$this->img = $img;
}
function SetNumColors($aNum) {
$this->numcolors=$aNum;
}
//---------------
// PUBLIC METHODS
// Produce a gradient filled rectangle with a smooth transition between
// two colors.
// ($xl,$yt) Top left corner
// ($xr,$yb) Bottom right
// $from_color Starting color in gradient
// $to_color End color in the gradient
// $style Which way is the gradient oriented?
function FilledRectangle($xl,$yt,$xr,$yb,$from_color,$to_color,$style=1) {
switch( $style ) {
case GRAD_VER:
$steps = ceil(abs($xr-$xl));
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for( $i=0, $x=$xl; $i < $steps; ++$i ) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yt,$x,$yb);
$x += $delta;
}
break;
case GRAD_HOR:
$steps = ceil(abs($yb-$yt));
$delta = $yb>=$yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($i=0,$y=$yt; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
break;
case GRAD_MIDHOR:
$steps = ceil(abs($yb-$yt)/2);
$delta = $yb >= $yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($y=$yt, $i=0; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
--$i;
if( abs($yb-$yt) % 2 == 1 ) --$steps;
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
$this->img->Line($xl,$y,$xr,$y);
break;
case GRAD_MIDVER:
$steps = ceil(abs($xr-$xl)/2);
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
for($x=$xl, $i=0; $i < $steps; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
--$i;
if( abs($xr-$xl) % 2 == 1 ) --$steps;
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$this->img->Line($x,$yb,$x,$yt);
break;
case GRAD_WIDE_MIDVER:
$diff = ceil(abs($xr-$xl));
$steps = floor(abs($diff)/3);
$firststep = $diff - 2*$steps ;
$delta = $xr >= $xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors);
for($x=$xl, $i=0; $i < $firststep; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
for($j=0; $j< $steps; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_WIDE_MIDHOR:
$diff = ceil(abs($yb-$yt));
$steps = floor(abs($diff)/3);
$firststep = $diff - 2*$steps ;
$delta = $yb >= $yt? 1 : -1;
$this->GetColArray($from_color,$to_color,$firststep,$colors,$this->numcolors);
for($y=$yt, $i=0; $i < $firststep; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
--$i;
$this->img->current_color = $colors[$i];
for($j=0; $j < $steps; ++$j) {
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
for($j=0; $j < $steps; ++$j, --$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($xl,$y,$xr,$y);
$y += $delta;
}
break;
case GRAD_LEFT_REFLECTION:
$steps1 = ceil(0.3*abs($xr-$xl));
$delta = $xr>=$xl ? 1 : -1;
$from_color = $this->img->rgb->Color($from_color);
$adj = 1.4;
$m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2]))));
$from_color2 = array(min(255,$from_color[0]+$m),
min(255,$from_color[1]+$m), min(255,$from_color[2]+$m));
$this->GetColArray($from_color2,$to_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps2 = max(1,ceil(0.08*abs($xr-$xl)));
$this->img->SetColor($to_color);
for($j=0; $j< $steps2; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps = abs($xr-$xl)-$steps1-$steps2;
$this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
$n = count($colors);
for($i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_RIGHT_REFLECTION:
$steps1 = ceil(0.7*abs($xr-$xl));
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$steps2 = max(1,ceil(0.08*abs($xr-$xl)));
$this->img->SetColor($to_color);
for($j=0; $j< $steps2; ++$j) {
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
$from_color = $this->img->rgb->Color($from_color);
$adj = 1.4;
$m = ($adj-1.0)*(255-min(255,min($from_color[0],min($from_color[1],$from_color[2]))));
$from_color = array(min(255,$from_color[0]+$m),
min(255,$from_color[1]+$m), min(255,$from_color[2]+$m));
$steps = abs($xr-$xl)-$steps1-$steps2;
$this->GetColArray($to_color,$from_color,$steps,$colors,$this->numcolors);
$n = count($colors);
for($i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_CENTER:
$steps = ceil(min(($yb-$yt)+1,($xr-$xl)+1)/2);
$this->GetColArray($from_color,$to_color,$steps,$colors,$this->numcolors);
$dx = ($xr-$xl)/2;
$dy = ($yb-$yt)/2;
$x=$xl;$y=$yt;$x2=$xr;$y2=$yb;
$n = count($colors);
for($x=$xl, $i=0; $x < $xl+$dx && $y < $yt+$dy && $i < $n; ++$x, ++$y, --$x2, --$y2, ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Rectangle($x,$y,$x2,$y2);
}
$this->img->Line($x,$y,$x2,$y2);
break;
case GRAD_RAISED_PANEL:
// right to left
$steps1 = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($to_color,$from_color,$steps1,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps1 && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
// left to right
$xr -= 3;
$xl += 3;
$yb -= 3;
$yt += 3;
$steps2 = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
for($x=$xl, $j=$steps2; $j >= 0; --$j) {
$this->img->current_color = $colors[$j];
$this->img->Line($x,$yb,$x,$yt);
$x += $delta;
}
break;
case GRAD_DIAGONAL:
// use the longer dimension to determine the required number of steps.
// first loop draws from one corner to the mid-diagonal and the second
// loop draws from the mid-diagonal to the opposing corner.
if($xr-$xl > $yb - $yt) {
// width is greater than height -> use x-dimension for steps
$steps = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$x += $delta;
}
for($x=$xl, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
} else {
// height is greater than width -> use y-dimension for steps
$steps = $yb-$yt;
$delta = $yb>=$yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($y=$yt, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$y += $delta;
}
for($y=$yt, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
}
break;
default:
JpGraphError::RaiseL(7001,$style);
//("Unknown gradient style (=$style).");
break;
}
}
// Fill a special case of a polygon with a flat bottom
// with a gradient. Can be used for filled line plots.
// Please note that this is NOT a generic gradient polygon fill
// routine. It assumes that the bottom is flat (like a drawing
// of a mountain)
function FilledFlatPolygon($pts,$from_color,$to_color) {
if( count($pts) == 0 ) return;
$maxy=$pts[1];
$miny=$pts[1];
$n = count($pts) ;
for( $i=0, $idx=0; $i < $n; $i += 2) {
$x = round($pts[$i]);
$y = round($pts[$i+1]);
$miny = min($miny,$y);
$maxy = max($maxy,$y);
}
$colors = array();
$this->GetColArray($from_color,$to_color,abs($maxy-$miny)+1,$colors,$this->numcolors);
for($i=$miny, $idx=0; $i <= $maxy; ++$i ) {
$colmap[$i] = $colors[$idx++];
}
$n = count($pts)/2 ;
$idx = 0 ;
while( $idx < $n-1 ) {
$p1 = array(round($pts[$idx*2]),round($pts[$idx*2+1]));
$p2 = array(round($pts[++$idx*2]),round($pts[$idx*2+1]));
// Find the largest rectangle we can fill
$y = max($p1[1],$p2[1]) ;
for($yy=$maxy; $yy > $y; --$yy) {
$this->img->current_color = $colmap[$yy];
$this->img->Line($p1[0],$yy,$p2[0]-1,$yy);
}
if( $p1[1] == $p2[1] ) continue;
// Fill the rest using lines (slow...)
$slope = ($p2[0]-$p1[0])/($p1[1]-$p2[1]);
$x1 = $p1[0];
$x2 = $p2[0]-1;
$start = $y;
if( $p1[1] > $p2[1] ) {
while( $y >= $p2[1] ) {
$x1=$slope*($start-$y)+$p1[0];
$this->img->current_color = $colmap[$y];
$this->img->Line($x1,$y,$x2,$y);
--$y;
}
}
else {
while( $y >= $p1[1] ) {
$x2=$p2[0]+$slope*($start-$y);
$this->img->current_color = $colmap[$y];
$this->img->Line($x1,$y,$x2,$y);
--$y;
}
}
}
}
//---------------
// PRIVATE METHODS
// Add to the image color map the necessary colors to do the transition
// between the two colors using $numcolors intermediate colors
function GetColArray($from_color,$to_color,$arr_size,&$colors,$numcols=100) {
if( $arr_size==0 ) return;
// If color is given as text get it's corresponding r,g,b values
$from_color = $this->img->rgb->Color($from_color);
$to_color = $this->img->rgb->Color($to_color);
$rdelta=($to_color[0]-$from_color[0])/$numcols;
$gdelta=($to_color[1]-$from_color[1])/$numcols;
$bdelta=($to_color[2]-$from_color[2])/$numcols;
$colorsperstep = $numcols/$arr_size;
$prevcolnum = -1;
$from_alpha = $from_color[3];
$to_alpha = $to_color[3];
$adelta = ( $to_alpha - $from_alpha ) / $numcols ;
for ($i=0; $i < $arr_size; ++$i) {
$colnum = floor($colorsperstep*$i);
if ( $colnum == $prevcolnum )
$colors[$i] = $colidx;
else {
$r = floor($from_color[0] + $colnum*$rdelta);
$g = floor($from_color[1] + $colnum*$gdelta);
$b = floor($from_color[2] + $colnum*$bdelta);
$alpha = $from_alpha + $colnum*$adelta;
$colidx = $this->img->rgb->Allocate(sprintf("#%02x%02x%02x",$r,$g,$b),$alpha);
$colors[$i] = $colidx;
}
$prevcolnum = $colnum;
}
}
} // Class
?>

View File

@ -0,0 +1,632 @@
<?php
/*=======================================================================
// File: JPGRAPH_LINE.PHP
// Description: Line plot extension for JpGraph
// Created: 2001-01-08
// Ver: $Id: jpgraph_line.php 981 2008-03-24 11:51:12Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc.php');
// constants for the (filled) area
DEFINE("LP_AREA_FILLED", true);
DEFINE("LP_AREA_NOT_FILLED", false);
DEFINE("LP_AREA_BORDER",false);
DEFINE("LP_AREA_NO_BORDER",true);
//===================================================
// CLASS LinePlot
// Description:
//===================================================
class LinePlot extends Plot{
public $mark=null;
protected $filled=false;
protected $fill_color='blue';
protected $step_style=false, $center=false;
protected $line_style=1; // Default to solid
protected $filledAreas = array(); // array of arrays(with min,max,col,filled in them)
public $barcenter=false; // When we mix line and bar. Should we center the line in the bar.
protected $fillFromMin = false ;
protected $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100;
protected $iFastStroke=false;
//---------------
// CONSTRUCTOR
function LinePlot($datay,$datax=false) {
$this->Plot($datay,$datax);
$this->mark = new PlotMark() ;
}
//---------------
// PUBLIC METHODS
// Set style, filled or open
function SetFilled($aFlag=true) {
JpGraphError::RaiseL(10001);//('LinePlot::SetFilled() is deprecated. Use SetFillColor()');
}
function SetBarCenter($aFlag=true) {
$this->barcenter=$aFlag;
}
function SetStyle($aStyle) {
$this->line_style=$aStyle;
}
function SetStepStyle($aFlag=true) {
$this->step_style = $aFlag;
}
function SetColor($aColor) {
parent::SetColor($aColor);
}
function SetFillFromYMin($f=true) {
$this->fillFromMin = $f ;
}
function SetFillColor($aColor,$aFilled=true) {
$this->fill_color=$aColor;
$this->filled=$aFilled;
}
function SetFillGradient($aFromColor,$aToColor,$aNumColors=100,$aFilled=true) {
$this->fillgrad_fromcolor = $aFromColor;
$this->fillgrad_tocolor = $aToColor;
$this->fillgrad_numcolors = $aNumColors;
$this->filled = $aFilled;
$this->fillgrad = true;
}
function Legend($graph) {
if( $this->legend!="" ) {
if( $this->filled && !$this->fillgrad ) {
$graph->legend->Add($this->legend,
$this->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
elseif( $this->fillgrad ) {
$color=array($this->fillgrad_fromcolor,$this->fillgrad_tocolor);
// In order to differentiate between gradients and cooors specified as an RGB triple
$graph->legend->Add($this->legend,$color,"",-2 /* -GRAD_HOR */,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
} else {
$graph->legend->Add($this->legend,
$this->color,$this->mark,$this->line_style,
$this->legendcsimtarget,$this->legendcsimalt,$this->legendcsimwintarget);
}
}
}
function AddArea($aMin=0,$aMax=0,$aFilled=LP_AREA_NOT_FILLED,$aColor="gray9",$aBorder=LP_AREA_BORDER) {
if($aMin > $aMax) {
// swap
$tmp = $aMin;
$aMin = $aMax;
$aMax = $tmp;
}
$this->filledAreas[] = array($aMin,$aMax,$aColor,$aFilled,$aBorder);
}
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
// (We check for empty in case the scale is a log scale
// and hence doesn't contain any xlabel_offset)
if( empty($graph->xaxis->scale->ticks->xlabel_offset) ||
$graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
if( $this->center ) {
++$this->numpoints;
$a=0.5; $b=0.5;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
//$graph->xaxis->scale->ticks->SupressMinorTickMarks();
}
}
function SetFastStroke($aFlg=true) {
$this->iFastStroke = $aFlg;
}
function FastStroke($img,$xscale,$yscale,$aStartPoint=0,$exist_x=true) {
// An optimized stroke for many data points with no extra
// features but 60% faster. You can't have values or line styles, or null
// values in plots.
$numpoints=count($this->coords[0]);
if( $this->barcenter )
$textadj = 0.5-$xscale->text_scale_off;
else
$textadj = 0;
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$pnts=$aStartPoint;
while( $pnts < $numpoints ) {
if( $exist_x ) $x=$this->coords[1][$pnts];
else $x=$pnts+$textadj;
$xt = $xscale->Translate($x);
$y=$this->coords[0][$pnts];
$yt = $yscale->Translate($y);
if( is_numeric($y) ) {
$cord[] = $xt;
$cord[] = $yt;
}
elseif( $y == '-' && $pnts > 0 ) {
// Just ignore
}
else {
JpGraphError::RaiseL(10002);//('Plot too complicated for fast line Stroke. Use standard Stroke()');
}
++$pnts;
} // WHILE
$img->Polygon($cord,false,true);
}
function Stroke($img,$xscale,$yscale) {
$idx=0;
$numpoints=count($this->coords[0]);
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$numpoints )
JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints);
//("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
else
$exist_x = true;
}
else
$exist_x = false;
if( $this->barcenter )
$textadj = 0.5-$xscale->text_scale_off;
else
$textadj = 0;
// Find the first numeric data point
$startpoint=0;
while( $startpoint < $numpoints && !is_numeric($this->coords[0][$startpoint]) )
++$startpoint;
// Bail out if no data points
if( $startpoint == $numpoints )
return;
if( $this->iFastStroke ) {
$this->FastStroke($img,$xscale,$yscale,$startpoint,$exist_x);
return;
}
if( $exist_x )
$xs=$this->coords[1][$startpoint];
else
$xs= $textadj+$startpoint;
$img->SetStartPoint($xscale->Translate($xs),
$yscale->Translate($this->coords[0][$startpoint]));
if( $this->filled ) {
$min = $yscale->GetMinVal();
if( $min > 0 || $this->fillFromMin )
$fillmin = $yscale->scale_abs[0];//Translate($min);
else
$fillmin = $yscale->Translate(0);
$cord[$idx++] = $xscale->Translate($xs);
$cord[$idx++] = $fillmin;
}
$xt = $xscale->Translate($xs);
$yt = $yscale->Translate($this->coords[0][$startpoint]);
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
$yt_old = $yt;
$xt_old = $xt;
$y_old = $this->coords[0][$startpoint];
$this->value->Stroke($img,$this->coords[0][$startpoint],$xt,$yt);
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$img->SetLineStyle($this->line_style);
$pnts=$startpoint+1;
$firstnonumeric = false;
while( $pnts < $numpoints ) {
if( $exist_x ) $x=$this->coords[1][$pnts];
else $x=$pnts+$textadj;
$xt = $xscale->Translate($x);
$yt = $yscale->Translate($this->coords[0][$pnts]);
$y=$this->coords[0][$pnts];
if( $this->step_style ) {
// To handle null values within step style we need to record the
// first non numeric value so we know from where to start if the
// non value is '-'.
if( is_numeric($y) ) {
$firstnonumeric = false;
if( is_numeric($y_old) ) {
$img->StyleLine($xt_old,$yt_old,$xt,$yt_old);
$img->StyleLine($xt,$yt_old,$xt,$yt);
}
elseif( $y_old == '-' ) {
$img->StyleLine($xt_first,$yt_first,$xt,$yt_first);
$img->StyleLine($xt,$yt_first,$xt,$yt);
}
else {
$yt_old = $yt;
$xt_old = $xt;
}
$cord[$idx++] = $xt;
$cord[$idx++] = $yt_old;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
elseif( $firstnonumeric==false ) {
$firstnonumeric = true;
$yt_first = $yt_old;
$xt_first = $xt_old;
}
}
else {
$tmp1=$y;
$prev=$this->coords[0][$pnts-1];
if( $tmp1==='' || $tmp1===NULL || $tmp1==='X' ) $tmp1 = 'x';
if( $prev==='' || $prev===null || $prev==='X' ) $prev = 'x';
if( is_numeric($y) || (is_string($y) && $y != '-') ) {
if( is_numeric($y) && (is_numeric($prev) || $prev === '-' ) ) {
$img->StyleLineTo($xt,$yt);
}
else {
$img->SetStartPoint($xt,$yt);
}
}
if( $this->filled && $tmp1 !== '-' ) {
if( $tmp1 === 'x' ) {
$cord[$idx++] = $cord[$idx-3];
$cord[$idx++] = $fillmin;
}
elseif( $prev === 'x' ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $fillmin;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
else {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
else {
if( is_numeric($tmp1) && (is_numeric($prev) || $prev === '-' ) ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
}
$yt_old = $yt;
$xt_old = $xt;
$y_old = $y;
$this->StrokeDataValue($img,$this->coords[0][$pnts],$xt,$yt);
++$pnts;
}
if( $this->filled ) {
$cord[$idx++] = $xt;
if( $min > 0 || $this->fillFromMin )
$cord[$idx++] = $yscale->Translate($min);
else
$cord[$idx++] = $yscale->Translate(0);
if( $this->fillgrad ) {
$img->SetLineWeight(1);
$grad = new Gradient($img);
$grad->SetNumColors($this->fillgrad_numcolors);
$grad->FilledFlatPolygon($cord,$this->fillgrad_fromcolor,$this->fillgrad_tocolor);
$img->SetLineWeight($this->weight);
}
else {
$img->SetColor($this->fill_color);
$img->FilledPolygon($cord);
}
if( $this->line_weight > 0 ) {
$img->SetColor($this->color);
$img->Polygon($cord);
}
}
if(!empty($this->filledAreas)) {
$minY = $yscale->Translate($yscale->GetMinVal());
$factor = ($this->step_style ? 4 : 2);
for($i = 0; $i < sizeof($this->filledAreas); ++$i) {
// go through all filled area elements ordered by insertion
// fill polygon array
$areaCoords[] = $cord[$this->filledAreas[$i][0] * $factor];
$areaCoords[] = $minY;
$areaCoords =
array_merge($areaCoords,
array_slice($cord,
$this->filledAreas[$i][0] * $factor,
($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1)) * $factor));
$areaCoords[] = $areaCoords[sizeof($areaCoords)-2]; // last x
$areaCoords[] = $minY; // last y
if($this->filledAreas[$i][3]) {
$img->SetColor($this->filledAreas[$i][2]);
$img->FilledPolygon($areaCoords);
$img->SetColor($this->color);
}
// Check if we should draw the frame.
// If not we still re-draw the line since it might have been
// partially overwritten by the filled area and it doesn't look
// very good.
// TODO: The behaviour is undefined if the line does not have
// any line at the position of the area.
if( $this->filledAreas[$i][4] )
$img->Polygon($areaCoords);
else
$img->Polygon($cord);
$areaCoords = array();
}
}
if( $this->mark->type == -1 || $this->mark->show == false )
return;
for( $pnts=0; $pnts<$numpoints; ++$pnts) {
if( $exist_x ) $x=$this->coords[1][$pnts];
else $x=$pnts+$textadj;
$xt = $xscale->Translate($x);
$yt = $yscale->Translate($this->coords[0][$pnts]);
if( is_numeric($this->coords[0][$pnts]) ) {
if( !empty($this->csimtargets[$pnts]) ) {
if( !empty($this->csimwintargets[$pnts]) ) {
$this->mark->SetCSIMTarget($this->csimtargets[$pnts],$this->csimwintargets[$pnts]);
}
else {
$this->mark->SetCSIMTarget($this->csimtargets[$pnts]);
}
$this->mark->SetCSIMAlt($this->csimalts[$pnts]);
}
if( $exist_x )
$x=$this->coords[1][$pnts];
else
$x=$pnts;
$this->mark->SetCSIMAltVal($this->coords[0][$pnts],$x);
$this->mark->Stroke($img,$xt,$yt);
$this->csimareas .= $this->mark->GetCSIMAreas();
}
}
}
} // Class
//===================================================
// CLASS AccLinePlot
// Description:
//===================================================
class AccLinePlot extends Plot {
protected $plots=null,$nbrplots=0;
private $iStartEndZero=true;
//---------------
// CONSTRUCTOR
function AccLinePlot($plots) {
$this->plots = $plots;
$this->nbrplots = count($plots);
$this->numpoints = $plots[0]->numpoints;
// Verify that all plots have the same number of data points
for( $i=1; $i < $this->nbrplots; ++$i ) {
if( $plots[$i]->numpoints != $this->numpoints ) {
JpGraphError::RaiseL(10003);//('Each plot in an accumulated lineplot must have the same number of data points',0)
}
}
for($i=0; $i < $this->nbrplots; ++$i ) {
$this->LineInterpolate($this->plots[$i]->coords[0]);
}
}
//---------------
// PUBLIC METHODS
function Legend($graph) {
foreach( $this->plots as $p )
$p->DoLegend($graph);
}
function Max() {
list($xmax) = $this->plots[0]->Max();
$nmax=0;
$n = count($this->plots);
for($i=0; $i < $n; ++$i) {
$nc = count($this->plots[$i]->coords[0]);
$nmax = max($nmax,$nc);
list($x) = $this->plots[$i]->Max();
$xmax = Max($xmax,$x);
}
for( $i = 0; $i < $nmax; $i++ ) {
// Get y-value for line $i by adding the
// individual bars from all the plots added.
// It would be wrong to just add the
// individual plots max y-value since that
// would in most cases give to large y-value.
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
$y += $this->plots[ $j ]->coords[0][$i];
}
$ymax[$i] = $y;
}
$ymax = max($ymax);
return array($xmax,$ymax);
}
function Min() {
$nmax=0;
list($xmin,$ysetmin) = $this->plots[0]->Min();
$n = count($this->plots);
for($i=0; $i < $n; ++$i) {
$nc = count($this->plots[$i]->coords[0]);
$nmax = max($nmax,$nc);
list($x,$y) = $this->plots[$i]->Min();
$xmin = Min($xmin,$x);
$ysetmin = Min($y,$ysetmin);
}
for( $i = 0; $i < $nmax; $i++ ) {
// Get y-value for line $i by adding the
// individual bars from all the plots added.
// It would be wrong to just add the
// individual plots min y-value since that
// would in most cases give to small y-value.
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
$y += $this->plots[ $j ]->coords[0][$i];
}
$ymin[$i] = $y;
}
$ymin = Min($ysetmin,Min($ymin));
return array($xmin,$ymin);
}
// Gets called before any axis are stroked
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
// (We check for empty in case the scale is a log scale
// and hence doesn't contain any xlabel_offset)
if( empty($graph->xaxis->scale->ticks->xlabel_offset) ||
$graph->xaxis->scale->ticks->xlabel_offset == 0 ) {
if( $this->center ) {
++$this->numpoints;
$a=0.5; $b=0.5;
} else {
$a=0; $b=0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset($a);
$graph->SetTextScaleOff($b);
$graph->xaxis->scale->ticks->SupressMinorTickMarks();
}
}
function SetInterpolateMode($aIntMode) {
$this->iStartEndZero=$aIntMode;
}
// Replace all '-' with an interpolated value. We use straightforward
// linear interpolation. If the data starts with one or several '-' they
// will be replaced by the the first valid data point
function LineInterpolate(&$aData) {
$n=count($aData);
$i=0;
// If first point is undefined we will set it to the same as the first
// valid data
if( $aData[$i]==='-' ) {
// Find the first valid data
while( $i < $n && $aData[$i]==='-' ) {
++$i;
}
if( $i < $n ) {
for($j=0; $j < $i; ++$j ) {
if( $this->iStartEndZero )
$aData[$i] = 0;
else
$aData[$j] = $aData[$i];
}
}
else {
// All '-' => Error
return false;
}
}
while($i < $n) {
while( $i < $n && $aData[$i] !== '-' ) {
++$i;
}
if( $i < $n ) {
$pstart=$i-1;
// Now see how long this segment of '-' are
while( $i < $n && $aData[$i] === '-' )
++$i;
if( $i < $n ) {
$pend=$i;
$size=$pend-$pstart;
$k=($aData[$pend]-$aData[$pstart])/$size;
// Replace the segment of '-' with a linear interpolated value.
for($j=1; $j < $size; ++$j ) {
$aData[$pstart+$j] = $aData[$pstart] + $j*$k ;
}
}
else {
// There are no valid end point. The '-' goes all the way to the end
// In that case we just set all the remaining values the the same as the
// last valid data point.
for( $j=$pstart+1; $j < $n; ++$j )
if( $this->iStartEndZero )
$aData[$j] = 0;
else
$aData[$j] = $aData[$pstart] ;
}
}
}
return true;
}
// To avoid duplicate of line drawing code here we just
// change the y-values for each plot and then restore it
// after we have made the stroke. We must do this copy since
// it wouldn't be possible to create an acc line plot
// with the same graphs, i.e AccLinePlot(array($pl,$pl,$pl));
// since this method would have a side effect.
function Stroke($img,$xscale,$yscale) {
$img->SetLineWeight($this->weight);
$this->numpoints = count($this->plots[0]->coords[0]);
// Allocate array
$coords[$this->nbrplots][$this->numpoints]=0;
for($i=0; $i<$this->numpoints; $i++) {
$coords[0][$i]=$this->plots[0]->coords[0][$i];
$accy=$coords[0][$i];
for($j=1; $j<$this->nbrplots; ++$j ) {
$coords[$j][$i] = $this->plots[$j]->coords[0][$i]+$accy;
$accy = $coords[$j][$i];
}
}
for($j=$this->nbrplots-1; $j>=0; --$j) {
$p=$this->plots[$j];
for( $i=0; $i<$this->numpoints; ++$i) {
$tmp[$i]=$p->coords[0][$i];
$p->coords[0][$i]=$coords[$j][$i];
}
$p->Stroke($img,$xscale,$yscale);
for( $i=0; $i<$this->numpoints; ++$i)
$p->coords[0][$i]=$tmp[$i];
$p->coords[0][]=$tmp;
}
}
} // Class
/* EOF */
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,923 @@
<?php
/*=======================================================================
// File: JPGRAPH_PIE3D.PHP
// Description: 3D Pie plot extension for JpGraph
// Created: 2001-03-24
// Ver: $Id: jpgraph_pie3d.php 956 2007-11-17 13:19:20Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
//===================================================
// CLASS PiePlot3D
// Description: Plots a 3D pie with a specified projection
// angle between 20 and 70 degrees.
//===================================================
class PiePlot3D extends PiePlot {
private $labelhintcolor="red",$showlabelhint=true;
private $angle=50;
private $edgecolor="", $edgeweight=1;
private $iThickness=false;
//---------------
// CONSTRUCTOR
function PiePlot3d($data) {
$this->radius = 0.5;
$this->data = $data;
$this->title = new Text("");
$this->title->SetFont(FF_FONT1,FS_BOLD);
$this->value = new DisplayValue();
$this->value->Show();
$this->value->SetFormat('%.0f%%');
}
//---------------
// PUBLIC METHODS
// Set label arrays
function SetLegends($aLegend) {
$this->legends = array_reverse(array_slice($aLegend,0,count($this->data)));
}
function SetSliceColors($aColors) {
$this->setslicecolors = $aColors;
}
function Legend($aGraph) {
parent::Legend($aGraph);
$aGraph->legend->txtcol = array_reverse($aGraph->legend->txtcol);
}
function SetCSIMTargets($aTargets,$aAlts='',$aWinTargets='') {
$this->csimtargets = $aTargets;
$this->csimwintargets = $aWinTargets;
$this->csimalts = $aAlts;
}
// Should the slices be separated by a line? If color is specified as "" no line
// will be used to separate pie slices.
function SetEdge($aColor='black',$aWeight=1) {
$this->edgecolor = $aColor;
$this->edgeweight = $aWeight;
}
// Dummy function to make Pie3D behave in a similair way to 2D
function ShowBorder($exterior=true,$interior=true) {
JpGraphError::RaiseL(14001);
//('Pie3D::ShowBorder() . Deprecated function. Use Pie3D::SetEdge() to control the edges around slices.');
}
// Specify projection angle for 3D in degrees
// Must be between 20 and 70 degrees
function SetAngle($a) {
if( $a<5 || $a>90 )
JpGraphError::RaiseL(14002);
//("PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.");
else
$this->angle = $a;
}
function Add3DSliceToCSIM($i,$xc,$yc,$height,$width,$thick,$sa,$ea) { //Slice number, ellipse centre (x,y), height, width, start angle, end angle
$sa *= M_PI/180;
$ea *= M_PI/180;
//add coordinates of the centre to the map
$coords = "$xc, $yc";
//add coordinates of the first point on the arc to the map
$xp = floor($width*cos($sa)/2+$xc);
$yp = floor($yc-$height*sin($sa)/2);
$coords.= ", $xp, $yp";
//If on the front half, add the thickness offset
if ($sa >= M_PI && $sa <= 2*M_PI*1.01) {
$yp = floor($yp+$thick);
$coords.= ", $xp, $yp";
}
//add coordinates every 0.2 radians
$a=$sa+0.2;
while ($a<$ea) {
$xp = floor($width*cos($a)/2+$xc);
if ($a >= M_PI && $a <= 2*M_PI*1.01) {
$yp = floor($yc-($height*sin($a)/2)+$thick);
} else {
$yp = floor($yc-$height*sin($a)/2);
}
$coords.= ", $xp, $yp";
$a += 0.2;
}
//Add the last point on the arc
$xp = floor($width*cos($ea)/2+$xc);
$yp = floor($yc-$height*sin($ea)/2);
if ($ea >= M_PI && $ea <= 2*M_PI*1.01) {
$coords.= ", $xp, ".floor($yp+$thick);
}
$coords.= ", $xp, $yp";
$alt='';
if( !empty($this->csimtargets[$i]) ) {
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".$this->csimtargets[$i]."\"";
if( !empty($this->csimwintargets[$i]) ) {
$this->csimareas .= " target=\"".$this->csimwintargets[$i]."\" ";
}
if( !empty($this->csimalts[$i]) ) {
$tmp=sprintf($this->csimalts[$i],$this->data[$i]);
$this->csimareas .= "alt=\"$tmp\" title=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
}
function SetLabels($aLabels,$aLblPosAdj="auto") {
$this->labels = $aLabels;
$this->ilabelposadj=$aLblPosAdj;
}
// Distance from the pie to the labels
function SetLabelMargin($m) {
$this->value->SetMargin($m);
}
// Show a thin line from the pie to the label for a specific slice
function ShowLabelHint($f=true) {
$this->showlabelhint=$f;
}
// Set color of hint line to label for each slice
function SetLabelHintColor($c) {
$this->labelhintcolor=$c;
}
function SetHeight($aHeight) {
$this->iThickness = $aHeight;
}
// Normalize Angle between 0-360
function NormAngle($a) {
// Normalize anle to 0 to 2M_PI
//
if( $a > 0 ) {
while($a > 360) $a -= 360;
}
else {
while($a < 0) $a += 360;
}
if( $a < 0 )
$a = 360 + $a;
if( $a == 360 ) $a=0;
return $a;
}
// Draw one 3D pie slice at position ($xc,$yc) with height $z
function Pie3DSlice($img,$xc,$yc,$w,$h,$sa,$ea,$z,$fillcolor,$shadow=0.65) {
// Due to the way the 3D Pie algorithm works we are
// guaranteed that any slice we get into this method
// belongs to either the left or right side of the
// pie ellipse. Hence, no slice will cross 90 or 270
// point.
if( ($sa < 90 && $ea > 90) || ( ($sa > 90 && $sa < 270) && $ea > 270) ) {
JpGraphError::RaiseL(14003);//('Internal assertion failed. Pie3D::Pie3DSlice');
exit(1);
}
$p[] = array();
// Setup pre-calculated values
$rsa = $sa/180*M_PI; // to Rad
$rea = $ea/180*M_PI; // to Rad
$sinsa = sin($rsa);
$cossa = cos($rsa);
$sinea = sin($rea);
$cosea = cos($rea);
// p[] is the points for the overall slice and
// pt[] is the points for the top pie
// Angular step when approximating the arc with a polygon train.
$step = 0.05;
if( $sa >= 270 ) {
if( $ea > 360 || ($ea > 0 && $ea <= 90) ) {
if( $ea > 0 && $ea <= 90 ) {
// Adjust angle to simplify conditions in loops
$rea += 2*M_PI;
}
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
for( $a=$rsa; $a < 2*M_PI; $a += $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w;
$pt[] = $yc;
$p[] = $xc+$w;
$p[] = $z+$yc;
$p[] = $xc+$w;
$p[] = $yc;
$p[] = $xc;
$p[] = $yc;
for( $a=2*M_PI+$step; $a < $rea; $a += $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
}
else {
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
$rea = $rea == 0.0 ? 2*M_PI : $rea;
for( $a=$rsa; $a < $rea; $a += $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
$p[] = $xc+$w*$cosea;
$p[] = $z+$yc-$h*$sinea;
$p[] = $xc+$w*$cosea;
$p[] = $yc-$h*$sinea;
$p[] = $xc;
$p[] = $yc;
}
}
elseif( $sa >= 180 ) {
$p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a>$rsa; $a -= $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z+$yc-$h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
$p[] = $xc+$w*$cossa;
$p[] = $z+$yc-$h*$sinsa;
$p[] = $xc+$w*$cossa;
$p[] = $yc-$h*$sinsa;
$p[] = $xc;
$p[] = $yc;
}
elseif( $sa >= 90 ) {
if( $ea > 180 ) {
$p = array($xc,$yc,$xc,$yc+$z,$xc+$w*$cosea,$z+$yc-$h*$sinea);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a > M_PI; $a -= $step ) {
$tca = cos($a);
$tsa = sin($a);
$p[] = $xc+$w*$tca;
$p[] = $z + $yc - $h*$tsa;
$pt[] = $xc+$w*$tca;
$pt[] = $yc-$h*$tsa;
}
$p[] = $xc-$w;
$p[] = $z+$yc;
$p[] = $xc-$w;
$p[] = $yc;
$p[] = $xc;
$p[] = $yc;
$pt[] = $xc-$w;
$pt[] = $z+$yc;
$pt[] = $xc-$w;
$pt[] = $yc;
for( $a=M_PI-$step; $a > $rsa; $a -= $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
}
else { // $sa >= 90 && $ea <= 180
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cosea,$z+$yc-$h*$sinea,
$xc+$w*$cosea,$yc-$h*$sinea,
$xc,$yc);
$pt = array($xc,$yc,$xc+$w*$cosea,$yc-$h*$sinea);
for( $a=$rea; $a>$rsa; $a -= $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cossa;
$pt[] = $yc-$h*$sinsa;
$pt[] = $xc;
$pt[] = $yc;
}
}
else { // sa > 0 && ea < 90
$p = array($xc,$yc,$xc,$yc+$z,
$xc+$w*$cossa,$z+$yc-$h*$sinsa,
$xc+$w*$cossa,$yc-$h*$sinsa,
$xc,$yc);
$pt = array($xc,$yc,$xc+$w*$cossa,$yc-$h*$sinsa);
for( $a=$rsa; $a < $rea; $a += $step ) {
$pt[] = $xc + $w*cos($a);
$pt[] = $yc - $h*sin($a);
}
$pt[] = $xc+$w*$cosea;
$pt[] = $yc-$h*$sinea;
$pt[] = $xc;
$pt[] = $yc;
}
$img->PushColor($fillcolor.":".$shadow);
$img->FilledPolygon($p);
$img->PopColor();
$img->PushColor($fillcolor);
$img->FilledPolygon($pt);
$img->PopColor();
}
function SetStartAngle($aStart) {
if( $aStart < 0 || $aStart > 360 ) {
JpGraphError::RaiseL(14004);//('Slice start angle must be between 0 and 360 degrees.');
}
$this->startangle = $aStart;
}
// Draw a 3D Pie
function Pie3D($aaoption,$img,$data,$colors,$xc,$yc,$d,$angle,$z,
$shadow=0.65,$startangle=0,$edgecolor="",$edgeweight=1) {
//---------------------------------------------------------------------------
// As usual the algorithm get more complicated than I originally
// envisioned. I believe that this is as simple as it is possible
// to do it with the features I want. It's a good exercise to start
// thinking on how to do this to convince your self that all this
// is really needed for the general case.
//
// The algorithm two draw 3D pies without "real 3D" is done in
// two steps.
// First imagine the pie cut in half through a thought line between
// 12'a clock and 6'a clock. It now easy to imagine that we can plot
// the individual slices for each half by starting with the topmost
// pie slice and continue down to 6'a clock.
//
// In the algortithm this is done in three principal steps
// Step 1. Do the knife cut to ensure by splitting slices that extends
// over the cut line. This is done by splitting the original slices into
// upto 3 subslices.
// Step 2. Find the top slice for each half
// Step 3. Draw the slices from top to bottom
//
// The thing that slightly complicates this scheme with all the
// angle comparisons below is that we can have an arbitrary start
// angle so we must take into account the different equivalence classes.
// For the same reason we must walk through the angle array in a
// modulo fashion.
//
// Limitations of algorithm:
// * A small exploded slice which crosses the 270 degree point
// will get slightly nagged close to the center due to the fact that
// we print the slices in Z-order and that the slice left part
// get printed first and might get slightly nagged by a larger
// slice on the right side just before the right part of the small
// slice. Not a major problem though.
//---------------------------------------------------------------------------
// Determine the height of the ellippse which gives an
// indication of the inclination angle
$h = ($angle/90.0)*$d;
$sum = 0;
for($i=0; $i<count($data); ++$i ) {
$sum += $data[$i];
}
// Special optimization
if( $sum==0 ) return;
if( $this->labeltype == 2 ) {
$this->adjusted_data = $this->AdjPercentage($data);
}
// Setup the start
$accsum = 0;
$a = $startangle;
$a = $this->NormAngle($a);
//
// Step 1 . Split all slices that crosses 90 or 270
//
$idx=0;
$adjexplode=array();
$numcolors = count($colors);
for($i=0; $i<count($data); ++$i, ++$idx ) {
$da = $data[$i]/$sum * 360;
if( empty($this->explode_radius[$i]) )
$this->explode_radius[$i]=0;
$expscale=1;
if( $aaoption == 1 )
$expscale=2;
$la = $a + $da/2;
$explode = array( $xc + $this->explode_radius[$i]*cos($la*M_PI/180)*$expscale,
$yc - $this->explode_radius[$i]*sin($la*M_PI/180) * ($h/$d) *$expscale );
$adjexplode[$idx] = $explode;
$labeldata[$i] = array($la,$explode[0],$explode[1]);
$originalangles[$i] = array($a,$a+$da);
$ne = $this->NormAngle($a+$da);
if( $da <= 180 ) {
// If the slice size is <= 90 it can at maximum cut across
// one boundary (either 90 or 270) where it needs to be split
$split=-1; // no split
if( ($da<=90 && ($a <= 90 && $ne > 90)) ||
(($da <= 180 && $da >90) && (($a < 90 || $a >= 270) && $ne > 90)) ) {
$split = 90;
}
elseif( ($da<=90 && ($a <= 270 && $ne > 270)) ||
(($da<=180 && $da>90) && ($a >= 90 && $a < 270 && ($a+$da) > 270 )) ) {
$split = 270;
}
if( $split > 0 ) { // split in two
$angles[$idx] = array($a,$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
$angles[++$idx] = array($split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
else { // no split
$angles[$idx] = array($a,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
}
else {
// da>180
// Slice may, depending on position, cross one or two
// bonudaries
if( $a < 90 )
$split = 90;
elseif( $a <= 270 )
$split = 270;
else
$split = 90;
$angles[$idx] = array($a,$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
//if( $a+$da > 360-$split ) {
// For slices larger than 270 degrees we might cross
// another boundary as well. This means that we must
// split the slice further. The comparison gets a little
// bit complicated since we must take into accound that
// a pie might have a startangle >0 and hence a slice might
// wrap around the 0 angle.
// Three cases:
// a) Slice starts before 90 and hence gets a split=90, but
// we must also check if we need to split at 270
// b) Slice starts after 90 but before 270 and slices
// crosses 90 (after a wrap around of 0)
// c) If start is > 270 (hence the firstr split is at 90)
// and the slice is so large that it goes all the way
// around 270.
if( ($a < 90 && ($a+$da > 270)) ||
($a > 90 && $a<=270 && ($a+$da>360+90) ) ||
($a > 270 && $this->NormAngle($a+$da)>270) ) {
$angles[++$idx] = array($split,360-$split);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
$angles[++$idx] = array(360-$split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
else {
// Just a simple split to the previous decided
// angle.
$angles[++$idx] = array($split,$ne);
$adjcolors[$idx] = $colors[$i % $numcolors];
$adjexplode[$idx] = $explode;
}
}
$a += $da;
$a = $this->NormAngle($a);
}
// Total number of slices
$n = count($angles);
for($i=0; $i<$n; ++$i) {
list($dbgs,$dbge) = $angles[$i];
}
//
// Step 2. Find start index (first pie that starts in upper left quadrant)
//
$minval = $angles[0][0];
$min = 0;
for( $i=0; $i<$n; ++$i ) {
if( $angles[$i][0] < $minval ) {
$minval = $angles[$i][0];
$min = $i;
}
}
$j = $min;
$cnt = 0;
while( $angles[$j][1] <= 90 ) {
$j++;
if( $j>=$n) {
$j=0;
}
if( $cnt > $n ) {
JpGraphError::RaiseL(14005);
//("Pie3D Internal error (#1). Trying to wrap twice when looking for start index");
}
++$cnt;
}
$start = $j;
//
// Step 3. Print slices in z-order
//
$cnt = 0;
// First stroke all the slices between 90 and 270 (left half circle)
// counterclockwise
while( $angles[$j][0] < 270 && $aaoption !== 2 ) {
list($x,$y) = $adjexplode[$j];
$this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1],
$z,$adjcolors[$j],$shadow);
$last = array($x,$y,$j);
$j++;
if( $j >= $n ) $j=0;
if( $cnt > $n ) {
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
++$cnt;
}
$slice_left = $n-$cnt;
$j=$start-1;
if($j<0) $j=$n-1;
$cnt = 0;
// The stroke all slices from 90 to -90 (right half circle)
// clockwise
while( $cnt < $slice_left && $aaoption !== 2 ) {
list($x,$y) = $adjexplode[$j];
$this->Pie3DSlice($img,$x,$y,$d,$h,$angles[$j][0],$angles[$j][1],
$z,$adjcolors[$j],$shadow);
$j--;
if( $cnt > $n ) {
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
if($j<0) $j=$n-1;
$cnt++;
}
// Now do a special thing. Stroke the last slice on the left
// halfcircle one more time. This is needed in the case where
// the slice close to 270 have been exploded. In that case the
// part of the slice close to the center of the pie might be
// slightly nagged.
if( $aaoption !== 2 )
$this->Pie3DSlice($img,$last[0],$last[1],$d,$h,$angles[$last[2]][0],
$angles[$last[2]][1],$z,$adjcolors[$last[2]],$shadow);
if( $aaoption !== 1 ) {
// Now print possible labels and add csim
$this->value->ApplyFont($img);
$margin = $img->GetFontHeight()/2 + $this->value->margin ;
for($i=0; $i < count($data); ++$i ) {
$la = $labeldata[$i][0];
$x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin)*$this->ilabelposadj;
$y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin)*$this->ilabelposadj;
if( $this->ilabelposadj >= 1.0 ) {
if( $la > 180 && $la < 360 ) $y += $z;
}
if( $this->labeltype == 0 ) {
if( $sum > 0 )
$l = 100*$data[$i]/$sum;
else
$l = 0;
}
elseif( $this->labeltype == 1 ) {
$l = $data[$i];
}
else {
$l = $this->adjusted_data[$i];
}
if( isset($this->labels[$i]) && is_string($this->labels[$i]) )
$l=sprintf($this->labels[$i],$l);
$this->StrokeLabels($l,$img,$labeldata[$i][0]*M_PI/180,$x,$y,$z);
$this->Add3DSliceToCSIM($i,$labeldata[$i][1],$labeldata[$i][2],$h*2,$d*2,$z,
$originalangles[$i][0],$originalangles[$i][1]);
}
}
//
// Finally add potential lines in pie
//
if( $edgecolor=="" || $aaoption !== 0 ) return;
$accsum = 0;
$a = $startangle;
$a = $this->NormAngle($a);
$a *= M_PI/180.0;
$idx=0;
$img->PushColor($edgecolor);
$img->SetLineWeight($edgeweight);
$fulledge = true;
for($i=0; $i < count($data) && $fulledge; ++$i ) {
if( empty($this->explode_radius[$i]) )
$this->explode_radius[$i]=0;
if( $this->explode_radius[$i] > 0 ) {
$fulledge = false;
}
}
for($i=0; $i < count($data); ++$i, ++$idx ) {
$da = $data[$i]/$sum * 2*M_PI;
$this->StrokeFullSliceFrame($img,$xc,$yc,$a,$a+$da,$d,$h,$z,$edgecolor,
$this->explode_radius[$i],$fulledge);
$a += $da;
}
$img->PopColor();
}
function StrokeFullSliceFrame($img,$xc,$yc,$sa,$ea,$w,$h,$z,$edgecolor,$exploderadius,$fulledge) {
$step = 0.02;
if( $exploderadius > 0 ) {
$la = ($sa+$ea)/2;
$xc += $exploderadius*cos($la);
$yc -= $exploderadius*sin($la) * ($h/$w) ;
}
$p = array($xc,$yc,$xc+$w*cos($sa),$yc-$h*sin($sa));
for($a=$sa; $a < $ea; $a += $step ) {
$p[] = $xc + $w*cos($a);
$p[] = $yc - $h*sin($a);
}
$p[] = $xc+$w*cos($ea);
$p[] = $yc-$h*sin($ea);
$p[] = $xc;
$p[] = $yc;
$img->SetColor($edgecolor);
$img->Polygon($p);
// Unfortunately we can't really draw the full edge around the whole of
// of the slice if any of the slices are exploded. The reason is that
// this algorithm is to simply. There are cases where the edges will
// "overwrite" other slices when they have been exploded.
// Doing the full, proper 3D hidden lines stiff is actually quite
// tricky. So for exploded pies we only draw the top edge. Not perfect
// but the "real" solution is much more complicated.
if( $fulledge && !( $sa > 0 && $sa < M_PI && $ea < M_PI) ) {
if($sa < M_PI && $ea > M_PI)
$sa = M_PI;
if($sa < 2*M_PI && (($ea >= 2*M_PI) || ($ea > 0 && $ea < $sa ) ) )
$ea = 2*M_PI;
if( $sa >= M_PI && $ea <= 2*M_PI ) {
$p = array($xc + $w*cos($sa),$yc - $h*sin($sa),
$xc + $w*cos($sa),$z + $yc - $h*sin($sa));
for($a=$sa+$step; $a < $ea; $a += $step ) {
$p[] = $xc + $w*cos($a);
$p[] = $z + $yc - $h*sin($a);
}
$p[] = $xc + $w*cos($ea);
$p[] = $z + $yc - $h*sin($ea);
$p[] = $xc + $w*cos($ea);
$p[] = $yc - $h*sin($ea);
$img->SetColor($edgecolor);
$img->Polygon($p);
}
}
}
function Stroke($img,$aaoption=0) {
$n = count($this->data);
// If user hasn't set the colors use the theme array
if( $this->setslicecolors==null ) {
$colors = array_keys($img->rgb->rgb_table);
sort($colors);
$idx_a=$this->themearr[$this->theme];
$ca = array();
$m = count($idx_a);
for($i=0; $i < $m; ++$i)
$ca[$i] = $colors[$idx_a[$i]];
$ca = array_reverse(array_slice($ca,0,$n));
}
else {
$ca = $this->setslicecolors;
}
if( $this->posx <= 1 && $this->posx > 0 )
$xc = round($this->posx*$img->width);
else
$xc = $this->posx ;
if( $this->posy <= 1 && $this->posy > 0 )
$yc = round($this->posy*$img->height);
else
$yc = $this->posy ;
if( $this->radius <= 1 ) {
$width = floor($this->radius*min($img->width,$img->height));
// Make sure that the pie doesn't overflow the image border
// The 0.9 factor is simply an extra margin to leave some space
// between the pie an the border of the image.
$width = min($width,min($xc*0.9,($yc*90/$this->angle-$width/4)*0.9));
}
else {
$width = $this->radius * ($aaoption === 1 ? 2 : 1 ) ;
}
// Add a sanity check for width
if( $width < 1 ) {
JpGraphError::RaiseL(14007);//("Width for 3D Pie is 0. Specify a size > 0");
}
// Establish a thickness. By default the thickness is a fifth of the
// pie slice width (=pie radius) but since the perspective depends
// on the inclination angle we use some heuristics to make the edge
// slightly thicker the less the angle.
// Has user specified an absolute thickness? In that case use
// that instead
if( $this->iThickness ) {
$thick = $this->iThickness;
$thick *= ($aaoption === 1 ? 2 : 1 );
}
else
$thick = $width/12;
$a = $this->angle;
if( $a <= 30 ) $thick *= 1.6;
elseif( $a <= 40 ) $thick *= 1.4;
elseif( $a <= 50 ) $thick *= 1.2;
elseif( $a <= 60 ) $thick *= 1.0;
elseif( $a <= 70 ) $thick *= 0.8;
elseif( $a <= 80 ) $thick *= 0.7;
else $thick *= 0.6;
$thick = floor($thick);
if( $this->explode_all )
for($i=0; $i < $n; ++$i)
$this->explode_radius[$i]=$this->explode_r;
$this->Pie3D($aaoption,$img,$this->data, $ca, $xc, $yc, $width, $this->angle,
$thick, 0.65, $this->startangle, $this->edgecolor, $this->edgeweight);
// Adjust title position
if( $aaoption != 1 ) {
$this->title->SetPos($xc,$yc-$this->title->GetFontHeight($img)-$width/2-$this->title->margin, "center","bottom");
$this->title->Stroke($img);
}
}
//---------------
// PRIVATE METHODS
// Position the labels of each slice
function StrokeLabels($label,$img,$a,$xp,$yp,$z) {
$this->value->halign="left";
$this->value->valign="top";
// Position the axis title.
// dx, dy is the offset from the top left corner of the bounding box that sorrounds the text
// that intersects with the extension of the corresponding axis. The code looks a little
// bit messy but this is really the only way of having a reasonable position of the
// axis titles.
$this->value->ApplyFont($img);
$h=$img->GetTextHeight($label);
// For numeric values the format of the display value
// must be taken into account
if( is_numeric($label) ) {
if( $label >= 0 )
$w=$img->GetTextWidth(sprintf($this->value->format,$label));
else
$w=$img->GetTextWidth(sprintf($this->value->negformat,$label));
}
else
$w=$img->GetTextWidth($label);
while( $a > 2*M_PI ) $a -= 2*M_PI;
if( $a>=7*M_PI/4 || $a <= M_PI/4 ) $dx=0;
if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dx=($a-M_PI/4)*2/M_PI;
if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dx=1;
if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dx=(1-($a-M_PI*5/4)*2/M_PI);
if( $a>=7*M_PI/4 ) $dy=(($a-M_PI)-3*M_PI/4)*2/M_PI;
if( $a<=M_PI/4 ) $dy=(1-$a*2/M_PI);
if( $a>=M_PI/4 && $a <= 3*M_PI/4 ) $dy=1;
if( $a>=3*M_PI/4 && $a <= 5*M_PI/4 ) $dy=(1-($a-3*M_PI/4)*2/M_PI);
if( $a>=5*M_PI/4 && $a <= 7*M_PI/4 ) $dy=0;
$x = round($xp-$dx*$w);
$y = round($yp-$dy*$h);
// Mark anchor point for debugging
/*
$img->SetColor('red');
$img->Line($xp-10,$yp,$xp+10,$yp);
$img->Line($xp,$yp-10,$xp,$yp+10);
*/
$oldmargin = $this->value->margin;
$this->value->margin=0;
$this->value->Stroke($img,$label,$x,$y);
$this->value->margin=$oldmargin;
}
} // Class
/* EOF */
?>

View File

@ -0,0 +1,635 @@
<?php
//=======================================================================
// File: JPGRAPH_PLOTBAND.PHP
// Description: PHP4 Graph Plotting library. Extension module.
// Created: 2004-02-18
// Ver: $Id: jpgraph_plotband.php 781 2006-10-08 08:07:47Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
// Constants for types of static bands in plot area
DEFINE("BAND_RDIAG",1); // Right diagonal lines
DEFINE("BAND_LDIAG",2); // Left diagonal lines
DEFINE("BAND_SOLID",3); // Solid one color
DEFINE("BAND_VLINE",4); // Vertical lines
DEFINE("BAND_HLINE",5); // Horizontal lines
DEFINE("BAND_3DPLANE",6); // "3D" Plane
DEFINE("BAND_HVCROSS",7); // Vertical/Hor crosses
DEFINE("BAND_DIAGCROSS",8); // Diagonal crosses
// Utility class to hold coordinates for a rectangle
class Rectangle {
public $x,$y,$w,$h;
public $xe, $ye;
function Rectangle($aX,$aY,$aWidth,$aHeight) {
$this->x=$aX;
$this->y=$aY;
$this->w=$aWidth;
$this->h=$aHeight;
$this->xe=$aX+$aWidth-1;
$this->ye=$aY+$aHeight-1;
}
}
//=====================================================================
// Class RectPattern
// Base class for pattern hierarchi that is used to display patterned
// bands on the graph. Any subclass that doesn't override Stroke()
// must at least implement method DoPattern($aImg) which is responsible
// for drawing the pattern onto the graph.
//=====================================================================
class RectPattern {
protected $color;
protected $weight;
protected $rect=null;
protected $doframe=true;
protected $linespacing; // Line spacing in pixels
protected $iBackgroundColor=-1; // Default is no background fill
function RectPattern($aColor,$aWeight=1) {
$this->color = $aColor;
$this->weight = $aWeight;
}
function SetBackground($aBackgroundColor) {
$this->iBackgroundColor=$aBackgroundColor;
}
function SetPos($aRect) {
$this->rect = $aRect;
}
function ShowFrame($aShow=true) {
$this->doframe=$aShow;
}
function SetDensity($aDens) {
if( $aDens < 1 || $aDens > 100 )
JpGraphError::RaiseL(16001,$aDens);
//(" Desity for pattern must be between 1 and 100. (You tried $aDens)");
// 1% corresponds to linespacing=50
// 100 % corresponds to linespacing 1
$this->linespacing = floor(((100-$aDens)/100.0)*50)+1;
}
function Stroke($aImg) {
if( $this->rect == null )
JpGraphError::RaiseL(16002);
//(" No positions specified for pattern.");
if( !(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor==-1) ) {
$aImg->SetColor($this->iBackgroundColor);
$aImg->FilledRectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye);
}
$aImg->SetColor($this->color);
$aImg->SetLineWeight($this->weight);
// Virtual function implemented by subclass
$this->DoPattern($aImg);
// Frame around the pattern area
if( $this->doframe )
$aImg->Rectangle($this->rect->x,$this->rect->y,$this->rect->xe,$this->rect->ye);
}
}
//=====================================================================
// Class RectPatternSolid
// Implements a solid band
//=====================================================================
class RectPatternSolid extends RectPattern {
function RectPatternSolid($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
}
function DoPattern($aImg) {
$aImg->SetColor($this->color);
$aImg->FilledRectangle($this->rect->x,$this->rect->y,
$this->rect->xe,$this->rect->ye);
}
}
//=====================================================================
// Class RectPatternHor
// Implements horizontal line pattern
//=====================================================================
class RectPatternHor extends RectPattern {
function RectPatternHor($aColor="black",$aWeight=1,$aLineSpacing=7) {
parent::RectPattern($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
function DoPattern($aImg) {
$x0 = $this->rect->x;
$x1 = $this->rect->xe;
$y = $this->rect->y;
while( $y < $this->rect->ye ) {
$aImg->Line($x0,$y,$x1,$y);
$y += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternVert
// Implements vertical line pattern
//=====================================================================
class RectPatternVert extends RectPattern {
function RectPatternVert($aColor="black",$aWeight=1,$aLineSpacing=7) {
parent::RectPattern($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
//--------------------
// Private methods
//
function DoPattern($aImg) {
$x = $this->rect->x;
$y0 = $this->rect->y;
$y1 = $this->rect->ye;
while( $x < $this->rect->xe ) {
$aImg->Line($x,$y0,$x,$y1);
$x += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternRDiag
// Implements right diagonal pattern
//=====================================================================
class RectPatternRDiag extends RectPattern {
function RectPatternRDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {
parent::RectPattern($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
function DoPattern($aImg) {
// --------------------
// | / / / / /|
// |/ / / / / |
// | / / / / |
// --------------------
$xe = $this->rect->xe;
$ye = $this->rect->ye;
$x0 = $this->rect->x + round($this->linespacing/2);
$y0 = $this->rect->y;
$x1 = $this->rect->x;
$y1 = $this->rect->y + round($this->linespacing/2);
while($x0<=$xe && $y1<=$ye) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$y1 += $this->linespacing;
}
if( $xe-$x1 > $ye-$y0 ) {
// Width larger than height
$x1 = $this->rect->x + ($y1-$ye);
$y1 = $ye;
$y0 = $this->rect->y;
while( $x0 <= $xe ) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$x1 += $this->linespacing;
}
$y0=$this->rect->y + ($x0-$xe);
$x0=$xe;
}
else {
// Height larger than width
$diff = $x0-$xe;
$y0 = $diff+$this->rect->y;
$x0 = $xe;
$x1 = $this->rect->x;
while( $y1 <= $ye ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y1 += $this->linespacing;
$y0 += $this->linespacing;
}
$diff = $y1-$ye;
$y1 = $ye;
$x1 = $diff + $this->rect->x;
}
while( $y0 <= $ye ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 += $this->linespacing;
$x1 += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPatternLDiag
// Implements left diagonal pattern
//=====================================================================
class RectPatternLDiag extends RectPattern {
function RectPatternLDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {
$this->linespacing = $aLineSpacing;
parent::RectPattern($aColor,$aWeight);
}
function DoPattern($aImg) {
// --------------------
// |\ \ \ \ \ |
// | \ \ \ \ \|
// | \ \ \ \ |
// |------------------|
$xe = $this->rect->xe;
$ye = $this->rect->ye;
$x0 = $this->rect->x + round($this->linespacing/2);
$y0 = $this->rect->ye;
$x1 = $this->rect->x;
$y1 = $this->rect->ye - round($this->linespacing/2);
while($x0<=$xe && $y1>=$this->rect->y) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$y1 -= $this->linespacing;
}
if( $xe-$x1 > $ye-$this->rect->y ) {
// Width larger than height
$x1 = $this->rect->x + ($this->rect->y-$y1);
$y0=$ye; $y1=$this->rect->y;
while( $x0 <= $xe ) {
$aImg->Line($x0,$y0,$x1,$y1);
$x0 += $this->linespacing;
$x1 += $this->linespacing;
}
$y0=$this->rect->ye - ($x0-$xe);
$x0=$xe;
}
else {
// Height larger than width
$diff = $x0-$xe;
$y0 = $ye-$diff;
$x0 = $xe;
while( $y1 >= $this->rect->y ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 -= $this->linespacing;
$y1 -= $this->linespacing;
}
$diff = $this->rect->y - $y1;
$x1 = $this->rect->x + $diff;
$y1 = $this->rect->y;
}
while( $y0 >= $this->rect->y ) {
$aImg->Line($x0,$y0,$x1,$y1);
$y0 -= $this->linespacing;
$x1 += $this->linespacing;
}
}
}
//=====================================================================
// Class RectPattern3DPlane
// Implements "3D" plane pattern
//=====================================================================
class RectPattern3DPlane extends RectPattern {
private $alpha=50; // Parameter that specifies the distance
// to "simulated" horizon in pixel from the
// top of the band. Specifies how fast the lines
// converge.
function RectPattern3DPlane($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
$this->SetDensity(10); // Slightly larger default
}
function SetHorizon($aHorizon) {
$this->alpha=$aHorizon;
}
function DoPattern($aImg) {
// "Fake" a nice 3D grid-effect.
$x0 = $this->rect->x + $this->rect->w/2;
$y0 = $this->rect->y;
$x1 = $x0;
$y1 = $this->rect->ye;
$x0_right = $x0;
$x1_right = $x1;
// BTW "apa" means monkey in Swedish but is really a shortform for
// "alpha+a" which was the labels I used on paper when I derived the
// geometric to get the 3D perspective right.
// $apa is the height of the bounding rectangle plus the distance to the
// artifical horizon (alpha)
$apa = $this->rect->h + $this->alpha;
// Three cases and three loops
// 1) The endpoint of the line ends on the bottom line
// 2) The endpoint ends on the side
// 3) Horizontal lines
// Endpoint falls on bottom line
$middle=$this->rect->x + $this->rect->w/2;
$dist=$this->linespacing;
$factor=$this->alpha /($apa);
while($x1>$this->rect->x) {
$aImg->Line($x0,$y0,$x1,$y1);
$aImg->Line($x0_right,$y0,$x1_right,$y1);
$x1 = $middle - $dist;
$x0 = $middle - $dist * $factor;
$x1_right = $middle + $dist;
$x0_right = $middle + $dist * $factor;
$dist += $this->linespacing;
}
// Endpoint falls on sides
$dist -= $this->linespacing;
$d=$this->rect->w/2;
$c = $apa - $d*$apa/$dist;
while( $x0>$this->rect->x ) {
$aImg->Line($x0,$y0,$this->rect->x,$this->rect->ye-$c);
$aImg->Line($x0_right,$y0,$this->rect->xe,$this->rect->ye-$c);
$dist += $this->linespacing;
$x0 = $middle - $dist * $factor;
$x1 = $middle - $dist;
$x0_right = $middle + $dist * $factor;
$c = $apa - $d*$apa/$dist;
}
// Horizontal lines
// They need some serious consideration since they are a function
// of perspective depth (alpha) and density (linespacing)
$x0=$this->rect->x;
$x1=$this->rect->xe;
$y=$this->rect->ye;
// The first line is drawn directly. Makes the loop below slightly
// more readable.
$aImg->Line($x0,$y,$x1,$y);
$hls = $this->linespacing;
// A correction factor for vertical "brick" line spacing to account for
// a) the difference in number of pixels hor vs vert
// b) visual apperance to make the first layer of "bricks" look more
// square.
$vls = $this->linespacing*0.6;
$ds = $hls*($apa-$vls)/$apa;
// Get the slope for the "perspective line" going from bottom right
// corner to top left corner of the "first" brick.
// Uncomment the following lines if you want to get a visual understanding
// of what this helpline does. BTW this mimics the way you would get the
// perspective right when drawing on paper.
/*
$x0 = $middle;
$y0 = $this->rect->ye;
$len=floor(($this->rect->ye-$this->rect->y)/$vls);
$x1 = $middle+round($len*$ds);
$y1 = $this->rect->ye-$len*$vls;
$aImg->PushColor("red");
$aImg->Line($x0,$y0,$x1,$y1);
$aImg->PopColor();
*/
$y -= $vls;
$k=($this->rect->ye-($this->rect->ye-$vls))/($middle-($middle-$ds));
$dist = $hls;
while( $y>$this->rect->y ) {
$aImg->Line($this->rect->x,$y,$this->rect->xe,$y);
$adj = $k*$dist/(1+$dist*$k/$apa);
if( $adj < 2 ) $adj=1;
$y = $this->rect->ye - round($adj);
$dist += $hls;
}
}
}
//=====================================================================
// Class RectPatternCross
// Vert/Hor crosses
//=====================================================================
class RectPatternCross extends RectPattern {
private $vert=null;
private $hor=null;
function RectPatternCross($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
$this->vert = new RectPatternVert($aColor,$aWeight);
$this->hor = new RectPatternHor($aColor,$aWeight);
}
function SetOrder($aDepth) {
$this->vert->SetOrder($aDepth);
$this->hor->SetOrder($aDepth);
}
function SetPos($aRect) {
parent::SetPos($aRect);
$this->vert->SetPos($aRect);
$this->hor->SetPos($aRect);
}
function SetDensity($aDens) {
$this->vert->SetDensity($aDens);
$this->hor->SetDensity($aDens);
}
function DoPattern($aImg) {
$this->vert->DoPattern($aImg);
$this->hor->DoPattern($aImg);
}
}
//=====================================================================
// Class RectPatternDiagCross
// Vert/Hor crosses
//=====================================================================
class RectPatternDiagCross extends RectPattern {
private $left=null;
private $right=null;
function RectPatternDiagCross($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
$this->right = new RectPatternRDiag($aColor,$aWeight);
$this->left = new RectPatternLDiag($aColor,$aWeight);
}
function SetOrder($aDepth) {
$this->left->SetOrder($aDepth);
$this->right->SetOrder($aDepth);
}
function SetPos($aRect) {
parent::SetPos($aRect);
$this->left->SetPos($aRect);
$this->right->SetPos($aRect);
}
function SetDensity($aDens) {
$this->left->SetDensity($aDens);
$this->right->SetDensity($aDens);
}
function DoPattern($aImg) {
$this->left->DoPattern($aImg);
$this->right->DoPattern($aImg);
}
}
//=====================================================================
// Class RectPatternFactory
// Factory class for rectangular pattern
//=====================================================================
class RectPatternFactory {
function RectPatternFactory() {
// Empty
}
function Create($aPattern,$aColor,$aWeight=1) {
switch($aPattern) {
case BAND_RDIAG:
$obj = new RectPatternRDiag($aColor,$aWeight);
break;
case BAND_LDIAG:
$obj = new RectPatternLDiag($aColor,$aWeight);
break;
case BAND_SOLID:
$obj = new RectPatternSolid($aColor,$aWeight);
break;
case BAND_VLINE:
$obj = new RectPatternVert($aColor,$aWeight);
break;
case BAND_HLINE:
$obj = new RectPatternHor($aColor,$aWeight);
break;
case BAND_3DPLANE:
$obj = new RectPattern3DPlane($aColor,$aWeight);
break;
case BAND_HVCROSS:
$obj = new RectPatternCross($aColor,$aWeight);
break;
case BAND_DIAGCROSS:
$obj = new RectPatternDiagCross($aColor,$aWeight);
break;
default:
JpGraphError::RaiseL(16003,$aPattern);
//(" Unknown pattern specification ($aPattern)");
}
return $obj;
}
}
//=====================================================================
// Class PlotBand
// Factory class which is used by the client.
// It is responsible for factoring the corresponding pattern
// concrete class.
//=====================================================================
class PlotBand {
public $depth; // Determine if band should be over or under the plots
private $prect=null;
private $dir, $min, $max;
function PlotBand($aDir,$aPattern,$aMin,$aMax,$aColor="black",$aWeight=1,$aDepth=DEPTH_BACK) {
$f = new RectPatternFactory();
$this->prect = $f->Create($aPattern,$aColor,$aWeight);
if( is_numeric($aMin) && is_numeric($aMax) && ($aMin > $aMax) )
JpGraphError::RaiseL(16004);
//('Min value for plotband is larger than specified max value. Please correct.');
$this->dir = $aDir;
$this->min = $aMin;
$this->max = $aMax;
$this->depth=$aDepth;
}
// Set position. aRect contains absolute image coordinates
function SetPos($aRect) {
assert( $this->prect != null ) ;
$this->prect->SetPos($aRect);
}
function ShowFrame($aFlag=true) {
$this->prect->ShowFrame($aFlag);
}
// Set z-order. In front of pplot or in the back
function SetOrder($aDepth) {
$this->depth=$aDepth;
}
function SetDensity($aDens) {
$this->prect->SetDensity($aDens);
}
function GetDir() {
return $this->dir;
}
function GetMin() {
return $this->min;
}
function GetMax() {
return $this->max;
}
function PreStrokeAdjust($aGraph) {
// Nothing to do
}
// Display band
function Stroke($aImg,$aXScale,$aYScale) {
assert( $this->prect != null ) ;
if( $this->dir == HORIZONTAL ) {
if( $this->min === 'min' ) $this->min = $aYScale->GetMinVal();
if( $this->max === 'max' ) $this->max = $aYScale->GetMaxVal();
// Only draw the bar if it actually appears in the range
if ($this->min < $aYScale->GetMaxVal() && $this->max > $aYScale->GetMinVal()) {
// Trucate to limit of axis
$this->min = max($this->min, $aYScale->GetMinVal());
$this->max = min($this->max, $aYScale->GetMaxVal());
$x=$aXScale->scale_abs[0];
$y=$aYScale->Translate($this->max);
$width=$aXScale->scale_abs[1]-$aXScale->scale_abs[0]+1;
$height=abs($y-$aYScale->Translate($this->min))+1;
$this->prect->SetPos(new Rectangle($x,$y,$width,$height));
$this->prect->Stroke($aImg);
}
}
else { // VERTICAL
if( $this->min === 'min' ) $this->min = $aXScale->GetMinVal();
if( $this->max === 'max' ) $this->max = $aXScale->GetMaxVal();
// Only draw the bar if it actually appears in the range
if ($this->min < $aXScale->GetMaxVal() && $this->max > $aXScale->GetMinVal()) {
// Trucate to limit of axis
$this->min = max($this->min, $aXScale->GetMinVal());
$this->max = min($this->max, $aXScale->GetMaxVal());
$y=$aYScale->scale_abs[1];
$x=$aXScale->Translate($this->min);
$height=abs($aYScale->scale_abs[1]-$aYScale->scale_abs[0]);
$width=abs($x-$aXScale->Translate($this->max));
$this->prect->SetPos(new Rectangle($x,$y,$width,$height));
$this->prect->Stroke($aImg);
}
}
}
}
?>

View File

@ -0,0 +1,497 @@
<?php
//=======================================================================
// File: JPGRAPH_PLOTMARK.PHP
// Description: Class file. Handles plotmarks
// Created: 2003-03-21
// Ver: $Id: jpgraph_plotmark.inc.php 956 2007-11-17 13:19:20Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
//===================================================
// CLASS PlotMark
// Description: Handles the plot marks in graphs
//===================================================
class PlotMark {
public $title, $show=true;
public $type,$weight=1;
public $iFormatCallback="", $iFormatCallback2="";
public $fill_color="blue";
public $color="black", $width=4;
private $yvalue,$xvalue='',$csimtarget,$csimwintarget='',$csimalt,$csimareas;
private $markimg='',$iScale=1.0;
private $oldfilename='',$iFileName='';
private $imgdata_balls = null;
private $imgdata_diamonds = null;
private $imgdata_squares = null;
private $imgdata_bevels = null;
private $imgdata_stars = null;
private $imgdata_pushpins = null;
//--------------
// CONSTRUCTOR
function PlotMark() {
$this->title = new Text();
$this->title->Hide();
$this->csimareas = '';
$this->type=-1;
}
//---------------
// PUBLIC METHODS
function SetType($aType,$aFileName='',$aScale=1.0) {
$this->type = $aType;
if( $aType == MARK_IMG && $aFileName=='' ) {
JpGraphError::RaiseL(23003);//('A filename must be specified if you set the mark type to MARK_IMG.');
}
$this->iFileName = $aFileName;
$this->iScale = $aScale;
}
function SetCallback($aFunc) {
$this->iFormatCallback = $aFunc;
}
function SetCallbackYX($aFunc) {
$this->iFormatCallback2 = $aFunc;
}
function GetType() {
return $this->type;
}
function SetColor($aColor) {
$this->color=$aColor;
}
function SetFillColor($aFillColor) {
$this->fill_color = $aFillColor;
}
function SetWeight($aWeight) {
$this->weight = $aWeight;
}
// Synonym for SetWidth()
function SetSize($aWidth) {
$this->width=$aWidth;
}
function SetWidth($aWidth) {
$this->width=$aWidth;
}
function SetDefaultWidth() {
switch( $this->type ) {
case MARK_CIRCLE:
case MARK_FILLEDCIRCLE:
$this->width=4;
break;
default:
$this->width=7;
}
}
function GetWidth() {
return $this->width;
}
function Hide($aHide=true) {
$this->show = !$aHide;
}
function Show($aShow=true) {
$this->show = $aShow;
}
function SetCSIMAltVal($aY,$aX='') {
$this->yvalue=$aY;
$this->xvalue=$aX;
}
function SetCSIMTarget($aTarget,$aWinTarget='') {
$this->csimtarget=$aTarget;
$this->csimwintarget=$aWinTarget;
}
function SetCSIMAlt($aAlt) {
$this->csimalt=$aAlt;
}
function GetCSIMAreas(){
return $this->csimareas;
}
function AddCSIMPoly($aPts) {
$coords = round($aPts[0]).", ".round($aPts[1]);
$n = count($aPts)/2;
for( $i=1; $i < $n; ++$i){
$coords .= ", ".round($aPts[2*$i]).", ".round($aPts[2*$i+1]);
}
$this->csimareas="";
if( !empty($this->csimtarget) ) {
$this->csimareas .= "<area shape=\"poly\" coords=\"$coords\" href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\"";
}
$this->csimareas .= " />\n";
}
}
function AddCSIMCircle($x,$y,$r) {
$x = round($x); $y=round($y); $r=round($r);
$this->csimareas="";
if( !empty($this->csimtarget) ) {
$this->csimareas .= "<area shape=\"circle\" coords=\"$x,$y,$r\" href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
}
function Stroke($img,$x,$y) {
if( !$this->show ) return;
if( $this->iFormatCallback != '' || $this->iFormatCallback2 != '' ) {
if( $this->iFormatCallback != '' ) {
$f = $this->iFormatCallback;
list($width,$color,$fcolor) = call_user_func($f,$this->yvalue);
$filename = $this->iFileName;
$imgscale = $this->iScale;
}
else {
$f = $this->iFormatCallback2;
list($width,$color,$fcolor,$filename,$imgscale) = call_user_func($f,$this->yvalue,$this->xvalue);
if( $filename=="" ) $filename = $this->iFileName;
if( $imgscale=="" ) $imgscale = $this->iScale;
}
if( $width=="" ) $width = $this->width;
if( $color=="" ) $color = $this->color;
if( $fcolor=="" ) $fcolor = $this->fill_color;
}
else {
$fcolor = $this->fill_color;
$color = $this->color;
$width = $this->width;
$filename = $this->iFileName;
$imgscale = $this->iScale;
}
if( $this->type == MARK_IMG ||
($this->type >= MARK_FLAG1 && $this->type <= MARK_FLAG4 ) ||
$this->type >= MARK_IMG_PUSHPIN ) {
// Note: For the builtin images we use the "filename" parameter
// to denote the color
$anchor_x = 0.5;
$anchor_y = 0.5;
switch( $this->type ) {
case MARK_FLAG1:
case MARK_FLAG2:
case MARK_FLAG3:
case MARK_FLAG4:
$this->markimg = FlagCache::GetFlagImgByName($this->type-MARK_FLAG1+1,$filename);
break;
case MARK_IMG :
// Load an image and use that as a marker
// Small optimization, if we have already read an image don't
// waste time reading it again.
if( $this->markimg == '' || !($this->oldfilename === $filename) ) {
$this->markimg = Graph::LoadBkgImage('',$filename);
$this->oldfilename = $filename ;
}
break;
case MARK_IMG_PUSHPIN:
case MARK_IMG_SPUSHPIN:
case MARK_IMG_LPUSHPIN:
if( $this->imgdata_pushpins == null ) {
require_once 'imgdata_pushpins.inc.php';
$this->imgdata_pushpins = new ImgData_PushPins();
}
$this->markimg = $this->imgdata_pushpins->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_pushpins->GetAnchor();
break;
case MARK_IMG_SQUARE:
if( $this->imgdata_squares == null ) {
require_once 'imgdata_squares.inc.php';
$this->imgdata_squares = new ImgData_Squares();
}
$this->markimg = $this->imgdata_squares->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_squares->GetAnchor();
break;
case MARK_IMG_STAR:
if( $this->imgdata_stars == null ) {
require_once 'imgdata_stars.inc.php';
$this->imgdata_stars = new ImgData_Stars();
}
$this->markimg = $this->imgdata_stars->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_stars->GetAnchor();
break;
case MARK_IMG_BEVEL:
if( $this->imgdata_bevels == null ) {
require_once 'imgdata_bevels.inc.php';
$this->imgdata_bevels = new ImgData_Bevels();
}
$this->markimg = $this->imgdata_bevels->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_bevels->GetAnchor();
break;
case MARK_IMG_DIAMOND:
if( $this->imgdata_diamonds == null ) {
require_once 'imgdata_diamonds.inc.php';
$this->imgdata_diamonds = new ImgData_Diamonds();
}
$this->markimg = $this->imgdata_diamonds->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_diamonds->GetAnchor();
break;
case MARK_IMG_BALL:
case MARK_IMG_SBALL:
case MARK_IMG_MBALL:
case MARK_IMG_LBALL:
if( $this->imgdata_balls == null ) {
require_once 'imgdata_balls.inc.php';
$this->imgdata_balls = new ImgData_Balls();
}
$this->markimg = $this->imgdata_balls->GetImg($this->type,$filename);
list($anchor_x,$anchor_y) = $this->imgdata_balls->GetAnchor();
break;
}
$w = $img->GetWidth($this->markimg);
$h = $img->GetHeight($this->markimg);
$dw = round($imgscale * $w );
$dh = round($imgscale * $h );
// Do potential rotation
list($x,$y) = $img->Rotate($x,$y);
$dx = round($x-$dw*$anchor_x);
$dy = round($y-$dh*$anchor_y);
$this->width = max($dx,$dy);
$img->Copy($this->markimg,$dx,$dy,0,0,$dw,$dh,$w,$h);
if( !empty($this->csimtarget) ) {
$this->csimareas = "<area shape=\"rect\" coords=\"".
$dx.','.$dy.','.round($dx+$dw).','.round($dy+$dh).'" '.
"href=\"".htmlentities($this->csimtarget)."\"";
if( !empty($this->csimwintarget) ) {
$this->csimareas .= " target=\"".$this->csimwintarget."\" ";
}
if( !empty($this->csimalt) ) {
$tmp=sprintf($this->csimalt,$this->yvalue,$this->xvalue);
$this->csimareas .= " title=\"$tmp\" alt=\"$tmp\" ";
}
$this->csimareas .= " />\n";
}
// Stroke title
$this->title->Align("center","top");
$this->title->Stroke($img,$x,$y+round($dh/2));
return;
}
$weight = $this->weight;
$dx=round($width/2,0);
$dy=round($width/2,0);
$pts=0;
switch( $this->type ) {
case MARK_SQUARE:
$c[]=$x-$dx;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y-$dy;
$pts=5;
break;
case MARK_UTRIANGLE:
++$dx;++$dy;
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$c[]=$x;$c[]=$y-0.87*$dy;
$c[]=$x+$dx;$c[]=$y+0.87*$dy;
$c[]=$x-$dx;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$pts=4;
break;
case MARK_DTRIANGLE:
++$dx;++$dy;
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$c[]=$x-$dx;$c[]=$y-0.87*$dy;
$c[]=$x+$dx;$c[]=$y-0.87*$dy;
$c[]=$x;$c[]=$y+0.87*$dy; // tan(60)/2*$dx
$pts=4;
break;
case MARK_DIAMOND:
$c[]=$x;$c[]=$y+$dy;
$c[]=$x-$dx;$c[]=$y;
$c[]=$x;$c[]=$y-$dy;
$c[]=$x+$dx;$c[]=$y;
$c[]=$x;$c[]=$y+$dy;
$pts=5;
break;
case MARK_LEFTTRIANGLE:
$c[]=$x;$c[]=$y;
$c[]=$x;$c[]=$y+2*$dy;
$c[]=$x+$dx*2;$c[]=$y;
$c[]=$x;$c[]=$y;
$pts=4;
break;
case MARK_RIGHTTRIANGLE:
$c[]=$x-$dx*2;$c[]=$y;
$c[]=$x;$c[]=$y+2*$dy;
$c[]=$x;$c[]=$y;
$c[]=$x-$dx*2;$c[]=$y;
$pts=4;
break;
case MARK_FLASH:
$dy *= 2;
$c[]=$x+$dx/2; $c[]=$y-$dy;
$c[]=$x-$dx+$dx/2; $c[]=$y+$dy*0.7-$dy;
$c[]=$x+$dx/2; $c[]=$y+$dy*1.3-$dy;
$c[]=$x-$dx+$dx/2; $c[]=$y+2*$dy-$dy;
$img->SetLineWeight($weight);
$img->SetColor($color);
$img->Polygon($c);
$img->SetLineWeight(1);
$this->AddCSIMPoly($c);
break;
}
if( $pts>0 ) {
$this->AddCSIMPoly($c);
$img->SetLineWeight($weight);
$img->SetColor($fcolor);
$img->FilledPolygon($c);
$img->SetColor($color);
$img->Polygon($c);
$img->SetLineWeight(1);
}
elseif( $this->type==MARK_CIRCLE ) {
$img->SetColor($color);
$img->Circle($x,$y,$width);
$this->AddCSIMCircle($x,$y,$width);
}
elseif( $this->type==MARK_FILLEDCIRCLE ) {
$img->SetColor($fcolor);
$img->FilledCircle($x,$y,$width);
$img->SetColor($color);
$img->Circle($x,$y,$width);
$this->AddCSIMCircle($x,$y,$width);
}
elseif( $this->type==MARK_CROSS ) {
// Oversize by a pixel to match the X
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x,$y+$dy+1,$x,$y-$dy-1);
$img->Line($x-$dx-1,$y,$x+$dx+1,$y);
$this->AddCSIMCircle($x,$y,$dx);
}
elseif( $this->type==MARK_X ) {
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy);
$img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy);
$this->AddCSIMCircle($x,$y,$dx+$dy);
}
elseif( $this->type==MARK_STAR ) {
$img->SetColor($color);
$img->SetLineWeight($weight);
$img->Line($x+$dx,$y+$dy,$x-$dx,$y-$dy);
$img->Line($x-$dx,$y+$dy,$x+$dx,$y-$dy);
// Oversize by a pixel to match the X
$img->Line($x,$y+$dy+1,$x,$y-$dy-1);
$img->Line($x-$dx-1,$y,$x+$dx+1,$y);
$this->AddCSIMCircle($x,$y,$dx+$dy);
}
// Stroke title
$this->title->Align("center","center");
$this->title->Stroke($img,$x,$y);
}
} // Class
//========================================================================
// CLASS ImgData
// Description: Base class for all image data classes that contains the
// real image data.
//========================================================================
class ImgData {
protected $name = ''; // Each subclass gives a name
protected $an = array(); // Data array names
protected $colors = array(); // Available colors
protected $index = array(); // Index for colors
protected $maxidx = 0 ; // Max color index
protected $anchor_x=0.5, $anchor_y=0.5 ; // Where is the center of the image
// Create a GD image from the data and return a GD handle
function GetImg($aMark,$aIdx) {
$n = $this->an[$aMark];
if( is_string($aIdx) ) {
if( !in_array($aIdx,$this->colors) ) {
JpGraphError::RaiseL(23001,$this->name,$aIdx);//('This marker "'.($this->name).'" does not exist in color: '.$aIdx);
}
$idx = $this->index[$aIdx];
}
elseif( !is_integer($aIdx) ||
(is_integer($aIdx) && $aIdx > $this->maxidx ) ) {
JpGraphError::RaiseL(23002,$this->name);//('Mark color index too large for marker "'.($this->name).'"');
}
else
$idx = $aIdx ;
return Image::CreateFromString(base64_decode($this->{$n}[$idx][1]));
}
function GetAnchor() {
return array($this->anchor_x,$this->anchor_y);
}
}
// Keep a global flag cache to reduce memory usage
$_gFlagCache=array(
1 => null,
2 => null,
3 => null,
4 => null,
);
// Only supposed to b called as statics
class FlagCache {
static function GetFlagImgByName($aSize,$aName) {
global $_gFlagCache;
require_once('jpgraph_flags.php');
if( $_gFlagCache[$aSize] === null ) {
$_gFlagCache[$aSize] = new FlagImages($aSize);
}
$f = $_gFlagCache[$aSize];
$idx = $f->GetIdxByName($aName,$aFullName);
return $f->GetImgByIdx($idx);
}
}
?>

View File

@ -0,0 +1,339 @@
<?php
//=======================================================================
// File: jpgraph_ttf.inc.php
// Description: Handling of TTF fonts
// Created: 2006-11-19
// Ver: $Id: jpgraph_ttf.inc.php 805 2006-11-28 07:45:54Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
// TTF Font families
DEFINE("FF_COURIER",10);
DEFINE("FF_VERDANA",11);
DEFINE("FF_TIMES",12);
DEFINE("FF_COMIC",14);
DEFINE("FF_ARIAL",15);
DEFINE("FF_GEORGIA",16);
DEFINE("FF_TREBUCHE",17);
// Gnome Vera font
// Available from http://www.gnome.org/fonts/
DEFINE("FF_VERA",18);
DEFINE("FF_VERAMONO",19);
DEFINE("FF_VERASERIF",20);
// Chinese font
DEFINE("FF_SIMSUN",30);
DEFINE("FF_CHINESE",31);
DEFINE("FF_BIG5",31);
// Japanese font
DEFINE("FF_MINCHO",40);
DEFINE("FF_PMINCHO",41);
DEFINE("FF_GOTHIC",42);
DEFINE("FF_PGOTHIC",43);
// Hebrew fonts
DEFINE("FF_DAVID",44);
DEFINE("FF_MIRIAM",45);
DEFINE("FF_AHRON",46);
// Extra fonts
// Download fonts from
// http://www.webfontlist.com
// http://www.webpagepublicity.com/free-fonts.html
DEFINE("FF_SPEEDO",50); // This font is also known as Bauer (Used for gauge fascia)
DEFINE("FF_DIGITAL",51); // Digital readout font
DEFINE("FF_COMPUTER",52); // The classic computer font
DEFINE("FF_CALCULATOR",53); // Triad font
// Limits for fonts
DEFINE("_FIRST_FONT",10);
DEFINE("_LAST_FONT",53);
// TTF Font styles
DEFINE("FS_NORMAL",9001);
DEFINE("FS_BOLD",9002);
DEFINE("FS_ITALIC",9003);
DEFINE("FS_BOLDIT",9004);
DEFINE("FS_BOLDITALIC",9004);
//Definitions for internal font
DEFINE("FF_FONT0",1);
DEFINE("FF_FONT1",2);
DEFINE("FF_FONT2",4);
//=================================================================
// CLASS LanguageConv
// Description:
// Converts various character encoding into proper
// UTF-8 depending on how the library have been configured and
// what font family is being used
//=================================================================
class LanguageConv {
private $g2312 = null ;
function Convert($aTxt,$aFF) {
if( LANGUAGE_GREEK ) {
if( GREEK_FROM_WINDOWS ) {
$unistring = LanguageConv::gr_win2uni($aTxt);
} else {
$unistring = LanguageConv::gr_iso2uni($aTxt);
}
return $unistring;
} elseif( LANGUAGE_CYRILLIC ) {
if( CYRILLIC_FROM_WINDOWS && (!defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'windows-1251')) ) {
$aTxt = convert_cyr_string($aTxt, "w", "k");
}
if( !defined('LANGUAGE_CHARSET') || stristr(LANGUAGE_CHARSET, 'koi8-r') || stristr(LANGUAGE_CHARSET, 'windows-1251')) {
$isostring = convert_cyr_string($aTxt, "k", "i");
$unistring = LanguageConv::iso2uni($isostring);
}
else {
$unistring = $aTxt;
}
return $unistring;
}
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
elseif( $aFF === FF_CHINESE ) {
if( !function_exists('iconv') ) {
JpGraphError::RaiseL(25006);
//('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).');
}
return iconv('BIG5','UTF-8',$aTxt);
}
elseif( ASSUME_EUCJP_ENCODING &&
($aFF == FF_MINCHO || $aFF == FF_GOTHIC || $aFF == FF_PMINCHO || $aFF == FF_PGOTHIC) ) {
if( !function_exists('mb_convert_encoding') ) {
JpGraphError::RaiseL(25127);
}
return mb_convert_encoding($aTxt, 'UTF-8','EUC-JP');
}
elseif( $aFF == FF_DAVID || $aFF == FF_MIRIAM || $aFF == FF_AHRON ) {
return LanguageConv::heb_iso2uni($aTxt);
}
else
return $aTxt;
}
// Translate iso encoding to unicode
public static function iso2uni ($isoline){
$uniline='';
for ($i=0; $i < strlen($isoline); $i++){
$thischar=substr($isoline,$i,1);
$charcode=ord($thischar);
$uniline.=($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;
}
return $uniline;
}
// Translate greek iso encoding to unicode
public static function gr_iso2uni ($isoline) {
$uniline='';
for ($i=0; $i < strlen($isoline); $i++) {
$thischar=substr($isoline,$i,1);
$charcode=ord($thischar);
$uniline.=($charcode>179 && $charcode!=183 && $charcode!=187 && $charcode!=189) ? "&#" . (900+($charcode-180)). ";" : $thischar;
}
return $uniline;
}
// Translate greek win encoding to unicode
public static function gr_win2uni ($winline) {
$uniline='';
for ($i=0; $i < strlen($winline); $i++) {
$thischar=substr($winline,$i,1);
$charcode=ord($thischar);
if ($charcode==161 || $charcode==162) {
$uniline.="&#" . (740+$charcode). ";";
}
else {
$uniline.=(($charcode>183 && $charcode!=187 && $charcode!=189) || $charcode==180) ? "&#" . (900+($charcode-180)). ";" : $thischar;
}
}
return $uniline;
}
public static function heb_iso2uni($isoline) {
$isoline = hebrev($isoline);
$o = '';
$n = strlen($isoline);
for($i=0; $i < $n; $i++) {
$c=ord( substr($isoline,$i,1) );
$o .= ($c > 223) && ($c < 251) ? '&#'.(1264+$c).';' : chr($c);
}
return utf8_encode($o);
}
}
//=============================================================
// CLASS TTF
// Description: Handle TTF font names and mapping and loading of
// font files
//=============================================================
class TTF {
private $font_files,$style_names;
//---------------
// CONSTRUCTOR
function TTF() {
// String names for font styles to be used in error messages
$this->style_names=array(FS_NORMAL =>'normal',
FS_BOLD =>'bold',
FS_ITALIC =>'italic',
FS_BOLDITALIC =>'bolditalic');
// File names for available fonts
$this->font_files=array(
FF_COURIER => array(FS_NORMAL =>'cour.ttf',
FS_BOLD =>'courbd.ttf',
FS_ITALIC =>'couri.ttf',
FS_BOLDITALIC =>'courbi.ttf' ),
FF_GEORGIA => array(FS_NORMAL =>'georgia.ttf',
FS_BOLD =>'georgiab.ttf',
FS_ITALIC =>'georgiai.ttf',
FS_BOLDITALIC =>'' ),
FF_TREBUCHE =>array(FS_NORMAL =>'trebuc.ttf',
FS_BOLD =>'trebucbd.ttf',
FS_ITALIC =>'trebucit.ttf',
FS_BOLDITALIC =>'trebucbi.ttf' ),
FF_VERDANA => array(FS_NORMAL =>'verdana.ttf',
FS_BOLD =>'verdanab.ttf',
FS_ITALIC =>'verdanai.ttf',
FS_BOLDITALIC =>'' ),
FF_TIMES => array(FS_NORMAL =>'times.ttf',
FS_BOLD =>'timesbd.ttf',
FS_ITALIC =>'timesi.ttf',
FS_BOLDITALIC =>'timesbi.ttf' ),
FF_COMIC => array(FS_NORMAL =>'comic.ttf',
FS_BOLD =>'comicbd.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_ARIAL => array(FS_NORMAL =>'arial.ttf',
FS_BOLD =>'arialbd.ttf',
FS_ITALIC =>'ariali.ttf',
FS_BOLDITALIC =>'arialbi.ttf' ) ,
FF_VERA => array(FS_NORMAL =>'Vera.ttf',
FS_BOLD =>'VeraBd.ttf',
FS_ITALIC =>'VeraIt.ttf',
FS_BOLDITALIC =>'VeraBI.ttf' ),
FF_VERAMONO => array(FS_NORMAL =>'VeraMono.ttf',
FS_BOLD =>'VeraMoBd.ttf',
FS_ITALIC =>'VeraMoIt.ttf',
FS_BOLDITALIC =>'VeraMoBI.ttf' ),
FF_VERASERIF=> array(FS_NORMAL =>'VeraSe.ttf',
FS_BOLD =>'VeraSeBd.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ) ,
/* Chinese fonts */
FF_SIMSUN => array(FS_NORMAL =>'simsun.ttc',
FS_BOLD =>'simhei.ttf',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_CHINESE => array(FS_NORMAL =>CHINESE_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Japanese fonts */
FF_MINCHO => array(FS_NORMAL =>MINCHO_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_PMINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_GOTHIC => array(FS_NORMAL =>GOTHIC_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_PGOTHIC => array(FS_NORMAL =>PGOTHIC_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_MINCHO => array(FS_NORMAL =>PMINCHO_TTF_FONT,
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Hebrew fonts */
FF_DAVID => array(FS_NORMAL =>'DAVIDNEW.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_MIRIAM => array(FS_NORMAL =>'MRIAMY.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_AHRON => array(FS_NORMAL =>'ahronbd.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
/* Misc fonts */
FF_DIGITAL => array(FS_NORMAL =>'DIGIRU__.TTF',
FS_BOLD =>'Digirtu_.ttf',
FS_ITALIC =>'Digir___.ttf',
FS_BOLDITALIC =>'DIGIRT__.TTF' ),
FF_SPEEDO => array(FS_NORMAL =>'Speedo.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_COMPUTER => array(FS_NORMAL =>'COMPUTER.TTF',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
FF_CALCULATOR => array(FS_NORMAL =>'Triad_xs.ttf',
FS_BOLD =>'',
FS_ITALIC =>'',
FS_BOLDITALIC =>'' ),
);
}
//---------------
// PUBLIC METHODS
// Create the TTF file from the font specification
function File($family,$style=FS_NORMAL) {
$fam = @$this->font_files[$family];
if( !$fam ) {
JpGraphError::RaiseL(25046,$family);//("Specified TTF font family (id=$family) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/");
}
$f = @$fam[$style];
if( $f==='' )
JpGraphError::RaiseL(25047,$this->style_names[$style],$this->font_files[$family][FS_NORMAL]);//('Style "'.$this->style_names[$style].'" is not available for font family '.$this->font_files[$family][FS_NORMAL].'.');
if( !$f ) {
JpGraphError::RaiseL(25048,$fam);//("Unknown font style specification [$fam].");
}
if ($family >= FF_MINCHO && $family <= FF_PGOTHIC) {
$f = MBTTF_DIR.$f;
} else {
$f = TTF_DIR.$f;
}
if( file_exists($f) === false || is_readable($f) === false ) {
JpGraphError::RaiseL(25049,$f);//("Font file \"$f\" is not readable or does not exist.");
}
return $f;
}
} // Class
?>

View File

@ -0,0 +1,500 @@
<?php
/*=======================================================================
// File: DE.INC.PHP
// Description: German language file for error messages
// Created: 2006-03-06
// Author: Timo Leopold (timo@leopold-hh.de)
// Ver: $Id: de.inc.php 993 2008-03-30 21:17:41Z ljp $
//
// Copyright (c)
//========================================================================
*/
// Notiz: Das Format fuer jede Fehlermeldung ist array(<Fehlermeldung>,<Anzahl der Argumente>)
$_jpg_messages = array(
/*
** Headers wurden bereits gesendet - Fehler. Dies wird als HTML formatiert, weil es direkt als text zurueckgesendet wird
*/
10 => array('<table border="1"><tr><td style="color:darkred;font-size:1.2em;"><b>JpGraph Fehler:</b>
HTTP header wurden bereits gesendet.<br>Fehler in der Datei <b>%s</b> in der Zeile <b>%d</b>.</td></tr><tr><td><b>Erklärung:</b><br>HTTP header wurden bereits zum Browser gesendet, wobei die Daten als Text gekennzeichnet wurden, bevor die Bibliothek die Chance hatte, seinen Bild-HTTP-Header zum Browser zu schicken. Dies verhindert, dass die Bibliothek Bilddaten zum Browser schicken kann (weil sie vom Browser als Text interpretiert würden und daher nur Mist dargestellt würde).<p>Wahrscheinlich steht Text im Skript bevor <i>Graph::Stroke()</i> aufgerufen wird. Wenn dieser Text zum Browser gesendet wird, nimmt dieser an, dass die gesamten Daten aus Text bestehen. Such nach irgendwelchem Text, auch nach Leerzeichen und Zeilenumbrüchen, die eventuell bereits zum Browser gesendet wurden. <p>Zum Beispiel ist ein oft auftretender Fehler, eine Leerzeile am Anfang der Datei oder vor <i>Graph::Stroke()</i> zu lassen."<b>&lt;?php</b>".</td></tr></table>',2),
/*
** Setup Fehler
*/
11 => array('Es wurde kein Pfad für CACHE_DIR angegeben. Bitte gib einen Pfad CACHE_DIR in der Datei jpg-config.inc an.',0),
12 => array('Es wurde kein Pfad für TTF_DIR angegeben und der Pfad kann nicht automatisch ermittelt werden. Bitte gib den Pfad in der Datei jpg-config.inc an.',0),
13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2),
/*
** jpgraph_bar
*/
2001 => array('Die Anzahl der Farben ist nicht gleich der Anzahl der Vorlagen in BarPlot::SetPattern().',0),
2002 => array('Unbekannte Vorlage im Aufruf von BarPlot::SetPattern().',0),
2003 => array('Anzahl der X- und Y-Koordinaten sind nicht identisch. Anzahl der X-Koordinaten: %d; Anzahl der Y-Koordinaten: %d.',2),
2004 => array('Alle Werte für ein Balkendiagramm (barplot) müssen numerisch sein. Du hast den Wert nr [%d] == %s angegeben.',2),
2005 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0),
2006 => array('Unbekannte Position für die Werte der Balken: %s.',1),
2007 => array('Kann GroupBarPlot nicht aus einem leeren Vektor erzeugen.',0),
2008 => array('GroupBarPlot Element nbr %d wurde nicht definiert oder ist leer.',0),
2009 => array('Eins der Objekte, das an GroupBar weitergegeben wurde ist kein Balkendiagramm (BarPlot). Versichere Dich, dass Du den GroupBarPlot aus einem Vektor von Balkendiagrammen (barplot) oder AccBarPlot-Objekten erzeugst. (Class = %s)',1),
2010 => array('Kann AccBarPlot nicht aus einem leeren Vektor erzeugen.',0),
2011 => array('AccBarPlot-Element nbr %d wurde nicht definiert oder ist leer.',1),
2012 => array('Eins der Objekte, das an AccBar weitergegeben wurde ist kein Balkendiagramm (barplot). Versichere Dich, dass Du den AccBar-Plot aus einem Vektor von Balkendiagrammen (barplot) erzeugst. (Class=%s)',1),
2013 => array('Du hast einen leeren Vektor für die Schattierungsfarben im Balkendiagramm (barplot) angegeben.',0),
2014 => array('Die Anzahl der Datenpunkte jeder Datenreihe in AccBarPlot muss gleich sein.',0),
/*
** jpgraph_date
*/
3001 => array('Es ist nur möglich, entweder SetDateAlign() oder SetTimeAlign() zu benutzen, nicht beides!',0),
/*
** jpgraph_error
*/
4002 => array('Fehler bei den Eingabedaten von LineErrorPlot. Die Anzahl der Datenpunkte mus ein Mehrfaches von drei sein!',0),
/*
** jpgraph_flags
*/
5001 => array('Unbekannte Flaggen-Größe (%d).',1),
5002 => array('Der Flaggen-Index %s existiert nicht.',1),
5003 => array('Es wurde eine ungültige Ordnungszahl (%d) für den Flaggen-Index angegeben.',1),
5004 => array('Der Landesname %s hat kein korrespondierendes Flaggenbild. Die Flagge mag existieren, abr eventuell unter einem anderen Namen, z.B. versuche "united states" statt "usa".',1),
/*
** jpgraph_gantt
*/
6001 => array('Interner Fehler. Die Höhe für ActivityTitles ist < 0.',0),
6002 => array('Es dürfen keine negativen Werte für die Gantt-Diagramm-Dimensionen angegeben werden. Verwende 0, wenn die Dimensionen automatisch ermittelt werden sollen.',0),
6003 => array('Ungültiges Format für den Bedingungs-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei index 0 starten und Vektoren in der Form (Row,Constrain-To,Constrain-Type) enthalten.',1),
6004 => array('Ungültiges Format für den Fortschritts-Parameter bei Index=%d in CreateSimple(). Der Parameter muss bei Index 0 starten und Vektoren in der Form (Row,Progress) enthalten.',1),
6005 => array('SetScale() ist nicht sinnvoll bei Gantt-Diagrammen.',0),
6006 => array('Das Gantt-Diagramm kann nicht automatisch skaliert werden. Es existieren keine Aktivitäten mit Termin. [GetBarMinMax() start >= n]',0),
6007 => array('Plausibiltätsprüfung für die automatische Gantt-Diagramm-Größe schlug fehl. Entweder die Breite (=%d) oder die Höhe (=%d) ist größer als MAX_GANTTIMG_SIZE. Dies kann möglicherweise durch einen falschen Wert bei einer Aktivität hervorgerufen worden sein.',2),
6008 => array('Du hast eine Bedingung angegeben von Reihe=%d bis Reihe=%d, die keine Aktivität hat.',2),
6009 => array('Unbekannter Bedingungstyp von Reihe=%d bis Reihe=%d',2),
6010 => array('Ungültiger Icon-Index für das eingebaute Gantt-Icon [%d]',1),
6011 => array('Argument für IconImage muss entweder ein String oder ein Integer sein.',0),
6012 => array('Unbekannter Typ bei der Gantt-Objekt-Title-Definition.',0),
6015 => array('Ungültige vertikale Position %d',1),
6016 => array('Der eingegebene Datums-String (%s) für eine Gantt-Aktivität kann nicht interpretiert werden. Versichere Dich, dass es ein gültiger Datumsstring ist, z.B. 2005-04-23 13:30',1),
6017 => array('Unbekannter Datumstyp in GanttScale (%s).',1),
6018 => array('Intervall für Minuten muss ein gerader Teiler einer Stunde sein, z.B. 1,5,10,12,15,20,30, etc. Du hast ein Intervall von %d Minuten angegeben.',1),
6019 => array('Die vorhandene Breite (%d) für die Minuten ist zu klein, um angezeigt zu werden. Bitte benutze die automatische Größenermittlung oder vergrößere die Breite des Diagramms.',1),
6020 => array('Das Intervall für die Stunden muss ein gerader Teiler eines Tages sein, z.B. 0:30, 1:00, 1:30, 4:00, etc. Du hast ein Intervall von %d eingegeben.',1),
6021 => array('Unbekanntes Format für die Woche.',0),
6022 => array('Die Gantt-Skala wurde nicht eingegeben.',0),
6023 => array('Wenn Du sowohl Stunden als auch Minuten anzeigen lassen willst, muss das Stunden-Interval gleich 1 sein (anderenfalls ist es nicht sinnvoll, Minuten anzeigen zu lassen).',0),
6024 => array('Das CSIM-Ziel muss als String angegeben werden. Der Start des Ziels ist: %d',1),
6025 => array('Der CSIM-Alt-Text muss als String angegeben werden. Der Beginn des Alt-Textes ist: %d',1),
6027 => array('Der Fortschrittswert muss im Bereich [0, 1] liegen.',0),
6028 => array('Die eingegebene Höhe (%d) für GanttBar ist nicht im zulässigen Bereich.',1),
6029 => array('Der Offset für die vertikale Linie muss im Bereich [0,1] sein.',0),
6030 => array('Unbekannte Pfeilrichtung für eine Verbindung.',0),
6031 => array('Unbekannter Pfeiltyp für eine Verbindung.',0),
6032 => array('Interner Fehler: Unbekannter Pfadtyp (=%d) für eine Verbindung.',1),
/*
** jpgraph_gradient
*/
7001 => array('Unbekannter Gradiententyp (=%d).',1),
/*
** jpgraph_iconplot
*/
8001 => array('Der Mix-Wert für das Icon muss zwischen 0 und 100 sein.',0),
8002 => array('Die Ankerposition für Icons muss entweder "top", "bottom", "left", "right" oder "center" sein.',0),
8003 => array('Es ist nicht möglich, gleichzeitig ein Bild und eine Landesflagge für dasselbe Icon zu definieren',0),
8004 => array('Wenn Du Landesflaggen benutzen willst, musst Du die Datei "jpgraph_flags.php" hinzufügen (per include).',0),
/*
** jpgraph_imgtrans
*/
9001 => array('Der Wert für die Bildtransformation ist außerhalb des zulässigen Bereichs. Der verschwindende Punkt am Horizont muss als Wert zwischen 0 und 1 angegeben werden.',0),
/*
** jpgraph_lineplot
*/
10001 => array('Die Methode LinePlot::SetFilled() sollte nicht mehr benutzt werden. Benutze lieber SetFillColor()',0),
10002 => array('Der Plot ist zu kompliziert für FastLineStroke. Benutze lieber den StandardStroke()',0),
10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0),
/*
** jpgraph_log
*/
11001 => array('Deine Daten enthalten nicht-numerische Werte.',0),
11002 => array('Negative Werte können nicht für logarithmische Achsen verwendet werden.',0),
11003 => array('Deine Daten enthalten nicht-numerische Werte.',0),
11004 => array('Skalierungsfehler für die logarithmische Achse. Es gibt ein Problem mit den Daten der Achse. Der größte Wert muss größer sein als Null. Es ist mathematisch nicht möglich, einen Wert gleich Null in der Skala zu haben.',0),
11005 => array('Das Tick-Intervall für die logarithmische Achse ist nicht definiert. Lösche jeden Aufruf von SetTextLabelStart() oder SetTextTickInterval() bei der logarithmischen Achse.',0),
/*
** jpgraph_mgraph
*/
12001 => array("Du benutzt GD 2.x und versuchst ein Nicht-Truecolor-Bild als Hintergrundbild zu benutzen. Um Hintergrundbilder mit GD 2.x zu benutzen, ist es notwendig Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Truetype-Schriften sehr schlecht, wenn man Truetype-Schriften mit Truecolor-Bildern verwendet.",0),
12002 => array('Ungültiger Dateiname für MGraph::SetBackgroundImage() : %s. Die Datei muss eine gültige Dateierweiterung haben (jpg,gif,png), wenn die automatische Typerkennung verwendet wird.',1),
12003 => array('Unbekannte Dateierweiterung (%s) in MGraph::SetBackgroundImage() für Dateiname: %s',2),
12004 => array('Das Bildformat des Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1),
12005 => array('Das Hintergrundbild kann nicht gelesen werden: %s',1),
12006 => array('Es wurden ungültige Größen für Breite oder Höhe beim Erstellen des Bildes angegeben, (Breite=%d, Höhe=%d)',2),
12007 => array('Das Argument für MGraph::Add() ist nicht gültig für GD.',0),
12008 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Bildformate zu unterstützen.',0),
12009 => array('Deine PHP-Installation unterstützt das gewählte Bildformat nicht: %s',1),
12010 => array('Es konnte kein Bild als Datei %s erzeugt werden. Überprüfe, ob Du die entsprechenden Schreibrechte im aktuellen Verzeichnis hast.',1),
12011 => array('Es konnte kein Truecolor-Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0),
12012 => array('Es konnte kein Bild erzeugt werden. Überprüfe, ob Du wirklich die GD2-Bibliothek installiert hast.',0),
/*
** jpgraph_pie3d
*/
14001 => array('Pie3D::ShowBorder(). Missbilligte Funktion. Benutze Pie3D::SetEdge(), um die Ecken der Tortenstücke zu kontrollieren.',0),
14002 => array('PiePlot3D::SetAngle() 3D-Torten-Projektionswinkel muss zwischen 5 und 85 Grad sein.',0),
14003 => array('Interne Festlegung schlug fehl. Pie3D::Pie3DSlice',0),
14004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0),
14005 => array('Pie3D Interner Fehler: Versuch, zweimal zu umhüllen bei der Suche nach dem Startindex.',0,),
14006 => array('Pie3D Interner Fehler: Z-Sortier-Algorithmus für 3D-Tortendiagramme funktioniert nicht einwandfrei (2). Versuch, zweimal zu umhüllen beim Erstellen des Bildes.',0),
14007 => array('Die Breite für das 3D-Tortendiagramm ist 0. Gib eine Breite > 0 an.',0),
/*
** jpgraph_pie
*/
15001 => array('PiePLot::SetTheme() Unbekannter Stil: %s',1),
15002 => array('Argument für PiePlot::ExplodeSlice() muss ein Integer-Wert sein',0),
15003 => array('Argument für PiePlot::Explode() muss ein Vektor mit Integer-Werten sein.',0),
15004 => array('Tortenstück-Startwinkel muss zwischen 0 und 360 Grad sein.',0),
15005 => array('PiePlot::SetFont() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetFont().',0),
15006 => array('PiePlot::SetSize() Radius für Tortendiagramm muss entweder als Bruch [0, 0.5] der Bildgröße oder als Absoluwert in Pixel im Bereich [10, 1000] angegeben werden.',0),
15007 => array('PiePlot::SetFontColor() sollte nicht mehr verwendet werden. Benutze stattdessen PiePlot->value->SetColor()..',0),
15008 => array('PiePlot::SetLabelType() der Typ für Tortendiagramme muss entweder 0 or 1 sein (nicht %d).',1),
15009 => array('Ungültiges Tortendiagramm. Die Summe aller Daten ist Null.',0),
15010 => array('Die Summe aller Daten ist Null.',0),
15011 => array('Um Bildtransformationen benutzen zu können, muss die Datei jpgraph_imgtrans.php eingefügt werden (per include).',0),
/*
** jpgraph_plotband
*/
16001 => array('Die Dichte für das Pattern muss zwischen 1 und 100 sein. (Du hast %f eingegeben)',1),
16002 => array('Es wurde keine Position für das Pattern angegeben.',0),
16003 => array('Unbekannte Pattern-Definition (%d)',0),
16004 => array('Der Mindeswert für das PlotBand ist größer als der Maximalwert. Bitte korrigiere dies!',0),
/*
** jpgraph_polar
*/
17001 => array('PolarPlots müssen eine gerade Anzahl von Datenpunkten haben. Jeder Datenpunkt ist ein Tupel (Winkel, Radius).',0),
17002 => array('Unbekannte Ausrichtung für X-Achsen-Titel. (%s)',1),
//17003 => array('Set90AndMargin() wird für PolarGraph nicht unterstützt.',0),
17004 => array('Unbekannter Achsentyp für PolarGraph. Er muss entweder \'lin\' oder \'log\' sein.',0),
/*
** jpgraph_radar
*/
18001 => array('ClientSideImageMaps werden für RadarPlots nicht unterstützt.',0),
18002 => array('RadarGraph::SupressTickMarks() sollte nicht mehr verwendet werden. Benutze stattdessen HideTickMarks().',0),
18003 => array('Ungültiger Achsentyp für RadarPlot (%s). Er muss entweder \'lin\' oder \'log\' sein.',1),
18004 => array('Die RadarPlot-Größe muss zwischen 0.1 und 1 sein. (Dein Wert=%f)',1),
18005 => array('RadarPlot: nicht unterstützte Tick-Dichte: %d',1),
18006 => array('Minimum Daten %f (RadarPlots sollten nur verwendet werden, wenn alle Datenpunkte einen Wert > 0 haben).',1),
18007 => array('Die Anzahl der Titel entspricht nicht der Anzahl der Datenpunkte.',0),
18008 => array('Jeder RadarPlot muss die gleiche Anzahl von Datenpunkten haben.',0),
/*
** jpgraph_regstat
*/
19001 => array('Spline: Anzahl der X- und Y-Koordinaten muss gleich sein.',0),
19002 => array('Ungültige Dateneingabe für Spline. Zwei oder mehr aufeinanderfolgende X-Werte sind identisch. Jeder eigegebene X-Wert muss unterschiedlich sein, weil vom mathematischen Standpunkt ein Eins-zu-Eins-Mapping vorliegen muss, d.h. jeder X-Wert korrespondiert mit exakt einem Y-Wert.',0),
19003 => array('Bezier: Anzahl der X- und Y-Koordinaten muss gleich sein.',0),
/*
** jpgraph_scatter
*/
20001 => array('Fieldplots müssen die gleiche Anzahl von X und Y Datenpunkten haben.',0),
20002 => array('Bei Fieldplots muss ein Winkel für jeden X und Y Datenpunkt angegeben werden.',0),
20003 => array('Scatterplots müssen die gleiche Anzahl von X- und Y-Datenpunkten haben.',0),
/*
** jpgraph_stock
*/
21001 => array('Die Anzahl der Datenwerte für Stock-Charts müssen ein Mehrfaches von %d Datenpunkten sein.',1),
/*
** jpgraph_plotmark
*/
23001 => array('Der Marker "%s" existiert nicht in der Farbe: %d',2),
23002 => array('Der Farb-Index ist zu hoch für den Marker "%s"',1),
23003 => array('Ein Dateiname muss angegeben werden, wenn Du den Marker-Typ auf MARK_IMG setzt.',0),
/*
** jpgraph_utils
*/
24001 => array('FuncGenerator : Keine Funktion definiert. ',0),
24002 => array('FuncGenerator : Syntax-Fehler in der Funktionsdefinition ',0),
24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0),
/*
** jpgraph
*/
25001 => array('Diese PHP-Installation ist nicht mit der GD-Bibliothek kompiliert. Bitte kompiliere PHP mit GD-Unterstützung neu, damit JpGraph funktioniert. (Weder die Funktion imagetypes() noch imagecreatefromstring() existiert!)',0),
25002 => array('Diese PHP-Installation scheint nicht die benötigte GD-Bibliothek zu unterstützen. Bitte schau in der PHP-Dokumentation nach, wie man die GD-Bibliothek installiert und aktiviert.',0),
25003 => array('Genereller PHP Fehler : Bei %s:%d : %s',3),
25004 => array('Genereller PHP Fehler : %s ',1),
25005 => array('PHP_SELF, die PHP-Global-Variable kann nicht ermittelt werden. PHP kann nicht von der Kommandozeile gestartet werden, wenn der Cache oder die Bilddateien automatisch benannt werden sollen.',0),
25006 => array('Die Benutzung der FF_CHINESE (FF_BIG5) Schriftfamilie benötigt die iconv() Funktion in Deiner PHP-Konfiguration. Dies wird nicht defaultmäßig in PHP kompiliert (benötigt "--width-iconv" bei der Konfiguration).',0),
25007 => array('Du versuchst das lokale (%s) zu verwenden, was von Deiner PHP-Installation nicht unterstützt wird. Hinweis: Benutze \'\', um das defaultmäßige Lokale für diese geographische Region festzulegen.',1),
25008 => array('Die Bild-Breite und Höhe in Graph::Graph() müssen numerisch sein',0),
25009 => array('Die Skalierung der Achsen muss angegeben werden mit Graph::SetScale()',0),
25010 => array('Graph::Add() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25011 => array('Graph::AddY2() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25012 => array('Graph::AddYN() Du hast versucht, einen leeren Plot zum Graph hinzuzufügen.',0),
25013 => array('Es können nur Standard-Plots zu multiplen Y-Achsen hinzugefügt werden',0),
25014 => array('Graph::AddText() Du hast versucht, einen leeren Text zum Graph hinzuzufügen.',0),
25015 => array('Graph::AddLine() Du hast versucht, eine leere Linie zum Graph hinzuzufügen.',0),
25016 => array('Graph::AddBand() Du hast versucht, ein leeres Band zum Graph hinzuzufügen.',0),
25017 => array('Du benutzt GD 2.x und versuchst, ein Hintergrundbild in einem Truecolor-Bild zu verwenden. Um Hintergrundbilder mit GD 2.x zu verwenden, ist es notwendig, Truecolor zu aktivieren, indem die USE_TRUECOLOR-Konstante auf TRUE gesetzt wird. Wegen eines Bugs in GD 2.0.1 ist die Qualität der Schrift sehr schlecht, wenn Truetype-Schrift in Truecolor-Bildern verwendet werden.',0),
25018 => array('Falscher Dateiname für Graph::SetBackgroundImage() : "%s" muss eine gültige Dateinamenerweiterung (jpg,gif,png) haben, wenn die automatische Dateityperkennung verwenndet werden soll.',1),
25019 => array('Unbekannte Dateinamenerweiterung (%s) in Graph::SetBackgroundImage() für Dateiname: "%s"',2),
25020 => array('Graph::SetScale(): Dar Maximalwert muss größer sein als der Mindestwert.',0),
25021 => array('Unbekannte Achsendefinition für die Y-Achse. (%s)',1),
25022 => array('Unbekannte Achsendefinition für die X-Achse. (%s)',1),
25023 => array('Nicht unterstützter Y2-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1),
25024 => array('Nicht unterstützter X-Achsentyp: "%s" muss einer von (lin,log,int) sein.',1),
25025 => array('Nicht unterstützte Tick-Dichte: %d',1),
25026 => array('Nicht unterstützter Typ der nicht angegebenen Y-Achse. Du hast entweder: 1. einen Y-Achsentyp für automatisches Skalieren definiert, aber keine Plots angegeben. 2. eine Achse direkt definiert, aber vergessen, die Tick-Dichte zu festzulegen.',0),
25027 => array('Kann cached CSIM "%s" zum Lesen nicht öffnen.',1),
25028 => array('Apache/PHP hat keine Schreibrechte, in das CSIM-Cache-Verzeichnis (%s) zu schreiben. Überprüfe die Rechte.',1),
25029 => array('Kann nicht in das CSIM "%s" schreiben. Überprüfe die Schreibrechte und den freien Speicherplatz.',1),
25030 => array('Fehlender Skriptname für StrokeCSIM(). Der Name des aktuellen Skriptes muss als erster Parameter von StrokeCSIM() angegeben werden.',0),
25031 => array('Der Achsentyp muss mittels Graph::SetScale() angegeben werden.',0),
25032 => array('Es existieren keine Plots für die Y-Achse nbr:%d',1),
25033 => array('',0),
25034 => array('Undefinierte X-Achse kann nicht gezeichnet werden. Es wurden keine Plots definiert.',0),
25035 => array('Du hast Clipping aktiviert. Clipping wird nur für Diagramme mit 0 oder 90 Grad Rotation unterstützt. Bitte verändere Deinen Rotationswinkel (=%d Grad) dementsprechend oder deaktiviere Clipping.',1),
25036 => array('Unbekannter Achsentyp AxisStyle() : %s',1),
25037 => array('Das Bildformat Deines Hintergrundbildes (%s) wird von Deiner System-Konfiguration nicht unterstützt. ',1),
25038 => array('Das Hintergrundbild scheint von einem anderen Typ (unterschiedliche Dateierweiterung) zu sein als der angegebene Typ. Angegebenen: %s; Datei: %s',2),
25039 => array('Hintergrundbild kann nicht gelesen werden: "%s"',1),
25040 => array('Es ist nicht möglich, sowohl ein Hintergrundbild als auch eine Hintergrund-Landesflagge anzugeben.',0),
25041 => array('Um Landesflaggen als Hintergrund benutzen zu können, muss die Datei "jpgraph_flags.php" eingefügt werden (per include).',0),
25042 => array('Unbekanntes Hintergrundbild-Layout',0),
25043 => array('Unbekannter Titelhintergrund-Stil.',0),
25044 => array('Automatisches Skalieren kann nicht verwendet werden, weil es unmöglich ist, einen gültigen min/max Wert für die Y-Achse zu ermitteln (nur Null-Werte).',0),
25045 => array('Die Schriftfamilien FF_HANDWRT und FF_BOOK sind wegen Copyright-Problemen nicht mehr verfügbar. Diese Schriften können nicht mehr mit JpGraph verteilt werden. Bitte lade Dir Schriften von http://corefonts.sourceforge.net/ herunter.',0),
25046 => array('Angegebene TTF-Schriftfamilie (id=%d) ist unbekannt oder existiert nicht. Bitte merke Dir, dass TTF-Schriften wegen Copyright-Problemen nicht mit JpGraph mitgeliefert werden. Du findest MS-TTF-Internetschriften (arial, courier, etc.) zum Herunterladen unter http://corefonts.sourceforge.net/',1),
25047 => array('Stil %s ist nicht verfügbar für Schriftfamilie %s',2),
25048 => array('Unbekannte Schriftstildefinition [%s].',1),
25049 => array('Schriftdatei "%s" ist nicht lesbar oder existiert nicht.',1),
25050 => array('Erstes Argument für Text::Text() muss ein String sein.',0),
25051 => array('Ungültige Richtung angegeben für Text.',0),
25052 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte vertikale Ausrichtung für Text.',0),
25053 => array('PANIK: Interner Fehler in SuperScript::Stroke(). Unbekannte horizontale Ausrichtung für Text.',0),
25054 => array('Interner Fehler: Unbekannte Grid-Achse %s',1),
25055 => array('Axis::SetTickDirection() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetTickSide().',0),
25056 => array('SetTickLabelMargin() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelMargin().',0),
25057 => array('SetTextTicks() sollte nicht mehr verwendet werden. Benutze stattdessen SetTextTickInterval().',0),
25058 => array('TextLabelIntevall >= 1 muss angegeben werden.',0),
25059 => array('SetLabelPos() sollte nicht mehr verwendet werden. Benutze stattdessen Axis::SetLabelSide().',0),
25060 => array('Unbekannte Ausrichtung angegeben für X-Achsentitel (%s).',1),
25061 => array('Unbekannte Ausrichtung angegeben für Y-Achsentitel (%s).',1),
25062 => array('Label unter einem Winkel werden für die Y-Achse nicht unterstützt.',0),
25063 => array('Ticks::SetPrecision() sollte nicht mehr verwendet werden. Benutze stattdessen Ticks::SetLabelFormat() (oder Ticks::SetFormatCallback()).',0),
25064 => array('Kleinere oder größere Schrittgröße ist 0. Überprüfe, ob Du fälschlicherweise SetTextTicks(0) in Deinem Skript hast. Wenn dies nicht der Fall ist, bist Du eventuell über einen Bug in JpGraph gestolpert. Bitte sende einen Report und füge den Code an, der den Fehler verursacht hat.',0),
25065 => array('Tick-Positionen müssen als array() angegeben werden',0),
25066 => array('Wenn die Tick-Positionen und -Label von Hand eingegeben werden, muss die Anzahl der Ticks und der Label gleich sein.',0),
25067 => array('Deine von Hand eingegebene Achse und Ticks sind nicht korrekt. Die Skala scheint zu klein zu sein für den Tickabstand.',0),
25068 => array('Ein Plot hat eine ungültige Achse. Dies kann beispielsweise der Fall sein, wenn Du automatisches Text-Skalieren verwendest, um ein Liniendiagramm zu zeichnen mit nur einem Datenpunkt, oder wenn die Bildfläche zu klein ist. Es kann auch der Fall sein, dass kein Datenpunkt einen numerischen Wert hat (vielleicht nur \'-\' oder \'x\').',0),
25069 => array('Grace muss größer sein als 0',0),
25070 => array('Deine Daten enthalten nicht-numerische Werte.',0),
25071 => array('Du hast mit SetAutoMin() einen Mindestwert angegeben, der größer ist als der Maximalwert für die Achse. Dies ist nicht möglich.',0),
25072 => array('Du hast mit SetAutoMax() einen Maximalwert angegeben, der kleiner ist als der Minimalwert der Achse. Dies ist nicht möglich.',0),
25073 => array('Interner Fehler. Der Integer-Skalierungs-Algorithmus-Vergleich ist außerhalb der Grenzen (r=%f).',1),
25074 => array('Interner Fehler. Der Skalierungsbereich ist negativ (%f) [für %s Achse]. Dieses Problem könnte verursacht werden durch den Versuch, \'ungültige\' Werte in die Daten-Vektoren einzugeben (z.B. nur String- oder NULL-Werte), was beim automatischen Skalieren einen Fehler erzeugt.',2),
25075 => array('Die automatischen Ticks können nicht gesetzt werden, weil min==max.',0),
25077 => array('Einstellfaktor für die Farbe muss größer sein als 0',0),
25078 => array('Unbekannte Farbe: %s',1),
25079 => array('Unbekannte Farbdefinition: %s, Größe=%d',2),
25080 => array('Der Alpha-Parameter für Farben muss zwischen 0.0 und 1.0 liegen.',0),
25081 => array('Das ausgewählte Grafikformat wird entweder nicht unterstützt oder ist unbekannt [%s]',1),
25082 => array('Es wurden ungültige Größen für Breite und Höhe beim Erstellen des Bildes definiert (Breite=%d, Höhe=%d).',2),
25083 => array('Es wurde eine ungültige Größe beim Kopieren des Bildes angegeben. Die Größe für das kopierte Bild wurde auf 1 Pixel oder weniger gesetzt.',0),
25084 => array('Fehler beim Erstellen eines temporären GD-Canvas. Möglicherweise liegt ein Arbeitsspeicherproblem vor.',0),
25085 => array('Ein Bild kann nicht aus dem angegebenen String erzeugt werden. Er ist entweder in einem nicht unterstützen Format oder er represäntiert ein kaputtes Bild.',0),
25086 => array('Du scheinst nur GD 1.x installiert zu haben. Um Alphablending zu aktivieren, ist GD 2.x oder höher notwendig. Bitte installiere GD 2.x oder versichere Dich, dass die Konstante USE_GD2 richtig gesetzt ist. Standardmäßig wird die installierte GD-Version automatisch erkannt. Ganz selten wird GD2 erkannt, obwohl nur GD1 installiert ist. Die Konstante USE_GD2 muss dann zu "false" gesetzt werden.',0),
25087 => array('Diese PHP-Version wurde ohne TTF-Unterstützung konfiguriert. PHP muss mit TTF-Unterstützung neu kompiliert und installiert werden.',0),
25088 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontwidth() ist fehlerhaft.',0),
25089 => array('Die GD-Schriftunterstützung wurde falsch konfiguriert. Der Aufruf von imagefontheight() ist fehlerhaft.',0),
25090 => array('Unbekannte Richtung angegeben im Aufruf von StrokeBoxedText() [%s].',1),
25091 => array('Die interne Schrift untestützt das Schreiben von Text in einem beliebigen Winkel nicht. Benutze stattdessen TTF-Schriften.',0),
25092 => array('Es liegt entweder ein Konfigurationsproblem mit TrueType oder ein Problem beim Lesen der Schriftdatei "%s" vor. Versichere Dich, dass die Datei existiert und Leserechte und -pfad vergeben sind. (wenn \'basedir\' restriction in PHP aktiviert ist, muss die Schriftdatei im Dokumentwurzelverzeichnis abgelegt werden). Möglicherweise ist die FreeType-Bibliothek falsch installiert. Versuche, mindestens zur FreeType-Version 2.1.13 zu aktualisieren und kompiliere GD mit einem korrekten Setup neu, damit die FreeType-Bibliothek gefunden werden kann.',1),
25093 => array('Die Schriftdatei "%s" kann nicht gelesen werden beim Aufruf von Image::GetBBoxTTF. Bitte versichere Dich, dass die Schrift gesetzt wurde, bevor diese Methode aufgerufen wird, und dass die Schrift im TTF-Verzeichnis installiert ist.',1),
25094 => array('Die Textrichtung muss in einem Winkel zwischen 0 und 90 engegeben werden.',0),
25095 => array('Unbekannte Schriftfamilien-Definition. ',0),
25096 => array('Der Farbpalette können keine weiteren Farben zugewiesen werden. Dem Bild wurde bereits die größtmögliche Anzahl von Farben (%d) zugewiesen und die Palette ist voll. Verwende stattdessen ein TrueColor-Bild',0),
25097 => array('Eine Farbe wurde als leerer String im Aufruf von PushColor() angegegeben.',0),
25098 => array('Negativer Farbindex. Unpassender Aufruf von PopColor().',0),
25099 => array('Die Parameter für Helligkeit und Kontrast sind außerhalb des zulässigen Bereichs [-1,1]',0),
25100 => array('Es liegt ein Problem mit der Farbpalette und dem GD-Setup vor. Bitte deaktiviere anti-aliasing oder verwende GD2 mit TrueColor. Wenn die GD2-Bibliothek installiert ist, versichere Dich, dass die Konstante USE_GD2 auf "true" gesetzt und TrueColor aktiviert ist.',0),
25101 => array('Ungültiges numerisches Argument für SetLineStyle(): (%d)',1),
25102 => array('Ungültiges String-Argument für SetLineStyle(): %s',1),
25103 => array('Ungültiges Argument für SetLineStyle %s',1),
25104 => array('Unbekannter Linientyp: %s',1),
25105 => array('Es wurden NULL-Daten für ein gefülltes Polygon angegeben. Sorge dafür, dass keine NULL-Daten angegeben werden.',0),
25106 => array('Image::FillToBorder : es können keine weiteren Farben zugewiesen werden.',0),
25107 => array('In Datei "%s" kann nicht geschrieben werden. Überprüfe die aktuellen Schreibrechte.',1),
25108 => array('Das Bild kann nicht gestreamt werden. Möglicherweise liegt ein Fehler im PHP/GD-Setup vor. Kompiliere PHP neu und verwende die eingebaute GD-Bibliothek, die mit PHP angeboten wird.',0),
25109 => array('Deine PHP- (und GD-lib-) Installation scheint keine bekannten Grafikformate zu unterstützen. Sorge zunächst dafür, dass GD als PHP-Modul kompiliert ist. Wenn Du außerdem JPEG-Bilder verwenden willst, musst Du die JPEG-Bibliothek installieren. Weitere Details sind in der PHP-Dokumentation zu finden.',0),
25110 => array('Dein PHP-Installation unterstützt das gewählte Grafikformat nicht: %s',1),
25111 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1),
25112 => array('Das Datum der gecacheten Datei (%s) liegt in der Zukunft.',1),
25113 => array('Das gecachete Bild %s kann nicht gelöscht werden. Problem mit den Rechten?',1),
25114 => array('PHP hat nicht die erforderlichen Rechte, um in die Cache-Datei %s zu schreiben. Bitte versichere Dich, dass der Benutzer, der PHP anwendet, die entsprechenden Schreibrechte für die Datei hat, wenn Du das Cache-System in JPGraph verwenden willst.',1),
25115 => array('Berechtigung für gecachetes Bild %s kann nicht gesetzt werden. Problem mit den Rechten?',1),
25116 => array('Datei kann nicht aus dem Cache %s geöffnet werden',1),
25117 => array('Gecachetes Bild %s kann nicht zum Lesen geöffnet werden.',1),
25118 => array('Verzeichnis %s kann nicht angelegt werden. Versichere Dich, dass PHP die Schreibrechte in diesem Verzeichnis hat.',1),
25119 => array('Rechte für Datei %s können nicht gesetzt werden. Problem mit den Rechten?',1),
25120 => array('Die Position für die Legende muss als Prozentwert im Bereich 0-1 angegeben werden.',0),
25121 => array('Eine leerer Datenvektor wurde für den Plot eingegeben. Es muss wenigstens ein Datenpunkt vorliegen.',0),
25122 => array('Stroke() muss als Subklasse der Klasse Plot definiert sein.',0),
25123 => array('Du kannst keine Text-X-Achse mit X-Koordinaten verwenden. Benutze stattdessen eine "int" oder "lin" Achse.',0),
25124 => array('Der Eingabedatenvektor mus aufeinanderfolgende Werte von 0 aufwärts beinhalten. Der angegebene Y-Vektor beginnt mit leeren Werten (NULL).',0),
25125 => array('Ungültige Richtung für statische Linie.',0),
25126 => array('Es kann kein TrueColor-Bild erzeugt werden. Überprüfe, ob die GD2-Bibliothek und PHP korrekt aufgesetzt wurden.',0),
25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0),
25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0),
25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0),
/*
**---------------------------------------------------------------------------------------------
** Pro-version strings
**---------------------------------------------------------------------------------------------
*/
/*
** jpgraph_table
*/
27001 => array('GTextTable: Ungültiges Argument für Set(). Das Array-Argument muss 2-- dimensional sein.',0),
27002 => array('GTextTable: Ungültiges Argument für Set()',0),
27003 => array('GTextTable: Falsche Anzahl von Argumenten für GTextTable::SetColor()',0),
27004 => array('GTextTable: Angegebener Zellenbereich, der verschmolzen werden soll, ist ungültig.',0),
27005 => array('GTextTable: Bereits verschmolzene Zellen im Bereich (%d,%d) bis (%d,%d) können nicht ein weiteres Mal verschmolzen werden.',4),
27006 => array('GTextTable: Spalten-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1),
27007 => array('GTextTable: Zeilen-Argument = %d liegt außerhalb der festgelegten Tabellengröße.',1),
27008 => array('GTextTable: Spalten- und Zeilengröße müssen zu den Dimensionen der Tabelle passen.',0),
27009 => array('GTextTable: Die Anzahl der Tabellenspalten oder -zeilen ist 0. Versichere Dich, dass die Methoden Init() oder Set() aufgerufen werden.',0),
27010 => array('GTextTable: Es wurde keine Ausrichtung beim Aufruf von SetAlign() angegeben.',0),
27011 => array('GTextTable: Es wurde eine unbekannte Ausrichtung beim Aufruf von SetAlign() abgegeben. Horizontal=%s, Vertikal=%s',2),
27012 => array('GTextTable: Interner Fehler. Es wurde ein ungültiges Argument festgeleget %s',1),
27013 => array('GTextTable: Das Argument für FormatNumber() muss ein String sein.',0),
27014 => array('GTextTable: Die Tabelle wurde weder mit einem Aufruf von Set() noch von Init() initialisiert.',0),
27015 => array('GTextTable: Der Zellenbildbedingungstyp muss entweder TIMG_WIDTH oder TIMG_HEIGHT sein.',0),
/*
** jpgraph_windrose
*/
22001 => array('Die Gesamtsumme der prozentualen Anteile aller Windrosenarme darf 100%% nicht überschreiten!\n(Aktuell max: %d)',1),
22002 => array('Das Bild ist zu klein für eine Skala. Bitte vergrößere das Bild.',0),
22004 => array('Die Etikettendefinition für Windrosenrichtungen müssen 16 Werte haben (eine für jede Kompassrichtung).',0),
22005 => array('Der Linientyp für radiale Linien muss einer von ("solid","dotted","dashed","longdashed") sein.',0),
22006 => array('Es wurde ein ungültiger Windrosentyp angegeben.',0),
22007 => array('Es wurden zu wenig Werte für die Bereichslegende angegeben.',0),
22008 => array('Interner Fehler: Versuch, eine freie Windrose zu plotten, obwohl der Typ keine freie Windrose ist.',0),
22009 => array('Du hast die gleiche Richtung zweimal angegeben, einmal mit einem Winkel und einmal mit einer Kompassrichtung (%f Grad).',0),
22010 => array('Die Richtung muss entweder ein numerischer Wert sein oder eine der 16 Kompassrichtungen',0),
22011 => array('Der Windrosenindex muss ein numerischer oder Richtungswert sein. Du hast angegeben Index=%d',1),
22012 => array('Die radiale Achsendefinition für die Windrose enthält eine nicht aktivierte Richtung.',0),
22013 => array('Du hast dasselbe Look&Feel für die gleiche Kompassrichtung zweimal engegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1),
22014 => array('Der Index für eine Kompassrichtung muss zwischen 0 und 15 sein.',0),
22015 => array('Du hast einen unbekannten Windrosenplottyp angegeben.',0),
22016 => array('Der Windrosenarmindex muss ein numerischer oder ein Richtungswert sein.',0),
22017 => array('Die Windrosendaten enthalten eine Richtung, die nicht aktiviert ist. Bitte berichtige, welche Label angezeigt werden sollen.',0),
22018 => array('Du hast für dieselbe Kompassrichtung zweimal Daten angegeben, einmal mit Text und einmal mit einem Index (Index=%d)',1),
22019 => array('Der Index für eine Richtung muss zwischen 0 und 15 sein. Winkel dürfen nicht für einen regelmäßigen Windplot angegeben werden, sondern entweder ein Index oder eine Kompassrichtung.',0),
22020 => array('Der Windrosenplot ist zu groß für die angegebene Bildgröße. Benutze entweder WindrosePlot::SetSize(), um den Plot kleiner zu machen oder vergrößere das Bild im ursprünglichen Aufruf von WindroseGraph().',0),
22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0),
/*
** jpgraph_odometer
*/
13001 => array('Unbekannter Nadeltypstil (%d).',1),
13002 => array('Ein Wert für das Odometer (%f) ist außerhalb des angegebenen Bereichs [%f,%f]',3),
/*
** jpgraph_barcode
*/
1001 => array('Unbekannte Kodier-Specifikation: %s',1),
1002 => array('datenvalidierung schlug fehl. [%s] kann nicht mittels der Kodierung "%s" kodiert werden',2),
1003 => array('Interner Kodierfehler. Kodieren von %s ist nicht möglich in Code 128',1),
1004 => array('Interner barcode Fehler. Unbekannter UPC-E Kodiertyp: %s',1),
1005 => array('Interner Fehler. Das Textzeichen-Tupel (%s, %s) kann nicht im Code-128 Zeichensatz C kodiert werden.',2),
1006 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, CTRL in CHARSET != A zu kodieren.',0),
1007 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, DEL in CHARSET != B zu kodieren.',0),
1008 => array('Interner Kodierfehler für CODE 128. Es wurde versucht, kleine Buchstaben in CHARSET != B zu kodieren.',0),
1009 => array('Kodieren mittels CODE 93 wird noch nicht unterstützt.',0),
1010 => array('Kodieren mittels POSTNET wird noch nicht unterstützt.',0),
1011 => array('Nicht untrstütztes Barcode-Backend für den Typ %s',1),
/*
** PDF417
*/
26001 => array('PDF417: Die Anzahl der Spalten muss zwischen 1 und 30 sein.',0),
26002 => array('PDF417: Der Fehler-Level muss zwischen 0 und 8 sein.',0),
26003 => array('PDF417: Ungültiges Format für Eingabedaten, um sie mit PDF417 zu kodieren.',0),
26004 => array('PDF417: die eigebenen Daten können nicht mit Fehler-Level %d und %d spalten kodiert werden, weil daraus zu viele Symbole oder mehr als 90 Zeilen resultieren.',2),
26005 => array('PDF417: Die Datei "%s" kann nicht zum Schreiben geöffnet werden.',1),
26006 => array('PDF417: Interner Fehler. Die Eingabedatendatei für PDF417-Cluster %d ist fehlerhaft.',1),
26007 => array('PDF417: Interner Fehler. GetPattern: Ungültiger Code-Wert %d (Zeile %d)',2),
26008 => array('PDF417: Interner Fehler. Modus wurde nicht in der Modusliste!! Modus %d',1),
26009 => array('PDF417: Kodierfehler: Ungültiges Zeichen. Zeichen kann nicht mit ASCII-Code %d kodiert werden.',1),
26010 => array('PDF417: Interner Fehler: Keine Eingabedaten beim Dekodieren.',0),
26011 => array('PDF417: Kodierfehler. Numerisches Kodieren bei nicht-numerischen Daten nicht möglich.',0),
26012 => array('PDF417: Interner Fehler. Es wurden für den Binary-Kompressor keine Daten zum Dekodieren eingegeben.',0),
26013 => array('PDF417: Interner Fehler. Checksum Fehler. Koeffiziententabellen sind fehlerhaft.',0),
26014 => array('PDF417: Interner Fehler. Es wurden keine Daten zum Berechnen von Kodewörtern eingegeben.',0),
26015 => array('PDF417: Interner Fehler. Ein Eintrag 0 in die Statusübertragungstabellen ist nicht NULL. Eintrag 1 = (%s)',1),
26016 => array('PDF417: Interner Fehler: Nichtregistrierter Statusübertragungsmodus beim Dekodieren.',0),
);
?>

View File

@ -0,0 +1,500 @@
<?php
/*=======================================================================
// File: EN.INC.PHP
// Description: English language file for error messages
// Created: 2006-01-25
// Ver: $Id: en.inc.php 993 2008-03-30 21:17:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// Note: Format of each error message is array(<error message>,<number of arguments>)
$_jpg_messages = array(
/*
** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text
*/
10 => array('<table border="1"><tr><td style="color:darkred; font-size:1.2em;"><b>JpGraph Error:</b>
HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b>&lt;?php</b>".</td></tr></table>',2),
/*
** Setup errors
*/
11 => array('No path specified for CACHE_DIR. Please specify CACHE_DIR manually in jpg-config.inc',0),
12 => array('No path specified for TTF_DIR and path can not be determined automatically. Please specify TTF_DIR manually (in jpg-config.inc).',0),
13 => array('The installed PHP version (%s) is not compatible with this release of the library. The library requires at least PHP version %s',2),
/*
** jpgraph_bar
*/
2001 => array('Number of colors is not the same as the number of patterns in BarPlot::SetPattern()',0),
2002 => array('Unknown pattern specified in call to BarPlot::SetPattern()',0),
2003 => array('Number of X and Y points are not equal. Number of X-points: %d Number of Y-points: %d',2),
2004 => array('All values for a barplot must be numeric. You have specified value nr [%d] == %s',2),
2005 => array('You have specified an empty array for shadow colors in the bar plot.',0),
2006 => array('Unknown position for values on bars : %s',1),
2007 => array('Cannot create GroupBarPlot from empty plot array.',0),
2008 => array('Group bar plot element nbr %d is undefined or empty.',0),
2009 => array('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the GroupBar plot from an array of BarPlot or AccBarPlot objects. (Class = %s)',1),
2010 => array('Cannot create AccBarPlot from empty plot array.',0),
2011 => array('Acc bar plot element nbr %d is undefined or empty.',1),
2012 => array('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects. (Class=%s)',1),
2013 => array('You have specified an empty array for shadow colors in the bar plot.',0),
2014 => array('Number of datapoints for each data set in accbarplot must be the same',0),
/*
** jpgraph_date
*/
3001 => array('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both',0),
/*
** jpgraph_error
*/
4002 => array('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3',0),
/*
** jpgraph_flags
*/
5001 => array('Unknown flag size (%d).',1),
5002 => array('Flag index %s does not exist.',1),
5003 => array('Invalid ordinal number (%d) specified for flag index.',1),
5004 => array('The (partial) country name %s does not have a corresponding flag image. The flag may still exist but under another name, e.g. instead of "usa" try "united states".',1),
/*
** jpgraph_gantt
*/
6001 => array('Internal error. Height for ActivityTitles is < 0',0),
6002 => array('You can\'t specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.',0),
6003 => array('Invalid format for Constrain parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)',1),
6004 => array('Invalid format for Progress parameter at index=%d in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)',1),
6005 => array('SetScale() is not meaningful with Gantt charts.',0),
6006 => array('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]',0),
6007 => array('Sanity check for automatic Gantt chart size failed. Either the width (=%d) or height (=%d) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.',2),
6008 => array('You have specified a constrain from row=%d to row=%d which does not have any activity',2),
6009 => array('Unknown constrain type specified from row=%d to row=%d',2),
6010 => array('Illegal icon index for Gantt builtin icon [%d]',1),
6011 => array('Argument to IconImage must be string or integer',0),
6012 => array('Unknown type in Gantt object title specification',0),
6015 => array('Illegal vertical position %d',1),
6016 => array('Date string (%s) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30',1),
6017 => array('Unknown date format in GanttScale (%s).',1),
6018 => array('Interval for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an interval of %d minutes.',1),
6019 => array('The available width (%d) for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.',1),
6020 => array('Interval for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an interval of %d',1),
6021 => array('Unknown formatting style for week.',0),
6022 => array('Gantt scale has not been specified.',0),
6023 => array('If you display both hour and minutes the hour interval must be 1 (Otherwise it doesn\'t make sense to display minutes).',0),
6024 => array('CSIM Target must be specified as a string. Start of target is: %d',1),
6025 => array('CSIM Alt text must be specified as a string. Start of alt text is: %d',1),
6027 => array('Progress value must in range [0, 1]',0),
6028 => array('Specified height (%d) for gantt bar is out of range.',1),
6029 => array('Offset for vertical line must be in range [0,1]',0),
6030 => array('Unknown arrow direction for link.',0),
6031 => array('Unknown arrow type for link.',0),
6032 => array('Internal error: Unknown path type (=%d) specified for link.',1),
/*
** jpgraph_gradient
*/
7001 => array('Unknown gradient style (=%d).',1),
/*
** jpgraph_iconplot
*/
8001 => array('Mix value for icon must be between 0 and 100.',0),
8002 => array('Anchor position for icons must be one of "top", "bottom", "left", "right" or "center"',0),
8003 => array('It is not possible to specify both an image file and a country flag for the same icon.',0),
8004 => array('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.',0),
/*
** jpgraph_imgtrans
*/
9001 => array('Value for image transformation out of bounds. Vanishing point on horizon must be specified as a value between 0 and 1.',0),
/*
** jpgraph_lineplot
*/
10001 => array('LinePlot::SetFilled() is deprecated. Use SetFillColor()',0),
10002 => array('Plot too complicated for fast line Stroke. Use standard Stroke()',0),
10003 => array('Each plot in an accumulated lineplot must have the same number of data points.',0),
/*
** jpgraph_log
*/
11001 => array('Your data contains non-numeric values.',0),
11002 => array('Negative data values can not be used in a log scale.',0),
11003 => array('Your data contains non-numeric values.',0),
11004 => array('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.',0),
11005 => array('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.',0),
/*
** jpgraph_mgraph
*/
12001 => array("You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.",0),
12002 => array('Incorrect file name for MGraph::SetBackgroundImage() : %s Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1),
12003 => array('Unknown file extension (%s) in MGraph::SetBackgroundImage() for filename: %s',2),
12004 => array('The image format of your background image (%s) is not supported in your system configuration. ',1),
12005 => array('Can\'t read background image: %s',1),
12006 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2),
12007 => array('Argument to MGraph::Add() is not a valid GD image handle.',0),
12008 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats.',0),
12009 => array('Your PHP installation does not support the chosen graphic format: %s',1),
12010 => array('Can\'t create or stream image to file %s Check that PHP has enough permission to write a file to the current directory.',1),
12011 => array('Can\'t create truecolor image. Check that you really have GD2 library installed.',0),
12012 => array('Can\'t create image. Check that you really have GD2 library installed.',0),
/*
** jpgraph_pie3d
*/
14001 => array('Pie3D::ShowBorder() . Deprecated function. Use Pie3D::SetEdge() to control the edges around slices.',0),
14002 => array('PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.',0),
14003 => array('Internal assertion failed. Pie3D::Pie3DSlice',0),
14004 => array('Slice start angle must be between 0 and 360 degrees.',0),
14005 => array('Pie3D Internal error: Trying to wrap twice when looking for start index',0,),
14006 => array('Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.',0),
14007 => array('Width for 3D Pie is 0. Specify a size > 0',0),
/*
** jpgraph_pie
*/
15001 => array('PiePLot::SetTheme() Unknown theme: %s',1),
15002 => array('Argument to PiePlot::ExplodeSlice() must be an integer',0),
15003 => array('Argument to PiePlot::Explode() must be an array with integer distances.',0),
15004 => array('Slice start angle must be between 0 and 360 degrees.',0),
15005 => array('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.',0),
15006 => array('PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]',0),
15007 => array('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.',0),
15008 => array('PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not %d).',1),
15009 => array('Illegal pie plot. Sum of all data is zero for Pie Plot',0),
15010 => array('Sum of all data is 0 for Pie.',0),
15011 => array('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.',0),
/*
** jpgraph_plotband
*/
16001 => array('Density for pattern must be between 1 and 100. (You tried %f)',1),
16002 => array('No positions specified for pattern.',0),
16003 => array('Unknown pattern specification (%d)',0),
16004 => array('Min value for plotband is larger than specified max value. Please correct.',0),
/*
** jpgraph_polar
*/
17001 => array('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).',0),
17002 => array('Unknown alignment specified for X-axis title. (%s)',1),
//17003 => array('Set90AndMargin() is not supported for polar graphs.',0),
17004 => array('Unknown scale type for polar graph. Must be "lin" or "log"',0),
/*
** jpgraph_radar
*/
18001 => array('Client side image maps not supported for RadarPlots.',0),
18002 => array('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.',0),
18003 => array('Illegal scale for radarplot (%s). Must be \'lin\' or \'log\'',1),
18004 => array('Radar Plot size must be between 0.1 and 1. (Your value=%f)',1),
18005 => array('RadarPlot Unsupported Tick density: %d',1),
18006 => array('Minimum data %f (Radar plots should only be used when all data points > 0)',1),
18007 => array('Number of titles does not match number of points in plot.',0),
18008 => array('Each radar plot must have the same number of data points.',0),
/*
** jpgraph_regstat
*/
19001 => array('Spline: Number of X and Y coordinates must be the same',0),
19002 => array('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.',0),
19003 => array('Bezier: Number of X and Y coordinates must be the same',0),
/*
** jpgraph_scatter
*/
20001 => array('Fieldplots must have equal number of X and Y points.',0),
20002 => array('Fieldplots must have an angle specified for each X and Y points.',0),
20003 => array('Scatterplot must have equal number of X and Y points.',0),
/*
** jpgraph_stock
*/
21001 => array('Data values for Stock charts must contain an even multiple of %d data points.',1),
/*
** jpgraph_plotmark
*/
23001 => array('This marker "%s" does not exist in color with index: %d',2),
23002 => array('Mark color index too large for marker "%s"',1),
23003 => array('A filename must be specified if you set the mark type to MARK_IMG.',0),
/*
** jpgraph_utils
*/
24001 => array('FuncGenerator : No function specified. ',0),
24002 => array('FuncGenerator : Syntax error in function specification ',0),
24003 => array('DateScaleUtils: Unknown tick type specified in call to GetTicks()',0),
/*
** jpgraph
*/
25001 => array('This PHP installation is not configured with the GD library. Please recompile PHP with GD support to run JpGraph. (Neither function imagetypes() nor imagecreatefromstring() does exist)',0),
25002 => array('Your PHP installation does not seem to have the required GD library. Please see the PHP documentation on how to install and enable the GD library.',0),
25003 => array('General PHP error : At %s:%d : %s',3),
25004 => array('General PHP error : %s ',1),
25005 => array('Can\'t access PHP_SELF, PHP global variable. You can\'t run PHP from command line if you want to use the \'auto\' naming of cache or image files.',0),
25006 => array('Usage of FF_CHINESE (FF_BIG5) font family requires that your PHP setup has the iconv() function. By default this is not compiled into PHP (needs the "--width-iconv" when configured).',0),
25007 => array('You are trying to use the locale (%s) which your PHP installation does not support. Hint: Use \'\' to indicate the default locale for this geographic region.',1),
25008 => array('Image width/height argument in Graph::Graph() must be numeric',0),
25009 => array('You must specify what scale to use with a call to Graph::SetScale()',0),
25010 => array('Graph::Add() You tried to add a null plot to the graph.',0),
25011 => array('Graph::AddY2() You tried to add a null plot to the graph.',0),
25012 => array('Graph::AddYN() You tried to add a null plot to the graph.',0),
25013 => array('You can only add standard plots to multiple Y-axis',0),
25014 => array('Graph::AddText() You tried to add a null text to the graph.',0),
25015 => array('Graph::AddLine() You tried to add a null line to the graph.',0),
25016 => array('Graph::AddBand() You tried to add a null band to the graph.',0),
25017 => array('You are using GD 2.x and are trying to use a background images on a non truecolor image. To use background images with GD 2.x it is necessary to enable truecolor by setting the USE_TRUECOLOR constant to TRUE. Due to a bug in GD 2.0.1 using any truetype fonts with truecolor images will result in very poor quality fonts.',0),
25018 => array('Incorrect file name for Graph::SetBackgroundImage() : "%s" Must have a valid image extension (jpg,gif,png) when using auto detection of image type',1),
25019 => array('Unknown file extension (%s) in Graph::SetBackgroundImage() for filename: "%s"',2),
25020 => array('Graph::SetScale(): Specified Max value must be larger than the specified Min value.',0),
25021 => array('Unknown scale specification for Y-scale. (%s)',1),
25022 => array('Unknown scale specification for X-scale. (%s)',1),
25023 => array('Unsupported Y2 axis type: "%s" Must be one of (lin,log,int)',1),
25024 => array('Unsupported Y axis type: "%s" Must be one of (lin,log,int)',1),
25025 => array('Unsupported Tick density: %d',1),
25026 => array('Can\'t draw unspecified Y-scale. You have either: 1. Specified an Y axis for auto scaling but have not supplied any plots. 2. Specified a scale manually but have forgot to specify the tick steps',0),
25027 => array('Can\'t open cached CSIM "%s" for reading.',1),
25028 => array('Apache/PHP does not have permission to write to the CSIM cache directory (%s). Check permissions.',1),
25029 => array('Can\'t write CSIM "%s" for writing. Check free space and permissions.',1),
25030 => array('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().',0),
25031 => array('You must specify what scale to use with a call to Graph::SetScale().',0),
25032 => array('No plots for Y-axis nbr:%d',1),
25033 => array('',0),
25034 => array('Can\'t draw unspecified X-scale. No plots specified.',0),
25035 => array('You have enabled clipping. Clipping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (=%d degrees) or disable clipping.',1),
25036 => array('Unknown AxisStyle() : %s',1),
25037 => array('The image format of your background image (%s) is not supported in your system configuration. ',1),
25038 => array('Background image seems to be of different type (has different file extension) than specified imagetype. Specified: %s File: %s',2),
25039 => array('Can\'t read background image: "%s"',1),
25040 => array('It is not possible to specify both a background image and a background country flag.',0),
25041 => array('In order to use Country flags as backgrounds you must include the "jpgraph_flags.php" file.',0),
25042 => array('Unknown background image layout',0),
25043 => array('Unknown title background style.',0),
25044 => array('Cannot use auto scaling since it is impossible to determine a valid min/max value of the Y-axis (only null values).',0),
25045 => array('Font families FF_HANDWRT and FF_BOOK are no longer available due to copyright problem with these fonts. Fonts can no longer be distributed with JpGraph. Please download fonts from http://corefonts.sourceforge.net/',0),
25046 => array('Specified TTF font family (id=%d) is unknown or does not exist. Please note that TTF fonts are not distributed with JpGraph for copyright reasons. You can find the MS TTF WEB-fonts (arial, courier etc) for download at http://corefonts.sourceforge.net/',1),
25047 => array('Style %s is not available for font family %s',2),
25048 => array('Unknown font style specification [%s].',1),
25049 => array('Font file "%s" is not readable or does not exist.',1),
25050 => array('First argument to Text::Text() must be a string.',0),
25051 => array('Invalid direction specified for text.',0),
25052 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown vertical alignment for text',0),
25053 => array('PANIC: Internal error in SuperScript::Stroke(). Unknown horizontal alignment for text',0),
25054 => array('Internal error: Unknown grid axis %s',1),
25055 => array('Axis::SetTickDirection() is deprecated. Use Axis::SetTickSide() instead',0),
25056 => array('SetTickLabelMargin() is deprecated. Use Axis::SetLabelMargin() instead.',0),
25057 => array('SetTextTicks() is deprecated. Use SetTextTickInterval() instead.',0),
25058 => array('Text label interval must be specified >= 1.',0),
25059 => array('SetLabelPos() is deprecated. Use Axis::SetLabelSide() instead.',0),
25060 => array('Unknown alignment specified for X-axis title. (%s)',1),
25061 => array('Unknown alignment specified for Y-axis title. (%s)',1),
25062 => array('Labels at an angle are not supported on Y-axis',0),
25063 => array('Ticks::SetPrecision() is deprecated. Use Ticks::SetLabelFormat() (or Ticks::SetFormatCallback()) instead',0),
25064 => array('Minor or major step size is 0. Check that you haven\'t got an accidental SetTextTicks(0) in your code. If this is not the case you might have stumbled upon a bug in JpGraph. Please report this and if possible include the data that caused the problem',0),
25065 => array('Tick positions must be specified as an array()',0),
25066 => array('When manually specifying tick positions and labels the number of labels must be the same as the number of specified ticks.',0),
25067 => array('Your manually specified scale and ticks is not correct. The scale seems to be too small to hold any of the specified tick marks.',0),
25068 => array('A plot has an illegal scale. This could for example be that you are trying to use text auto scaling to draw a line plot with only one point or that the plot area is too small. It could also be that no input data value is numeric (perhaps only \'-\' or \'x\')',0),
25069 => array('Grace must be larger then 0',0),
25070 => array('Either X or Y data arrays contains non-numeric values. Check that the data is really specified as numeric data and not as strings. It is an error to specify data for example as \'-2345.2\' (using quotes).',0),
25071 => array('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.',0),
25072 => array('You have specified a max value with SetAutoMax() which is smaller than the minimum value used for the scale. This is not possible.',0),
25073 => array('Internal error. Integer scale algorithm comparison out of bound (r=%f)',1),
25074 => array('Internal error. The scale range is negative (%f) [for %s scale] This problem could potentially be caused by trying to use \"illegal\" values in the input data arrays (like trying to send in strings or only NULL values) which causes the auto scaling to fail.',2),
25075 => array('Can\'t automatically determine ticks since min==max.',0),
25077 => array('Adjustment factor for color must be > 0',0),
25078 => array('Unknown color: %s',1),
25079 => array('Unknown color specification: %s, size=%d',2),
25080 => array('Alpha parameter for color must be between 0.0 and 1.0',0),
25081 => array('Selected graphic format is either not supported or unknown [%s]',1),
25082 => array('Illegal sizes specified for width or height when creating an image, (width=%d, height=%d)',2),
25083 => array('Illegal image size when copying image. Size for copied to image is 1 pixel or less.',0),
25084 => array('Failed to create temporary GD canvas. Possible Out of memory problem.',0),
25085 => array('An image can not be created from the supplied string. It is either in a format not supported or the string is representing an corrupt image.',0),
25086 => array('You only seem to have GD 1.x installed. To enable Alphablending requires GD 2.x or higher. Please install GD or make sure the constant USE_GD2 is specified correctly to reflect your installation. By default it tries to auto detect what version of GD you have installed. On some very rare occasions it may falsely detect GD2 where only GD1 is installed. You must then set USE_GD2 to false.',0),
25087 => array('This PHP build has not been configured with TTF support. You need to recompile your PHP installation with FreeType support.',0),
25088 => array('You have a misconfigured GD font support. The call to imagefontwidth() fails.',0),
25089 => array('You have a misconfigured GD font support. The call to imagefontheight() fails.',0),
25090 => array('Unknown direction specified in call to StrokeBoxedText() [%s]',1),
25091 => array('Internal font does not support drawing text at arbitrary angle. Use TTF fonts instead.',0),
25092 => array('There is either a configuration problem with TrueType or a problem reading font file "%s" Make sure file exists and is in a readable place for the HTTP process. (If \'basedir\' restriction is enabled in PHP then the font file must be located in the document root.). It might also be a wrongly installed FreeType library. Try upgrading to at least FreeType 2.1.13 and recompile GD with the correct setup so it can find the new FT library.',1),
25093 => array('Can not read font file "%s" in call to Image::GetBBoxTTF. Please make sure that you have set a font before calling this method and that the font is installed in the TTF directory.',1),
25094 => array('Direction for text most be given as an angle between 0 and 90.',0),
25095 => array('Unknown font font family specification. ',0),
25096 => array('Can\'t allocate any more colors in palette image. Image has already allocated maximum of %d colors and the palette is now full. Change to a truecolor image instead',0),
25097 => array('Color specified as empty string in PushColor().',0),
25098 => array('Negative Color stack index. Unmatched call to PopColor()',0),
25099 => array('Parameters for brightness and Contrast out of range [-1,1]',0),
25100 => array('Problem with color palette and your GD setup. Please disable anti-aliasing or use GD2 with true-color. If you have GD2 library installed please make sure that you have set the USE_GD2 constant to true and truecolor is enabled.',0),
25101 => array('Illegal numeric argument to SetLineStyle(): (%d)',1),
25102 => array('Illegal string argument to SetLineStyle(): %s',1),
25103 => array('Illegal argument to SetLineStyle %s',1),
25104 => array('Unknown line style: %s',1),
25105 => array('NULL data specified for a filled polygon. Check that your data is not NULL.',0),
25106 => array('Image::FillToBorder : Can not allocate more colors',0),
25107 => array('Can\'t write to file "%s". Check that the process running PHP has enough permission.',1),
25108 => array('Can\'t stream image. This is most likely due to a faulty PHP/GD setup. Try to recompile PHP and use the built-in GD library that comes with PHP.',0),
25109 => array('Your PHP (and GD-lib) installation does not appear to support any known graphic formats. You need to first make sure GD is compiled as a module to PHP. If you also want to use JPEG images you must get the JPEG library. Please see the PHP docs for details.',0),
25110 => array('Your PHP installation does not support the chosen graphic format: %s',1),
25111 => array('Can\'t delete cached image %s. Permission problem?',1),
25112 => array('Cached imagefile (%s) has file date in the future.',1),
25113 => array('Can\'t delete cached image "%s". Permission problem?',1),
25114 => array('PHP has not enough permissions to write to the cache file "%s". Please make sure that the user running PHP has write permission for this file if you wan to use the cache system with JpGraph.',1),
25115 => array('Can\'t set permission for cached image "%s". Permission problem?',1),
25116 => array('Cant open file from cache "%s"',1),
25117 => array('Can\'t open cached image "%s" for reading.',1),
25118 => array('Can\'t create directory "%s". Make sure PHP has write permission to this directory.',1),
25119 => array('Can\'t set permissions for "%s". Permission problems?',1),
25120 => array('Position for legend must be given as percentage in range 0-1',0),
25121 => array('Empty input data array specified for plot. Must have at least one data point.',0),
25122 => array('Stroke() must be implemented by concrete subclass to class Plot',0),
25123 => array('You can\'t use a text X-scale with specified X-coords. Use a "int" or "lin" scale instead.',0),
25124 => array('The input data array must have consecutive values from position 0 and forward. The given y-array starts with empty values (NULL)',0),
25125 => array('Illegal direction for static line',0),
25126 => array('Can\'t create truecolor image. Check that the GD2 library is properly setup with PHP.',0),
25127 => array('The library has been configured for automatic encoding conversion of Japanese fonts. This requires that PHP has the mb_convert_encoding() function. Your PHP installation lacks this function (PHP needs the "--enable-mbstring" when compiled).',0),
25128 => array('The function imageantialias() is not available in your PHP installation. Use the GD version that comes with PHP and not the standalone version.',0),
25129 => array('Anti-alias can not be used with dashed lines. Please disable anti-alias or use solid lines.',0),
/*
**---------------------------------------------------------------------------------------------
** Pro-version strings
**---------------------------------------------------------------------------------------------
*/
/*
** jpgraph_table
*/
27001 => array('GTextTable: Invalid argument to Set(). Array argument must be 2 dimensional',0),
27002 => array('GTextTable: Invalid argument to Set()',0),
27003 => array('GTextTable: Wrong number of arguments to GTextTable::SetColor()',0),
27004 => array('GTextTable: Specified cell range to be merged is not valid.',0),
27005 => array('GTextTable: Cannot merge already merged cells in the range: (%d,%d) to (%d,%d)',4),
27006 => array('GTextTable: Column argument = %d is outside specified table size.',1),
27007 => array('GTextTable: Row argument = %d is outside specified table size.',1),
27008 => array('GTextTable: Column and row size arrays must match the dimensions of the table',0),
27009 => array('GTextTable: Number of table columns or rows are 0. Make sure Init() or Set() is called.',0),
27010 => array('GTextTable: No alignment specified in call to SetAlign()',0),
27011 => array('GTextTable: Unknown alignment specified in SetAlign(). Horizontal=%s, Vertical=%s',2),
27012 => array('GTextTable: Internal error. Invalid alignment specified =%s',1),
27013 => array('GTextTable: Argument to FormatNumber() must be a string.',0),
27014 => array('GTextTable: Table is not initilaized with either a call to Set() or Init()',0),
27015 => array('GTextTable: Cell image constrain type must be TIMG_WIDTH or TIMG_HEIGHT',0),
/*
** jpgraph_windrose
*/
22001 => array('Total percentage for all windrose legs in a windrose plot can not exceed 100%% !\n(Current max is: %d)',1),
22002 => array('Graph is too small to have a scale. Please make the graph larger.',0),
22004 => array('Label specification for windrose directions must have 16 values (one for each compass direction).',0),
22005 => array('Line style for radial lines must be on of ("solid","dotted","dashed","longdashed") ',0),
22006 => array('Illegal windrose type specified.',0),
22007 => array('To few values for the range legend.',0),
22008 => array('Internal error: Trying to plot free Windrose even though type is not a free windrose',0),
22009 => array('You have specified the same direction twice, once with an angle and once with a compass direction (%f degrees)',0),
22010 => array('Direction must either be a numeric value or one of the 16 compass directions',0),
22011 => array('Windrose index must be numeric or direction label. You have specified index=%d',1),
22012 => array('Windrose radial axis specification contains a direction which is not enabled.',0),
22013 => array('You have specified the look&feel for the same compass direction twice, once with text and once with index (Index=%d)',1),
22014 => array('Index for compass direction must be between 0 and 15.',0),
22015 => array('You have specified an undefined Windrose plot type.',0),
22016 => array('Windrose leg index must be numeric or direction label.',0),
22017 => array('Windrose data contains a direction which is not enabled. Please adjust what labels are displayed.',0),
22018 => array('You have specified data for the same compass direction twice, once with text and once with index (Index=%d)',1),
22019 => array('Index for direction must be between 0 and 15. You can\'t specify angles for a Regular Windplot, only index and compass directions.',0),
22020 => array('Windrose plot is too large to fit the specified Graph size. Please use WindrosePlot::SetSize() to make the plot smaller or increase the size of the Graph in the initial WindroseGraph() call.',0),
22021 => array('It is only possible to add Text, IconPlot or WindrosePlot to a Windrose Graph',0),
/*
** jpgraph_odometer
*/
13001 => array('Unknown needle style (%d).',1),
13002 => array('Value for odometer (%f) is outside specified scale [%f,%f]',3),
/*
** jpgraph_barcode
*/
1001 => array('Unknown encoder specification: %s',1),
1002 => array('Data validation failed. Can\'t encode [%s] using encoding "%s"',2),
1003 => array('Internal encoding error. Trying to encode %s is not possible in Code 128',1),
1004 => array('Internal barcode error. Unknown UPC-E encoding type: %s',1),
1005 => array('Internal error. Can\'t encode character tuple (%s, %s) in Code-128 charset C',2),
1006 => array('Internal encoding error for CODE 128. Trying to encode control character in CHARSET != A',0),
1007 => array('Internal encoding error for CODE 128. Trying to encode DEL in CHARSET != B',0),
1008 => array('Internal encoding error for CODE 128. Trying to encode small letters in CHARSET != B',0),
1009 => array('Encoding using CODE 93 is not yet supported.',0),
1010 => array('Encoding using POSTNET is not yet supported.',0),
1011 => array('Non supported barcode backend for type %s',1),
/*
** PDF417
*/
26001 => array('PDF417: Number of Columns must be >= 1 and <= 30',0),
26002 => array('PDF417: Error level must be between 0 and 8',0),
26003 => array('PDF417: Invalid format for input data to encode with PDF417',0),
26004 => array('PDF417: Can\'t encode given data with error level %d and %d columns since it results in too many symbols or more than 90 rows.',2),
26005 => array('PDF417: Can\'t open file "%s" for writing',1),
26006 => array('PDF417: Internal error. Data files for PDF417 cluster %d is corrupted.',1),
26007 => array('PDF417: Internal error. GetPattern: Illegal Code Value = %d (row=%d)',2),
26008 => array('PDF417: Internal error. Mode not found in mode list!! mode=%d',1),
26009 => array('PDF417: Encode error: Illegal character. Can\'t encode character with ASCII code=%d',1),
26010 => array('PDF417: Internal error: No input data in decode.',0),
26011 => array('PDF417: Encoding error. Can\'t use numeric encoding on non-numeric data.',0),
26012 => array('PDF417: Internal error. No input data to decode for Binary compressor.',0),
26013 => array('PDF417: Internal error. Checksum error. Coefficient tables corrupted.',0),
26014 => array('PDF417: Internal error. No data to calculate codewords on.',0),
26015 => array('PDF417: Internal error. State transition table entry 0 is NULL. Entry 1 = (%s)',1),
26016 => array('PDF417: Internal error: Unrecognized state transition mode in decode.',0),
);
?>

View File

@ -0,0 +1,357 @@
<?php
/*=======================================================================
// File: PROD.INC.PHP
// Description: Special localization file with the same error messages
// for all errors.
// Created: 2006-02-18
// Ver: $Id: prod.inc.php 993 2008-03-30 21:17:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
// The single error message for all errors
DEFINE('DEFAULT_ERROR_MESSAGE','We are sorry but the system could not generate the requested image. Please contact site support to resolve this problem. Problem no: #');
// Note: Format of each error message is array(<error message>,<number of arguments>)
$_jpg_messages = array(
/*
** Headers already sent error. This is formatted as HTML different since this will be sent back directly as text
*/
10 => array('<table border=1><tr><td><font color=darkred size=4><b>JpGraph Error:</b>
HTTP headers have already been sent.<br>Caused by output from file <b>%s</b> at line <b>%d</b>.</font></td></tr><tr><td><b>Explanation:</b><br>HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it\'s image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).<p>Most likely you have some text in your script before the call to <i>Graph::Stroke()</i>. If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser. <p>For example it is a common mistake to leave a blank line before the opening "<b>&lt;?php</b>".</td></tr></table>',2),
11 => array(DEFAULT_ERROR_MESSAGE.'11',0),
12 => array(DEFAULT_ERROR_MESSAGE.'12',0),
13 => array(DEFAULT_ERROR_MESSAGE.'13',0),
2001 => array(DEFAULT_ERROR_MESSAGE.'2001',0),
2002 => array(DEFAULT_ERROR_MESSAGE.'2002',0),
2003 => array(DEFAULT_ERROR_MESSAGE.'2003',0),
2004 => array(DEFAULT_ERROR_MESSAGE.'2004',0),
2005 => array(DEFAULT_ERROR_MESSAGE.'2005',0),
2006 => array(DEFAULT_ERROR_MESSAGE.'2006',0),
2007 => array(DEFAULT_ERROR_MESSAGE.'2007',0),
2008 => array(DEFAULT_ERROR_MESSAGE.'2008',0),
2009 => array(DEFAULT_ERROR_MESSAGE.'2009',0),
2010 => array(DEFAULT_ERROR_MESSAGE.'2010',0),
2011 => array(DEFAULT_ERROR_MESSAGE.'2011',0),
2012 => array(DEFAULT_ERROR_MESSAGE.'2012',0),
2013 => array(DEFAULT_ERROR_MESSAGE.'2013',0),
2014 => array(DEFAULT_ERROR_MESSAGE.'2014',0),
3001 => array(DEFAULT_ERROR_MESSAGE.'3001',0),
4002 => array(DEFAULT_ERROR_MESSAGE.'4002',0),
5001 => array(DEFAULT_ERROR_MESSAGE.'5001',0),
5002 => array(DEFAULT_ERROR_MESSAGE.'5002',0),
5003 => array(DEFAULT_ERROR_MESSAGE.'5003',0),
5004 => array(DEFAULT_ERROR_MESSAGE.'5004',0),
6001 => array(DEFAULT_ERROR_MESSAGE.'6001',0),
6002 => array(DEFAULT_ERROR_MESSAGE.'6002',0),
6003 => array(DEFAULT_ERROR_MESSAGE.'6003',0),
6004 => array(DEFAULT_ERROR_MESSAGE.'6004',0),
6005 => array(DEFAULT_ERROR_MESSAGE.'6005',0),
6006 => array(DEFAULT_ERROR_MESSAGE.'6006',0),
6007 => array(DEFAULT_ERROR_MESSAGE.'6007',0),
6008 => array(DEFAULT_ERROR_MESSAGE.'6008',0),
6009 => array(DEFAULT_ERROR_MESSAGE.'6009',0),
6010 => array(DEFAULT_ERROR_MESSAGE.'6010',0),
6011 => array(DEFAULT_ERROR_MESSAGE.'6011',0),
6012 => array(DEFAULT_ERROR_MESSAGE.'6012',0),
6015 => array(DEFAULT_ERROR_MESSAGE.'6015',0),
6016 => array(DEFAULT_ERROR_MESSAGE.'6016',0),
6017 => array(DEFAULT_ERROR_MESSAGE.'6017',0),
6018 => array(DEFAULT_ERROR_MESSAGE.'6018',0),
6019 => array(DEFAULT_ERROR_MESSAGE.'6019',0),
6020 => array(DEFAULT_ERROR_MESSAGE.'6020',0),
6021 => array(DEFAULT_ERROR_MESSAGE.'6021',0),
6022 => array(DEFAULT_ERROR_MESSAGE.'6022',0),
6023 => array(DEFAULT_ERROR_MESSAGE.'6023',0),
6024 => array(DEFAULT_ERROR_MESSAGE.'6024',0),
6025 => array(DEFAULT_ERROR_MESSAGE.'6025',0),
6027 => array(DEFAULT_ERROR_MESSAGE.'6027',0),
6028 => array(DEFAULT_ERROR_MESSAGE.'6028',0),
6029 => array(DEFAULT_ERROR_MESSAGE.'6029',0),
6030 => array(DEFAULT_ERROR_MESSAGE.'6030',0),
6031 => array(DEFAULT_ERROR_MESSAGE.'6031',0),
6032 => array(DEFAULT_ERROR_MESSAGE.'6032',0),
7001 => array(DEFAULT_ERROR_MESSAGE.'7001',0),
8001 => array(DEFAULT_ERROR_MESSAGE.'8001',0),
8002 => array(DEFAULT_ERROR_MESSAGE.'8002',0),
8003 => array(DEFAULT_ERROR_MESSAGE.'8003',0),
8004 => array(DEFAULT_ERROR_MESSAGE.'8004',0),
9001 => array(DEFAULT_ERROR_MESSAGE.'9001',0),
10001 => array(DEFAULT_ERROR_MESSAGE.'10001',0),
10002 => array(DEFAULT_ERROR_MESSAGE.'10002',0),
10003 => array(DEFAULT_ERROR_MESSAGE.'10003',0),
11001 => array(DEFAULT_ERROR_MESSAGE.'11001',0),
11002 => array(DEFAULT_ERROR_MESSAGE.'11002',0),
11003 => array(DEFAULT_ERROR_MESSAGE.'11003',0),
11004 => array(DEFAULT_ERROR_MESSAGE.'11004',0),
11005 => array(DEFAULT_ERROR_MESSAGE.'11005',0),
12001 => array(DEFAULT_ERROR_MESSAGE.'12001',0),
12002 => array(DEFAULT_ERROR_MESSAGE.'12002',0),
12003 => array(DEFAULT_ERROR_MESSAGE.'12003',0),
12004 => array(DEFAULT_ERROR_MESSAGE.'12004',0),
12005 => array(DEFAULT_ERROR_MESSAGE.'12005',0),
12006 => array(DEFAULT_ERROR_MESSAGE.'12006',0),
12007 => array(DEFAULT_ERROR_MESSAGE.'12007',0),
12008 => array(DEFAULT_ERROR_MESSAGE.'12008',0),
12009 => array(DEFAULT_ERROR_MESSAGE.'12009',0),
12010 => array(DEFAULT_ERROR_MESSAGE.'12010',0),
12011 => array(DEFAULT_ERROR_MESSAGE.'12011',0),
12012 => array(DEFAULT_ERROR_MESSAGE.'12012',0),
14001 => array(DEFAULT_ERROR_MESSAGE.'14001',0),
14002 => array(DEFAULT_ERROR_MESSAGE.'14002',0),
14003 => array(DEFAULT_ERROR_MESSAGE.'14003',0),
14004 => array(DEFAULT_ERROR_MESSAGE.'14004',0),
14005 => array(DEFAULT_ERROR_MESSAGE.'14005',0),
14006 => array(DEFAULT_ERROR_MESSAGE.'14006',0),
14007 => array(DEFAULT_ERROR_MESSAGE.'14007',0),
15001 => array(DEFAULT_ERROR_MESSAGE.'15001',0),
15002 => array(DEFAULT_ERROR_MESSAGE.'15002',0),
15003 => array(DEFAULT_ERROR_MESSAGE.'15003',0),
15004 => array(DEFAULT_ERROR_MESSAGE.'15004',0),
15005 => array(DEFAULT_ERROR_MESSAGE.'15005',0),
15006 => array(DEFAULT_ERROR_MESSAGE.'15006',0),
15007 => array(DEFAULT_ERROR_MESSAGE.'15007',0),
15008 => array(DEFAULT_ERROR_MESSAGE.'15008',0),
15009 => array(DEFAULT_ERROR_MESSAGE.'15009',0),
15010 => array(DEFAULT_ERROR_MESSAGE.'15010',0),
15011 => array(DEFAULT_ERROR_MESSAGE.'15011',0),
16001 => array(DEFAULT_ERROR_MESSAGE.'16001',0),
16002 => array(DEFAULT_ERROR_MESSAGE.'16002',0),
16003 => array(DEFAULT_ERROR_MESSAGE.'16003',0),
16004 => array(DEFAULT_ERROR_MESSAGE.'16004',0),
17001 => array(DEFAULT_ERROR_MESSAGE.'17001',0),
17002 => array(DEFAULT_ERROR_MESSAGE.'17002',0),
17004 => array(DEFAULT_ERROR_MESSAGE.'17004',0),
18001 => array(DEFAULT_ERROR_MESSAGE.'18001',0),
18002 => array(DEFAULT_ERROR_MESSAGE.'18002',0),
18003 => array(DEFAULT_ERROR_MESSAGE.'18003',0),
18004 => array(DEFAULT_ERROR_MESSAGE.'18004',0),
18005 => array(DEFAULT_ERROR_MESSAGE.'18005',0),
18006 => array(DEFAULT_ERROR_MESSAGE.'18006',0),
18007 => array(DEFAULT_ERROR_MESSAGE.'18007',0),
18008 => array(DEFAULT_ERROR_MESSAGE.'18008',0),
19001 => array(DEFAULT_ERROR_MESSAGE.'19001',0),
19002 => array(DEFAULT_ERROR_MESSAGE.'19002',0),
19003 => array(DEFAULT_ERROR_MESSAGE.'19003',0),
20001 => array(DEFAULT_ERROR_MESSAGE.'20001',0),
20002 => array(DEFAULT_ERROR_MESSAGE.'20002',0),
20003 => array(DEFAULT_ERROR_MESSAGE.'20003',0),
21001 => array(DEFAULT_ERROR_MESSAGE.'21001',0),
23001 => array(DEFAULT_ERROR_MESSAGE.'23001',0),
23002 => array(DEFAULT_ERROR_MESSAGE.'23002',0),
23003 => array(DEFAULT_ERROR_MESSAGE.'23003',0),
24001 => array(DEFAULT_ERROR_MESSAGE.'24001',0),
24002 => array(DEFAULT_ERROR_MESSAGE.'24002',0),
24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0),
25001 => array(DEFAULT_ERROR_MESSAGE.'25001',0),
25002 => array(DEFAULT_ERROR_MESSAGE.'25002',0),
25003 => array(DEFAULT_ERROR_MESSAGE.'25003',0),
25004 => array(DEFAULT_ERROR_MESSAGE.'25004',0),
25005 => array(DEFAULT_ERROR_MESSAGE.'25005',0),
25006 => array(DEFAULT_ERROR_MESSAGE.'25006',0),
25007 => array(DEFAULT_ERROR_MESSAGE.'25007',0),
25008 => array(DEFAULT_ERROR_MESSAGE.'25008',0),
25009 => array(DEFAULT_ERROR_MESSAGE.'25009',0),
25010 => array(DEFAULT_ERROR_MESSAGE.'25010',0),
25011 => array(DEFAULT_ERROR_MESSAGE.'25011',0),
25012 => array(DEFAULT_ERROR_MESSAGE.'25012',0),
25013 => array(DEFAULT_ERROR_MESSAGE.'25013',0),
25014 => array(DEFAULT_ERROR_MESSAGE.'25014',0),
25015 => array(DEFAULT_ERROR_MESSAGE.'25015',0),
25016 => array(DEFAULT_ERROR_MESSAGE.'25016',0),
25017 => array(DEFAULT_ERROR_MESSAGE.'25017',0),
25018 => array(DEFAULT_ERROR_MESSAGE.'25018',0),
25019 => array(DEFAULT_ERROR_MESSAGE.'25019',0),
25020 => array(DEFAULT_ERROR_MESSAGE.'25020',0),
25021 => array(DEFAULT_ERROR_MESSAGE.'25021',0),
25022 => array(DEFAULT_ERROR_MESSAGE.'25022',0),
25023 => array(DEFAULT_ERROR_MESSAGE.'25023',0),
25024 => array(DEFAULT_ERROR_MESSAGE.'25024',0),
25025 => array(DEFAULT_ERROR_MESSAGE.'25025',0),
25026 => array(DEFAULT_ERROR_MESSAGE.'25026',0),
25027 => array(DEFAULT_ERROR_MESSAGE.'25027',0),
25028 => array(DEFAULT_ERROR_MESSAGE.'25028',0),
25029 => array(DEFAULT_ERROR_MESSAGE.'25029',0),
25030 => array(DEFAULT_ERROR_MESSAGE.'25030',0),
25031 => array(DEFAULT_ERROR_MESSAGE.'25031',0),
25032 => array(DEFAULT_ERROR_MESSAGE.'25032',0),
25033 => array(DEFAULT_ERROR_MESSAGE.'25033',0),
25034 => array(DEFAULT_ERROR_MESSAGE.'25034',0),
25035 => array(DEFAULT_ERROR_MESSAGE.'25035',0),
25036 => array(DEFAULT_ERROR_MESSAGE.'25036',0),
25037 => array(DEFAULT_ERROR_MESSAGE.'25037',0),
25038 => array(DEFAULT_ERROR_MESSAGE.'25038',0),
25039 => array(DEFAULT_ERROR_MESSAGE.'25039',0),
25040 => array(DEFAULT_ERROR_MESSAGE.'25040',0),
25041 => array(DEFAULT_ERROR_MESSAGE.'25041',0),
25042 => array(DEFAULT_ERROR_MESSAGE.'25042',0),
25043 => array(DEFAULT_ERROR_MESSAGE.'25043',0),
25044 => array(DEFAULT_ERROR_MESSAGE.'25044',0),
25045 => array(DEFAULT_ERROR_MESSAGE.'25045',0),
25046 => array(DEFAULT_ERROR_MESSAGE.'25046',0),
25047 => array(DEFAULT_ERROR_MESSAGE.'25047',0),
25048 => array(DEFAULT_ERROR_MESSAGE.'25048',0),
25049 => array(DEFAULT_ERROR_MESSAGE.'25049',0),
25050 => array(DEFAULT_ERROR_MESSAGE.'25050',0),
25051 => array(DEFAULT_ERROR_MESSAGE.'25051',0),
25052 => array(DEFAULT_ERROR_MESSAGE.'25052',0),
25053 => array(DEFAULT_ERROR_MESSAGE.'25053',0),
25054 => array(DEFAULT_ERROR_MESSAGE.'25054',0),
25055 => array(DEFAULT_ERROR_MESSAGE.'25055',0),
25056 => array(DEFAULT_ERROR_MESSAGE.'25056',0),
25057 => array(DEFAULT_ERROR_MESSAGE.'25057',0),
25058 => array(DEFAULT_ERROR_MESSAGE.'25058',0),
25059 => array(DEFAULT_ERROR_MESSAGE.'25059',0),
25060 => array(DEFAULT_ERROR_MESSAGE.'25060',0),
25061 => array(DEFAULT_ERROR_MESSAGE.'25061',0),
25062 => array(DEFAULT_ERROR_MESSAGE.'25062',0),
25063 => array(DEFAULT_ERROR_MESSAGE.'25063',0),
25064 => array(DEFAULT_ERROR_MESSAGE.'25064',0),
25065 => array(DEFAULT_ERROR_MESSAGE.'25065',0),
25066 => array(DEFAULT_ERROR_MESSAGE.'25066',0),
25067 => array(DEFAULT_ERROR_MESSAGE.'25067',0),
25068 => array(DEFAULT_ERROR_MESSAGE.'25068',0),
25069 => array(DEFAULT_ERROR_MESSAGE.'25069',0),
25070 => array(DEFAULT_ERROR_MESSAGE.'25070',0),
25071 => array(DEFAULT_ERROR_MESSAGE.'25071',0),
25072 => array(DEFAULT_ERROR_MESSAGE.'25072',0),
25073 => array(DEFAULT_ERROR_MESSAGE.'25073',0),
25074 => array(DEFAULT_ERROR_MESSAGE.'25074',0),
25075 => array(DEFAULT_ERROR_MESSAGE.'25075',0),
25077 => array(DEFAULT_ERROR_MESSAGE.'25077',0),
25078 => array(DEFAULT_ERROR_MESSAGE.'25078',0),
25079 => array(DEFAULT_ERROR_MESSAGE.'25079',0),
25080 => array(DEFAULT_ERROR_MESSAGE.'25080',0),
25081 => array(DEFAULT_ERROR_MESSAGE.'25081',0),
25082 => array(DEFAULT_ERROR_MESSAGE.'25082',0),
25083 => array(DEFAULT_ERROR_MESSAGE.'25083',0),
25084 => array(DEFAULT_ERROR_MESSAGE.'25084',0),
25085 => array(DEFAULT_ERROR_MESSAGE.'25085',0),
25086 => array(DEFAULT_ERROR_MESSAGE.'25086',0),
25087 => array(DEFAULT_ERROR_MESSAGE.'25087',0),
25088 => array(DEFAULT_ERROR_MESSAGE.'25088',0),
25089 => array(DEFAULT_ERROR_MESSAGE.'25089',0),
25090 => array(DEFAULT_ERROR_MESSAGE.'25090',0),
25091 => array(DEFAULT_ERROR_MESSAGE.'25091',0),
25092 => array(DEFAULT_ERROR_MESSAGE.'25092',0),
25093 => array(DEFAULT_ERROR_MESSAGE.'25093',0),
25094 => array(DEFAULT_ERROR_MESSAGE.'25094',0),
25095 => array(DEFAULT_ERROR_MESSAGE.'25095',0),
25096 => array(DEFAULT_ERROR_MESSAGE.'25096',0),
25097 => array(DEFAULT_ERROR_MESSAGE.'25097',0),
25098 => array(DEFAULT_ERROR_MESSAGE.'25098',0),
25099 => array(DEFAULT_ERROR_MESSAGE.'25099',0),
25100 => array(DEFAULT_ERROR_MESSAGE.'25100',0),
25101 => array(DEFAULT_ERROR_MESSAGE.'25101',0),
25102 => array(DEFAULT_ERROR_MESSAGE.'25102',0),
25103 => array(DEFAULT_ERROR_MESSAGE.'25103',0),
25104 => array(DEFAULT_ERROR_MESSAGE.'25104',0),
25105 => array(DEFAULT_ERROR_MESSAGE.'25105',0),
25106 => array(DEFAULT_ERROR_MESSAGE.'25106',0),
25107 => array(DEFAULT_ERROR_MESSAGE.'25107',0),
25108 => array(DEFAULT_ERROR_MESSAGE.'25108',0),
25109 => array(DEFAULT_ERROR_MESSAGE.'25109',0),
25110 => array(DEFAULT_ERROR_MESSAGE.'25110',0),
25111 => array(DEFAULT_ERROR_MESSAGE.'25111',0),
25112 => array(DEFAULT_ERROR_MESSAGE.'25112',0),
25113 => array(DEFAULT_ERROR_MESSAGE.'25113',0),
25114 => array(DEFAULT_ERROR_MESSAGE.'25114',0),
25115 => array(DEFAULT_ERROR_MESSAGE.'25115',0),
25116 => array(DEFAULT_ERROR_MESSAGE.'25116',0),
25117 => array(DEFAULT_ERROR_MESSAGE.'25117',0),
25118 => array(DEFAULT_ERROR_MESSAGE.'25118',0),
25119 => array(DEFAULT_ERROR_MESSAGE.'25119',0),
25120 => array(DEFAULT_ERROR_MESSAGE.'25120',0),
25121 => array(DEFAULT_ERROR_MESSAGE.'25121',0),
25122 => array(DEFAULT_ERROR_MESSAGE.'25122',0),
25123 => array(DEFAULT_ERROR_MESSAGE.'25123',0),
25124 => array(DEFAULT_ERROR_MESSAGE.'25124',0),
25125 => array(DEFAULT_ERROR_MESSAGE.'25125',0),
25126 => array(DEFAULT_ERROR_MESSAGE.'25126',0),
25127 => array(DEFAULT_ERROR_MESSAGE.'25127',0),
25128 => array(DEFAULT_ERROR_MESSAGE.'25128',0),
25129 => array(DEFAULT_ERROR_MESSAGE.'25129',0),
24003 => array(DEFAULT_ERROR_MESSAGE.'24003',0),
24004 => array(DEFAULT_ERROR_MESSAGE.'24004',0),
24005 => array(DEFAULT_ERROR_MESSAGE.'24005',0),
24006 => array(DEFAULT_ERROR_MESSAGE.'24006',0),
24007 => array(DEFAULT_ERROR_MESSAGE.'24007',0),
24008 => array(DEFAULT_ERROR_MESSAGE.'24008',0),
24009 => array(DEFAULT_ERROR_MESSAGE.'24009',0),
24010 => array(DEFAULT_ERROR_MESSAGE.'24010',0),
24011 => array(DEFAULT_ERROR_MESSAGE.'24011',0),
24012 => array(DEFAULT_ERROR_MESSAGE.'24012',0),
24013 => array(DEFAULT_ERROR_MESSAGE.'24013',0),
24014 => array(DEFAULT_ERROR_MESSAGE.'24014',0),
24015 => array(DEFAULT_ERROR_MESSAGE.'24015',0),
22001 => array(DEFAULT_ERROR_MESSAGE.'22001',0),
22002 => array(DEFAULT_ERROR_MESSAGE.'22002',0),
22004 => array(DEFAULT_ERROR_MESSAGE.'22004',0),
22005 => array(DEFAULT_ERROR_MESSAGE.'22005',0),
22006 => array(DEFAULT_ERROR_MESSAGE.'22006',0),
22007 => array(DEFAULT_ERROR_MESSAGE.'22007',0),
22008 => array(DEFAULT_ERROR_MESSAGE.'22008',0),
22009 => array(DEFAULT_ERROR_MESSAGE.'22009',0),
22010 => array(DEFAULT_ERROR_MESSAGE.'22010',0),
22011 => array(DEFAULT_ERROR_MESSAGE.'22011',0),
22012 => array(DEFAULT_ERROR_MESSAGE.'22012',0),
22013 => array(DEFAULT_ERROR_MESSAGE.'22013',0),
22014 => array(DEFAULT_ERROR_MESSAGE.'22014',0),
22015 => array(DEFAULT_ERROR_MESSAGE.'22015',0),
22016 => array(DEFAULT_ERROR_MESSAGE.'22016',0),
22017 => array(DEFAULT_ERROR_MESSAGE.'22017',0),
22018 => array(DEFAULT_ERROR_MESSAGE.'22018',0),
22019 => array(DEFAULT_ERROR_MESSAGE.'22019',0),
22020 => array(DEFAULT_ERROR_MESSAGE.'22020',0),
13001 => array(DEFAULT_ERROR_MESSAGE.'13001',0),
13002 => array(DEFAULT_ERROR_MESSAGE.'13002',0),
1001 => array(DEFAULT_ERROR_MESSAGE.'1001',0),
1002 => array(DEFAULT_ERROR_MESSAGE.'1002',0),
1003 => array(DEFAULT_ERROR_MESSAGE.'1003',0),
1004 => array(DEFAULT_ERROR_MESSAGE.'1004',0),
1005 => array(DEFAULT_ERROR_MESSAGE.'1005',0),
1006 => array(DEFAULT_ERROR_MESSAGE.'1006',0),
1007 => array(DEFAULT_ERROR_MESSAGE.'1007',0),
1008 => array(DEFAULT_ERROR_MESSAGE.'1008',0),
1009 => array(DEFAULT_ERROR_MESSAGE.'1009',0),
1010 => array(DEFAULT_ERROR_MESSAGE.'1010',0),
1011 => array(DEFAULT_ERROR_MESSAGE.'1011',0),
26001 => array(DEFAULT_ERROR_MESSAGE.'26001',0),
26002 => array(DEFAULT_ERROR_MESSAGE.'26002',0),
26003 => array(DEFAULT_ERROR_MESSAGE.'26003',0),
26004 => array(DEFAULT_ERROR_MESSAGE.'26004',0),
26005 => array(DEFAULT_ERROR_MESSAGE.'26005',0),
26006 => array(DEFAULT_ERROR_MESSAGE.'26006',0),
26007 => array(DEFAULT_ERROR_MESSAGE.'26007',0),
26008 => array(DEFAULT_ERROR_MESSAGE.'26008',0),
26009 => array(DEFAULT_ERROR_MESSAGE.'26009',0),
26010 => array(DEFAULT_ERROR_MESSAGE.'26010',0),
26011 => array(DEFAULT_ERROR_MESSAGE.'26011',0),
26012 => array(DEFAULT_ERROR_MESSAGE.'26012',0),
26013 => array(DEFAULT_ERROR_MESSAGE.'26013',0),
26014 => array(DEFAULT_ERROR_MESSAGE.'26014',0),
26015 => array(DEFAULT_ERROR_MESSAGE.'26015',0),
26016 => array(DEFAULT_ERROR_MESSAGE.'26016',0),
27001 => array(DEFAULT_ERROR_MESSAGE.'27001',0),
27002 => array(DEFAULT_ERROR_MESSAGE.'27002',0),
27003 => array(DEFAULT_ERROR_MESSAGE.'27003',0),
27004 => array(DEFAULT_ERROR_MESSAGE.'27004',0),
27005 => array(DEFAULT_ERROR_MESSAGE.'27005',0),
27006 => array(DEFAULT_ERROR_MESSAGE.'27006',0),
27007 => array(DEFAULT_ERROR_MESSAGE.'27007',0),
27008 => array(DEFAULT_ERROR_MESSAGE.'27008',0),
27009 => array(DEFAULT_ERROR_MESSAGE.'27009',0),
27010 => array(DEFAULT_ERROR_MESSAGE.'27010',0),
27011 => array(DEFAULT_ERROR_MESSAGE.'27011',0),
27012 => array(DEFAULT_ERROR_MESSAGE.'27012',0),
27013 => array(DEFAULT_ERROR_MESSAGE.'27013',0),
27014 => array(DEFAULT_ERROR_MESSAGE.'27014',0),
27015 => array(DEFAULT_ERROR_MESSAGE.'27015',0),
);
?>

View File

@ -40,6 +40,7 @@ if ( !defined('IN_PHPLOGCON') )
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
@ -68,6 +69,13 @@ abstract class LogStream {
*/
public abstract function Close();
/**
* Verifies the logstream source
*
* @return integer Error stat
*/
public abstract function Verify();
/**
* Read the next data from the current stream. If it reads
* forwards or backwards depends on the current read direction.
@ -187,6 +195,13 @@ abstract class LogStream {
*/
public abstract function GetCurrentPageNumber();
/**
* This functions is used by charts/graph generator to obtain data
*
* @return integer Error stat
*/
public abstract function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit);
/**
* Gets a property and checks if the class is able to sort the records
@ -197,6 +212,14 @@ abstract class LogStream {
*/
public abstract function IsPropertySortable($myProperty);
/*
* Helper functino to trigger initialisation of MsgParsers
*/
public function RunBasicInits()
{
$this->_logStreamConfigObj->InitMsgParsers();
}
/**
* Set the filter for the current stream.
*
@ -258,6 +281,7 @@ abstract class LogStream {
{
// Split key and value
$tmpArray = explode(":", $myEntry, 2);
//print_r ( $tmpArray );
// Continue if empty filter!
if ( strlen(trim($tmpArray[FILTER_TMP_VALUE])) == 0 )
@ -265,8 +289,17 @@ abstract class LogStream {
// Check for multiple values!
if ( strpos($tmpArray[FILTER_TMP_VALUE], ",") )
$tmpValues = explode(",", $tmpArray[FILTER_TMP_VALUE]);
{
// Split by comma and fill tmp Value array
$tmpValueArray = explode(",", $tmpArray[FILTER_TMP_VALUE]);
foreach($tmpValueArray as $myValueEntry)
{
// Append to temp array
$tmpValues[] = array( FILTER_TMP_MODE => $this->SetFilterIncludeMode($myValueEntry), FILTER_TMP_VALUE => $myValueEntry );
}
}
// Handle filter based
switch( $tmpArray[FILTER_TMP_KEY] )
{
case "facility":
@ -277,16 +310,19 @@ abstract class LogStream {
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( !is_numeric($szValue) )
if ( !is_numeric($szValue[FILTER_TMP_VALUE]) )
{
$tmpFacilityCode = $this->ConvertFacilityString($szValue);
$tmpFacilityCode = $this->ConvertFacilityString($szValue[FILTER_TMP_VALUE]);
if ( $tmpFacilityCode != -1 )
$tmpValues[$mykey] = $tmpFacilityCode;
$tmpValues[$mykey][FILTER_TMP_VALUE] = $tmpFacilityCode;
}
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
{
$tmpFacilityCode = $this->ConvertFacilityString($tmpArray[FILTER_TMP_VALUE]);
@ -304,16 +340,19 @@ abstract class LogStream {
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( !is_numeric($szValue) )
if ( !is_numeric($szValue[FILTER_TMP_VALUE]) )
{
$tmpFacilityCode = $this->ConvertSeverityString($szValue);
$tmpFacilityCode = $this->ConvertSeverityString($szValue[FILTER_TMP_VALUE]);
if ( $tmpFacilityCode != -1 )
$tmpValues[$mykey] = $tmpFacilityCode;
$tmpValues[$mykey][FILTER_TMP_VALUE] = $tmpFacilityCode;
}
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
{
$tmpFacilityCode = $this->ConvertSeverityString($tmpArray[FILTER_TMP_VALUE]);
@ -331,16 +370,25 @@ abstract class LogStream {
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( !is_numeric($szValue) )
if ( !is_numeric($szValue[FILTER_TMP_VALUE]) )
{
$tmpMsgTypeCode = $this->ConvertMessageTypeString($szValue);
$tmpMsgTypeCode = $this->ConvertMessageTypeString($szValue[FILTER_TMP_VALUE]);
if ( $tmpMsgTypeCode != -1 )
$tmpValues[$mykey] = $tmpMsgTypeCode;
$tmpValues[$mykey][FILTER_TMP_VALUE] = $tmpMsgTypeCode;
}
}
foreach( $tmpValues as $mykey => $szValue )
{
// First set Filter Mode
$tmpValues[$mykey][FILTER_TMP_MODE] = $this->SetFilterIncludeMode($szValue);
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
{
$tmpMsgTypeCode = $this->ConvertMessageTypeString($tmpArray[FILTER_TMP_VALUE]);
@ -350,6 +398,30 @@ abstract class LogStream {
}
// ---
break;
case "processid":
$tmpKeyName = SYSLOG_PROCESSID;
$tmpFilterType = FILTER_TYPE_NUMBER;
// --- Extra numeric Check
if ( isset($tmpValues) )
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( is_numeric($szValue[FILTER_TMP_VALUE]) )
$tmpValues[$mykey][FILTER_TMP_VALUE] = $szValue[FILTER_TMP_VALUE];
else
$tmpValues[$mykey][FILTER_TMP_VALUE] = "";
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
$tmpArray[FILTER_TMP_VALUE] = "";
}
// ---
break;
/* BEGIN Eventlog based fields */
case "eventid":
$tmpKeyName = SYSLOG_EVENT_ID;
@ -359,12 +431,42 @@ abstract class LogStream {
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( is_numeric($szValue) )
$tmpValues[$mykey] = $szValue;
if ( is_numeric($szValue[FILTER_TMP_VALUE]) )
$tmpValues[$mykey][FILTER_TMP_VALUE] = $szValue[FILTER_TMP_VALUE];
else
$tmpValues[$mykey][FILTER_TMP_VALUE] = "";
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
$tmpArray[FILTER_TMP_VALUE] = "";
}
// ---
break;
case "eventcategory":
$tmpKeyName = SYSLOG_EVENT_CATEGORY;
$tmpFilterType = FILTER_TYPE_NUMBER;
// --- Extra numeric Check
if ( isset($tmpValues) )
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( is_numeric($szValue[FILTER_TMP_VALUE]) )
$tmpValues[$mykey][FILTER_TMP_VALUE] = $szValue[FILTER_TMP_VALUE];
else
$tmpValues[$mykey][FILTER_TMP_VALUE] = "";
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
$tmpArray[FILTER_TMP_VALUE] = "";
}
@ -378,6 +480,10 @@ abstract class LogStream {
$tmpKeyName = SYSLOG_EVENT_SOURCE;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case "eventuser":
$tmpKeyName = SYSLOG_EVENT_USER;
$tmpFilterType = FILTER_TYPE_STRING;
break;
/* END Eventlog based fields */
case "syslogtag":
$tmpKeyName = SYSLOG_SYSLOGTAG;
@ -402,6 +508,86 @@ abstract class LogStream {
$tmpFilterType = FILTER_TYPE_DATE;
$tmpTimeMode = DATEMODE_LASTX;
break;
/* BEGIN WebLog based fields */
case SYSLOG_WEBLOG_USER:
$tmpKeyName = SYSLOG_WEBLOG_USER;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_METHOD:
$tmpKeyName = SYSLOG_WEBLOG_METHOD;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_URL:
$tmpKeyName = SYSLOG_WEBLOG_URL;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_QUERYSTRING:
$tmpKeyName = SYSLOG_WEBLOG_QUERYSTRING;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_PVER:
$tmpKeyName = SYSLOG_WEBLOG_PVER;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_STATUS:
$tmpKeyName = SYSLOG_WEBLOG_STATUS;
$tmpFilterType = FILTER_TYPE_NUMBER;
// --- Extra numeric Check
if ( isset($tmpValues) )
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( is_numeric($szValue[FILTER_TMP_VALUE]) )
$tmpValues[$mykey][FILTER_TMP_VALUE] = $szValue[FILTER_TMP_VALUE];
else
$tmpValues[$mykey][FILTER_TMP_VALUE] = "";
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
$tmpArray[FILTER_TMP_VALUE] = "";
}
// ---
break;
case SYSLOG_WEBLOG_BYTESSEND:
$tmpKeyName = SYSLOG_WEBLOG_BYTESSEND;
$tmpFilterType = FILTER_TYPE_NUMBER;
// --- Extra numeric Check
if ( isset($tmpValues) )
{
foreach( $tmpValues as $mykey => $szValue )
{
if ( is_numeric($szValue[FILTER_TMP_VALUE]) )
$tmpValues[$mykey][FILTER_TMP_VALUE] = $szValue[FILTER_TMP_VALUE];
else
$tmpValues[$mykey][FILTER_TMP_VALUE] = "";
}
}
else
{
// First set Filter Mode
$tmpArray[FILTER_TMP_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( !is_numeric($tmpArray[FILTER_TMP_VALUE]) )
$tmpArray[FILTER_TMP_VALUE] = "";
}
// ---
break;
case SYSLOG_WEBLOG_REFERER:
$tmpKeyName = SYSLOG_WEBLOG_REFERER;
$tmpFilterType = FILTER_TYPE_STRING;
break;
case SYSLOG_WEBLOG_USERAGENT:
$tmpKeyName = SYSLOG_WEBLOG_USERAGENT;
$tmpFilterType = FILTER_TYPE_STRING;
break;
/* END WebLog based fields */
default:
$tmpFilterType = FILTER_TYPE_UNKNOWN;
break;
@ -422,10 +608,11 @@ abstract class LogStream {
}
else if ( isset($tmpValues) )
{
foreach( $tmpValues as $szValue )
//print_r( $tmpValues );
foreach( $tmpValues as $szValue )
{
// Continue if empty!
if ( strlen(trim($szValue)) == 0 )
if ( strlen($szValue[FILTER_TMP_VALUE]) == 0 )
continue;
if ( isset($this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]) )
@ -436,20 +623,41 @@ abstract class LogStream {
}
// Set Filter Mode
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $this->SetFilterIncludeMode($szValue);
if ( isset($szValue[FILTER_TMP_MODE]) )
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $szValue[FILTER_TMP_MODE];
else
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $this->SetFilterIncludeMode($szValue[FILTER_TMP_VALUE]);
// Set Value
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = $szValue;
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = $szValue[FILTER_TMP_VALUE];
}
}
else
{
// Set Filter Mode
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
if ( isset($tmpArray[FILTER_TMP_MODE]) )
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $tmpArray[FILTER_TMP_MODE];
else
$this->_filters[$tmpKeyName][$iNum][FILTER_MODE] = $this->SetFilterIncludeMode($tmpArray[FILTER_TMP_VALUE]);
// Set Filter value!
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = $tmpArray[FILTER_TMP_VALUE];
}
// Reverse string prepareation
$searchArray = array(
'/(?<!\+)\+/', // First one replaces all single + into spaces, but unfortunatelly replaces ONE + from a double ++
'/ (?=\+)/', // This is a helper, removes spaces if a + is following
// '/\+\+/', // Not needed, due the rules above, a double + has already become a single +
);
$replaceArray = array(
" ",
"",
// "+",
);
// $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]);
$this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = preg_replace( $searchArray, $replaceArray, $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] );
// ---
}
@ -486,25 +694,38 @@ abstract class LogStream {
*/
private function SetFilterIncludeMode(&$szValue)
{
// Set Filtermode
// Init BIT!
$myBits = FILTER_MODE_INCLUDE;
// If Filter is Included
$pos = strpos($szValue, "+");
if ( $pos !== false && $pos == 0 )
{
//trunscate +
$szValue = substr( $szValue, 1);
return FILTER_MODE_INCLUDE;
$myBits = FILTER_MODE_INCLUDE;
}
// If Filter is Excluded
$pos = strpos($szValue, "-");
if ( $pos !== false && $pos == 0 )
{
//trunscate -
$szValue = substr( $szValue, 1);
return FILTER_MODE_EXCLUDE;
$myBits = FILTER_MODE_EXCLUDE;
}
// Default is include which means +
return FILTER_MODE_INCLUDE;
// If Filter is a FULL text match!
$pos = strpos($szValue, "=");
if ( $pos !== false && $pos == 0 )
{
//trunscate -
$szValue = substr( $szValue, 1);
$myBits |= FILTER_MODE_SEARCHFULL;
}
// return result
return $myBits;
}
/*
@ -558,7 +779,6 @@ abstract class LogStream {
return -1;
}
}
?>
?>

View File

@ -48,8 +48,111 @@ abstract class LogStreamConfig {
protected $_logStreamName = '';
protected $_defaultFacility = '';
protected $_defaultSeverity = '';
// helpers properties for message parser list!
protected $_msgParserList = null; // Contains a string list of configure msg parsers
protected $_msgParserObjList = null; // Contains an object reference list to the msg parsers
protected $_MsgNormalize = 0; // If set to one, the msg will be reconstructed if successfully parsed before
// Constructor prototype
public abstract function LogStreamFactory($o);
/*
* Initialize Msg Parsers!
*/
public function InitMsgParsers()
{
// Init parsers if available and not initialized already!
if ( $this->_msgParserList != null && $this->_msgParserObjList == null )
{
// Loop through parsers
foreach( $this->_msgParserList as $szParser )
{
// Set Classname
$szClassName = "MsgParser_" . $szParser;
// Create OBjectRef!
$NewParser = new $szClassName(); // Create new instance
$NewParser->_MsgNormalize = $this->_MsgNormalize; // Copy property!
$this->_msgParserObjList[] = $NewParser; // Append NewParser to Parser array
}
}
}
/*
* Helper function to init Parserlist
*/
public function SetMsgNormalize( $nNewVal )
{
if ( $nNewVal == 0 )
$this->_MsgNormalize = 0;
else
$this->_MsgNormalize = 1;
}
/*
* Helper function to init Parserlist
*/
public function SetMsgParserList( $szParsers )
{
global $gl_root_path;
// Check if we have at least something to check
if ( $szParsers == null || strlen($szParsers) <= 0 )
return;
// Set list of Parsers!
if ( strpos($szParsers, ",") )
$aParsers = explode( ",", $szParsers );
else
$aParsers[0] = $szParsers;
// Loop through parsers
foreach( $aParsers as $szParser )
{
// Remove whitespaces
$szParser = trim($szParser);
// Check if parser file include exists
$szIncludeFile = $gl_root_path . 'classes/msgparsers/msgparser.' . $szParser . '.class.php';
if ( file_exists($szIncludeFile) )
{
// Try to include
if ( @include_once($szIncludeFile) )
$this->_msgParserList[] = $szParser;
else
OutputDebugMessage("Error, MsgParser '" . $szParser . "' could not be included. ", DEBUG_ERROR);
}
}
// print_r ( $this->_msgParserList );
}
public function ProcessMsgParsers($szMsg, &$arrArguments)
{
// Abort msgparsers if we have less then 5 seconds of processing time!
global $content, $gl_starttime;
$scriptruntime = intval(microtime_float() - $gl_starttime);
if ( $scriptruntime > ($content['MaxExecutionTime']-5) )
return ERROR_MSG_SCANABORTED;
// Process if set!
if ( $this->_msgParserObjList != null )
{
foreach( $this->_msgParserObjList as $myMsgParser )
{
// Perform Parsing, and return if was successfull or the message needs to be skipped!
// Otherwise the next Parser will be called.
$ret = $myMsgParser->ParseMsg($szMsg, $arrArguments);
if ( $ret == SUCCESS || $ret == ERROR_MSG_SKIPMESSAGE )
return $ret;
}
}
// reached this means all work is done!
return SUCCESS;
}
}
?>

View File

@ -63,7 +63,7 @@ class LogStreamConfigDisk extends LogStreamConfig {
require_once($gl_root_path . 'classes/logstreamlineparser.class.php');
// Probe if file exists then include it!
$strIncludeFile = 'classes/logstreamlineparser' . $this->LineParserType . '.class.php';
$strIncludeFile = $gl_root_path . 'classes/logstreamlineparser' . $this->LineParserType . '.class.php';
$strClassName = "LogStreamLineParser" . $this->LineParserType;
if ( is_file($strIncludeFile) )

View File

@ -84,15 +84,14 @@ class LogStreamDB extends LogStream {
{
global $dbmapping;
// Try to connect to the database
$this->_dbhandle = mysql_connect($this->_logStreamConfigObj->DBServer,$this->_logStreamConfigObj->DBUser,$this->_logStreamConfigObj->DBPassword);
if (!$this->_dbhandle)
return ERROR_DB_CONNECTFAILED;
// Initialise Basic stuff within the Classs
$this->RunBasicInits();
// Verify database connection (This also opens the database!)
$res = $this->Verify();
if ( $res != SUCCESS )
return $res;
$bRet = mysql_select_db($this->_logStreamConfigObj->DBName, $this->_dbhandle);
if(!$bRet)
return ERROR_DB_CANNOTSELECTDB;
// Copy the Property Array
$this->_arrProperties = $arrProperties;
@ -101,7 +100,9 @@ class LogStreamDB extends LogStream {
return ERROR_DB_INVALIDDBMAPPING;
// Create SQL Where Clause first!
$this->CreateSQLWhereClause();
$res = $this->CreateSQLWhereClause();
if ( $res != SUCCESS )
return $res;
// Success, this means we init the Pagenumber to ONE!
$this->_currentPageNumber = 1;
@ -121,6 +122,52 @@ class LogStreamDB extends LogStream {
return SUCCESS;
}
/**
* Verify if the database connection exists!
*
* @return integer Error state
*/
public function Verify() {
// Try to connect to the database
if ( $this->_dbhandle == null )
{
$this->_dbhandle = @mysql_connect($this->_logStreamConfigObj->DBServer,$this->_logStreamConfigObj->DBUser,$this->_logStreamConfigObj->DBPassword);
if (!$this->_dbhandle)
{
if ( isset($php_errormsg) )
{
global $extraErrorDescription;
$extraErrorDescription = $php_errormsg;
}
// Return error code
return ERROR_DB_CONNECTFAILED;
}
}
// Select the database now!
$bRet = @mysql_select_db($this->_logStreamConfigObj->DBName, $this->_dbhandle);
if(!$bRet)
{
if ( isset($php_errormsg) )
{
global $extraErrorDescription;
$extraErrorDescription = $php_errormsg;
}
// Return error code
return ERROR_DB_CANNOTSELECTDB;
}
// Check if the table exists!
$numTables = @mysql_num_rows( mysql_query("SHOW TABLES LIKE '%" . $this->_logStreamConfigObj->DBTableName . "%'"));
if( $numTables <= 0 )
return ERROR_DB_TABLENOTFOUND;
// reached this point means success ;)!
return SUCCESS;
}
/**
* Read the data from a specific uID which means in this
* case beginning with from the Database ID
@ -212,6 +259,10 @@ class LogStreamDB extends LogStream {
$arrProperitesOut[$property] = '';
}
// Run optional Message Parsers now
if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) )
$this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum;
$uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]];
@ -450,6 +501,70 @@ class LogStreamDB extends LogStream {
return false;
}
/**
* Implementation of GetCountSortedByField
*
* In the native MYSQL Logstream, the database will do most of the work
*
* @return integer Error stat
*/
public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit)
{
global $content, $dbmapping;
// Copy helper variables, this is just for better readability
$szTableType = $this->_logStreamConfigObj->DBTableType;
if ( isset($dbmapping[$szTableType][$szFieldId]) )
{
// Set DB Field name first!
$myDBFieldName = $dbmapping[$szTableType][$szFieldId];
$myDBQueryFieldName = $myDBFieldName;
$mySelectFieldName = $myDBFieldName;
// Special handling for date fields
if ( $nFieldType == FILTER_TYPE_DATE )
{
// Helper variable for the select statement
$mySelectFieldName = $mySelectFieldName . "Grouped";
$myDBQueryFieldName = "DATE( " . $myDBFieldName . ") AS " . $mySelectFieldName ;
}
// Create SQL String now!
$szSql = "SELECT " .
$myDBQueryFieldName . ", " .
"count(" . $myDBFieldName . ") as TotalCount " .
" FROM " . $this->_logStreamConfigObj->DBTableName .
" GROUP BY " . $mySelectFieldName .
" ORDER BY TotalCount DESC" .
" LIMIT " . $nRecordLimit;
// Perform Database Query
$myquery = mysql_query($szSql, $this->_dbhandle);
if ( !$myquery )
return ERROR_DB_QUERYFAILED;
// Initialize Array variable
$aResult = array();
// read data records
while ($myRow = mysql_fetch_array($myquery, MYSQL_ASSOC))
$aResult[ $myRow[$mySelectFieldName] ] = $myRow['TotalCount'];
// return finished array
if ( count($aResult) > 0 )
return $aResult;
else
return ERROR_NOMORERECORDS;
}
else
{
// return error code, field mapping not found
return ERROR_DB_DBFIELDNOTFOUND;
}
}
/*
* ============= Beginn of private functions =============
*/
@ -477,90 +592,133 @@ class LogStreamDB extends LogStream {
// Process all filters
foreach( $this->_filters[$propertyname] as $myfilter )
{
switch( $myfilter[FILTER_TYPE] )
// Only perform if database mapping is available for this filter!
if ( isset($dbmapping[$szTableType][$propertyname]) )
{
case FILTER_TYPE_STRING:
// Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE)
$addnod = "";
else
$addnod = " NOT";
switch( $myfilter[FILTER_TYPE] )
{
case FILTER_TYPE_STRING:
// --- Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
$addnod = "";
else
$addnod = " NOT";
// ---
// If Syslog message, we have AND handling, otherwise OR!
if ( $propertyname == SYSLOG_MESSAGE )
$addor = " AND ";
else
$addor = " OR ";
// Not create LIKE Filters
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
}
break;
case FILTER_TYPE_NUMBER:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . $myfilter[FILTER_VALUE];
}
break;
case FILTER_TYPE_DATE:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= " AND ";
else
{
$tmpfilters[$propertyname][FILTER_VALUE] = "";
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_DATE;
}
if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
{
// Get current timestamp
$nNowTimeStamp = time();
if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
$nNowTimeStamp -= 60 * 60; // One Hour!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
$nNowTimeStamp -= 60 * 60 * 12; // 12 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
$nNowTimeStamp -= 60 * 60 * 24; // 24 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 7; // 7 days
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 31; // 31 days
else
// --- Either make a LIKE or a equal query!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
{
// Set filter to unknown and Abort in this case!
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_UNKNOWN;
break;
$szSearchBegin = " = '";
$szSearchEnd = "' ";
}
else
{
$szSearchBegin = " LIKE '%";
$szSearchEnd = "%' ";
}
// ---
// --- If Syslog message, we have AND handling, otherwise OR!
if ( $propertyname == SYSLOG_MESSAGE )
$addor = " AND ";
else
$addor = " OR ";
// ---
// Now Create LIKE Filters
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd;
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd;
}
break;
case FILTER_TYPE_NUMBER:
// --- Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
{
// Add to filterset
$szArrayKey = $propertyname . "-NOT";
if ( isset($tmpfilters[$szArrayKey]) )
$tmpfilters[$szArrayKey][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$szArrayKey][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$szArrayKey][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " NOT IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]);
}
}
else
{
// Add to filterset
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]);
}
}
// ---
break;
case FILTER_TYPE_DATE:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= " AND ";
else
{
$tmpfilters[$propertyname][FILTER_VALUE] = "";
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_DATE;
}
// Append filter
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $nNowTimeStamp) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
{
// Get current timestamp
$nNowTimeStamp = time();
break;
default:
// Nothing to do!
break;
if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
$nNowTimeStamp -= 60 * 60; // One Hour!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
$nNowTimeStamp -= 60 * 60 * 12; // 12 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
$nNowTimeStamp -= 60 * 60 * 24; // 24 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 7; // 7 days
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 31; // 31 days
else
{
// Set filter to unknown and Abort in this case!
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_UNKNOWN;
break;
}
// Append filter
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $nNowTimeStamp) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
break;
default:
// Nothing to do!
break;
}
}
else
{
// Check how to treat not found db mappings / filters
if ( GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 0 )
return ERROR_DB_DBFIELDNOTFOUND;
}
}
}
@ -667,6 +825,7 @@ class LogStreamDB extends LogStream {
// Append LIMIT clause
$szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery;
//echo $szSql . "<br>";
// Perform Database Query
$myquery = mysql_query($szSql, $this->_dbhandle);
@ -772,9 +931,7 @@ class LogStreamDB extends LogStream {
*/
private function PrintDebugError($szErrorMsg)
{
global $CFG;
if ( isset($CFG['MiscShowDebugMsg']) && $CFG['MiscShowDebugMsg'] == 1 )
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
{
$errdesc = mysql_error();
$errno = mysql_errno();

View File

@ -73,19 +73,18 @@ class LogStreamDisk extends LogStream {
* @param arrProperties array in: Properties wish list.
* @return integer Error stat
*/
public function Open($arrProperties) {
public function Open($arrProperties)
{
// Initialise Basic stuff within the Classs
$this->RunBasicInits();
// Check if file exists!
if(!file_exists($this->_logStreamConfigObj->FileName)) {
return ERROR_FILE_NOT_FOUND;
}
// Check if file is readable!
if(!is_readable($this->_logStreamConfigObj->FileName)) {
return ERROR_FILE_NOT_READABLE;
}
$result = $this->Verify();
if ( $result != SUCCESS)
return $result;
// Now open the file
$this->_fp = fopen($this->_logStreamConfigObj->FileName, 'r');
$this->_currentOffset = ftell($this->_fp);
$this->_currentStartPos = $this->_currentOffset;
$this->_arrProperties = $arrProperties;
@ -111,6 +110,27 @@ class LogStreamDisk extends LogStream {
return SUCCESS;
}
/**
* Verify if the file exists!
*
* @return integer Error state
*/
public function Verify() {
// Check if file exists!
if(!file_exists($this->_logStreamConfigObj->FileName)) {
return ERROR_FILE_NOT_FOUND;
}
// Check if file is readable!
if(!is_readable($this->_logStreamConfigObj->FileName)) {
return ERROR_FILE_NOT_READABLE;
}
// reached this point means success ;)!
return SUCCESS;
}
private function ReadNextBlock() {
$this->_bEOS = false;
$bCheckForLastLf = false;
@ -205,6 +225,8 @@ class LogStreamDisk extends LogStream {
*/
public function ReadNext(&$uID, &$arrProperitesOut, $bParseMessage = true)
{
global $content, $gl_starttime;
do
{
// Read next entry first!
@ -212,18 +234,38 @@ class LogStreamDisk extends LogStream {
$ret = $this->ReadNextForwards($uID, $arrProperitesOut);
else
$ret = $this->ReadNextBackwards($uID, $arrProperitesOut);
// Only PARSE on success!
if ( $ret == SUCCESS && $bParseMessage)
{
// Line Parser Hook here
$this->_logStreamConfigObj->_lineParser->ParseLine($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Set uID to the PropertiesOut!
$arrProperitesOut[SYSLOG_UID] = $uID;
}
// Only PARSE on success!
if ( $ret == SUCCESS && $bParseMessage)
{
// Line Parser Hook here
$retParser = $this->_logStreamConfigObj->_lineParser->ParseLine($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Run optional Message Parsers now
$retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Loop until the filter applies, or another error occurs.
// Check if we have to skip the message!
if ( $retParser == ERROR_MSG_SKIPMESSAGE )
$ret = $retParser;
// Set uID to the PropertiesOut!
$arrProperitesOut[SYSLOG_UID] = $uID;
}
// Check how long we are running. If only two seconds of execution time are left, we abort further reading!
$scriptruntime = intval(microtime_float() - $gl_starttime);
if ( $scriptruntime > ($content['MaxExecutionTime']-2) )
{
// This may display a warning message, so the user knows we stopped reading records because of the script timeout.
$content['logstream_warning'] = "false";
$content['logstream_warning_details'] = $content['LN_WARNING_LOGSTREAMDISK_TIMEOUT'];
$content['logstream_warning_code'] = ERROR_FILE_NOMORETIME;
// Return error code
return ERROR_FILE_NOMORETIME;
}
// Loop until the filter applies, or another error occurs, and we still have TIME!
} while ( $this->ApplyFilters($ret, $arrProperitesOut) != SUCCESS && $ret == SUCCESS );
// reached here means return result!
@ -481,8 +523,10 @@ class LogStreamDisk extends LogStream {
*/
public function GetLastPageUID()
{
// Obtain last UID if enough records are available!
// Only perform lastUID scan if there are NO filters, for performance REASONS!
if ( $this->_filters != null )
return UID_UNKNOWN;
// Helper variables
$myuid = -1;
$counter = 0;
@ -550,6 +594,81 @@ class LogStreamDisk extends LogStream {
return false;
}
/**
* Implementation of GetCountSortedByField
*
* For now, the disk source needs to loop through the whole file
* to consolidate and sort the data
*
* @return integer Error stat
*/
public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit)
{
global $content;
// We loop through all loglines! this may take a while!
$uID = UID_UNKNOWN;
$ret = $this->ReadNext($uID, $logArray);
if ( $ret == SUCCESS )
{
// Initialize Array variable
$aResult = array();
// Loop through messages
do
{
if ( isset($logArray[$szFieldId]) )
{
if ( $nFieldType == FILTER_TYPE_DATE )
{
// Convert to FULL Day Date for now!
$myFieldData = date( "Y-m-d", $logArray[$szFieldId][EVTIME_TIMESTAMP] );
}
else // Just copy the value!
$myFieldData = $logArray[$szFieldId];
if ( isset($aResult[ $myFieldData ]) )
$aResult[ $myFieldData ]++;
else
{
// Initialize entry if we haven't exceeded the RecordLImit yet!
if ( count($aResult) < ($nRecordLimit-1) ) // -1 because the last entry will become all others
$aResult[ $myFieldData ] = 1;
else
{
// Count record to others
if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) )
$aResult[ $content['LN_STATS_OTHERS'] ]++;
else
$aResult[ $content['LN_STATS_OTHERS'] ] = 1;
}
}
}
} while ( ($ret = $this->ReadNext($uID, $logArray)) == SUCCESS );
// Sort Array, so the highest count comes first!
arsort($aResult);
// array_multisort($aResult, SORT_NUMERIC, SORT_DESC);
if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) )
{
// This will move the "Others" Element to the last position!
$arrEntryCopy = $aResult[ $content['LN_STATS_OTHERS'] ];
unset($aResult[ $content['LN_STATS_OTHERS'] ]);
$aResult[ $content['LN_STATS_OTHERS'] ] = $arrEntryCopy;
}
// finally return result!
if ( count($aResult) > 0 )
return $aResult;
else
return ERROR_NOMORERECORDS;
}
else
return ERROR_NOMORERECORDS;
}
/**
* Set the direction the stream should read data.
*
@ -586,7 +705,8 @@ class LogStreamDisk extends LogStream {
// IF result was unsuccessfull, return success - nothing we can do here.
if ( $myResults >= ERROR )
return SUCCESS;
// Process all filters
if ( $this->_filters != null )
{
// Evaluation default for now is true
@ -597,9 +717,9 @@ class LogStreamDisk extends LogStream {
{
// TODO: NOT SURE IF THIS WILL WORK ON NUMBERS AND OTHER TYPES RIGHT NOW
if (
array_key_exists($propertyname, $this->_filters) &&
isset($propertyvalue) &&
!(is_string($propertyvalue) && strlen($propertyvalue) <= 0 ) /* Negative because it only matters if the propvalure is a string*/
array_key_exists($propertyname, $this->_filters) &&
isset($propertyvalue) /* &&
!(is_string($propertyvalue) && strlen($propertyvalue) <= 0) /* Negative because it only matters if the propvalure is a string*/
)
{
// Extra var needed for number checks!
@ -612,35 +732,96 @@ class LogStreamDisk extends LogStream {
switch( $myfilter[FILTER_TYPE] )
{
case FILTER_TYPE_STRING:
// If Syslog message, we have AND handling!
if ( $propertyname == SYSLOG_MESSAGE )
// Only filter if value is non zero
if ( strlen($propertyvalue) > 0 && strlen($myfilter[FILTER_VALUE]) > 0 )
{
// Include Filter
if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE )
// If Syslog message, we have AND handling!
if ( $propertyname == SYSLOG_MESSAGE )
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false )
$bEval = false;
// Include Filter
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE )
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false )
$bEval = false;
}
// Exclude Filter
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
$bEval = false;
}
}
// Exclude Filter
else if ( $myfilter[FILTER_MODE] == FILTER_MODE_EXCLUDE )
// Otherwise we use OR Handling!
else
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
$bEval = false;
$bIsOrFilter = true; // Set isOrFilter to true
// Include Filter
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE )
{
if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
{
if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) )
$bOrFilter = true;
}
else
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
$bOrFilter = true;
}
}
// Exclude Filter
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
{
if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
{
if ( strtolower($propertyvalue) != strtolower($myfilter[FILTER_VALUE]) )
$bOrFilter = true;
}
else
{
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false )
$bOrFilter = true;
}
}
break;
}
}
// Otherwise we use OR Handling!
else
else
{
$bIsOrFilter = true; // Set isOrFilter to true
if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
$bOrFilter = true;
break;
// Either filter value or property value was empty!
// This means we have no match
$bEval = false;
}
break;
case FILTER_TYPE_NUMBER:
$bIsOrFilter = true; // Set to true in any case!
if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] )
$bOrFilter = true;
$bIsOrFilter = true; // Default is set to TRUE
if ( is_numeric($arrProperitesOut[$propertyname]) )
{
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE )
{
if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] )
$bOrFilter = true;
else
$bOrFilter = false;
}
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
{
if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] )
$bOrFilter = false;
else
$bOrFilter = true;
}
}
else
{
// If wanted, we treat this filter as a success!
if ( GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 1 )
$bOrFilter = true;
else
$bOrFilter = false;
}
break;
case FILTER_TYPE_DATE:
// Get Log TimeStamp
@ -664,6 +845,7 @@ class LogStreamDisk extends LogStream {
else
// WTF default?
$nLastXTime = 86400;
// If Nowtime + LastX is higher then the log timestamp, the this logline is to old for us.
if ( ($nNowTimeStamp - $nLastXTime) > $nLogTimeStamp )
$bEval = false;
@ -671,7 +853,7 @@ class LogStreamDisk extends LogStream {
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
{
// Get filter timestamp!
$nFromTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
$nFromTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
// If logtime is smaller then FromTime, then the Event is outside of our scope!
if ( $nLogTimeStamp < $nFromTimeStamp )
@ -701,7 +883,7 @@ class LogStreamDisk extends LogStream {
if ( !$bEval )
{
// unmatching filter, rest property array
// unmatching filter, reset property array
foreach ( $this->_arrProperties as $property )
$arrProperitesOut[$property] = '';

View File

@ -57,4 +57,4 @@ abstract class LogStreamLineParser {
}
?>
?>

View File

@ -0,0 +1,77 @@
<?php
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* Dummy LogStream Parser Class for all other logfile types handeled
* by msg parsers
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution.
*********************************************************************
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
class LogStreamLineParsermisc extends LogStreamLineParser {
// protected $_arrProperties = null;
// Constructor
public function LogStreamLineParsermisc() {
return; // Nothing
}
/**
* ParseLine
*
* @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
* @return integer Error stat
*/
public function ParseLine($szLine, &$arrArguments)
{
// Set MSG Property
$arrArguments[SYSLOG_MESSAGE] = $szLine;
// Set IUT Property
$arrArguments[SYSLOG_MESSAGETYPE] = IUT_Unknown;
// Return success!
return SUCCESS;
}
}
?>

View File

@ -127,7 +127,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
else
{
if ( isset($arrArguments[SYSLOG_MESSAGE]) && strlen($arrArguments[SYSLOG_MESSAGE]) > 0 )
OutputDebugMessage("Unparseable syslog msg - '" . $arrArguments[SYSLOG_MESSAGE] . "'");
OutputDebugMessage("Unparseable syslog msg - '" . $arrArguments[SYSLOG_MESSAGE] . "'", DEBUG_ERROR);
}
// If SyslogTag is set, we check for MessageType!
@ -144,4 +144,4 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
}
?>
?>

View File

@ -66,7 +66,7 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
$arrArguments[SYSLOG_MESSAGETYPE] = IUT_Syslog;
// Sample (WinSyslog/EventReporter): 2008-04-02,15:19:06,2008-04-02,15:19:06,127.0.0.1,16,5,EvntSLog: Performance counters for the RSVP (QoS RSVP) service were loaded successfully.
if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?):(.*?)$/", $szLine, $out ) )
if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}.[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}.[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?):(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
$arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
@ -76,7 +76,7 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
$arrArguments[SYSLOG_SYSLOGTAG] = $out[6];
$arrArguments[SYSLOG_MESSAGE] = $out[7];
}
else if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?)$/", $szLine, $out ) )
else if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}.[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}.[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
$arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
@ -88,7 +88,7 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
else
{
if ( isset($arrArguments[SYSLOG_MESSAGE]) && strlen($arrArguments[SYSLOG_MESSAGE]) > 0 )
OutputDebugMessage("Unparseable Winsyslog message - '" . $arrArguments[SYSLOG_MESSAGE] . "'");
OutputDebugMessage("Unparseable Winsyslog message - '" . $arrArguments[SYSLOG_MESSAGE] . "'", DEBUG_ERROR);
}
// If SyslogTag is set, we check for MessageType!
@ -105,4 +105,4 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
}
?>
?>

View File

@ -87,38 +87,14 @@ class LogStreamPDO extends LogStream {
{
global $dbmapping;
// Create DSN String
$myDBDriver = $this->_logStreamConfigObj->GetPDODatabaseType();
$myDsn = $this->_logStreamConfigObj->CreateConnectDSN();
if ( strlen($myDsn) > 0 )
{
// Check if configured driver is actually loaded!
//print_r(PDO::getAvailableDrivers());
if ( !in_array($myDBDriver, PDO::getAvailableDrivers()) )
{
$this->PrintDebugError('PDO Database Driver not loaded: ' . $myDBDriver . "<br>Please check your php configuration extensions");
return ERROR_DB_INVALIDDBDRIVER;
}
// Initialise Basic stuff within the Classs
$this->RunBasicInits();
try
{
// Try to connect to the database
$this->_dbhandle = new PDO( $myDsn, $this->_logStreamConfigObj->DBUser, $this->_logStreamConfigObj->DBPassword);
// Verify database driver and connection (This also opens the database!)
$res = $this->Verify();
if ( $res != SUCCESS )
return $res;
//$handle->setAttribute(PDO::ATTR_TIMEOUT, 3);
}
catch (PDOException $e)
{
$this->PrintDebugError('PDO Database Connection failed: ' . $e->getMessage() . "<br>DSN: " . $myDsn);
return ERROR_DB_CONNECTFAILED;
}
}
else
{
// Invalid DB Driver!
return ERROR_DB_INVALIDDBDRIVER;
}
// Copy the Property Array
$this->_arrProperties = $arrProperties;
@ -127,7 +103,9 @@ class LogStreamPDO extends LogStream {
return ERROR_DB_INVALIDDBMAPPING;
// Create SQL Where Clause first!
$this->CreateSQLWhereClause();
$res = $this->CreateSQLWhereClause();
if ( $res != SUCCESS )
return $res;
// Only obtain rowcount if enabled and not done before
if ( $this->_logStreamConfigObj->DBEnableRowCounting && $this->_totalRecordCount == -1 )
@ -155,6 +133,73 @@ class LogStreamPDO extends LogStream {
return true;
}
/**
* Verify if the database connection exists!
*
* @return integer Error state
*/
public function Verify() {
// Create DSN String
$myDBDriver = $this->_logStreamConfigObj->GetPDODatabaseType();
$myDsn = $this->_logStreamConfigObj->CreateConnectDSN();
if ( strlen($myDsn) > 0 )
{
// Check if configured driver is actually loaded!
//print_r(PDO::getAvailableDrivers());
if ( !in_array($myDBDriver, PDO::getAvailableDrivers()) )
{
global $extraErrorDescription;
$extraErrorDescription = "PDO Database Driver not loaded: " . $myDBDriver . "<br>Please check your php configuration extensions";
// $this->PrintDebugError($extraErrorDescription);
// return error code
return ERROR_DB_INVALIDDBDRIVER;
}
try
{
// Try to connect to the database
$this->_dbhandle = new PDO( $myDsn, $this->_logStreamConfigObj->DBUser, $this->_logStreamConfigObj->DBPassword /*, array(PDO::ATTR_TIMEOUT =>25)*/);
//$this->_dbhandle->setAttribute(PDO::ATTR_TIMEOUT, 25);
}
catch (PDOException $e)
{
global $extraErrorDescription;
$extraErrorDescription = "PDO Database Connection failed: " . $e->getMessage() . "<br>DSN: " . $myDsn;
// $this->PrintDebugError($extraErrorDescription);
// return error code
return ERROR_DB_CONNECTFAILED;
}
try
{
// This is one way to check if the table exists! But I don't really like it tbh -.-
$tmpStmnt = $this->_dbhandle->prepare("SELECT ID FROM " . $this->_logStreamConfigObj->DBTableName . " WHERE ID=1");
$tmpStmnt->execute();
$colcount = $tmpStmnt->columnCount();
if ( $colcount <= 0 )
return ERROR_DB_TABLENOTFOUND;
}
catch (PDOException $e)
{
global $extraErrorDescription;
$extraErrorDescription = "Could not find table: " . $e->getMessage();
// return error code
return ERROR_DB_TABLENOTFOUND;
}
}
else
{
// Invalid DB Driver!
return ERROR_DB_INVALIDDBDRIVER;
}
// reached this point means success ;)!
return SUCCESS;
}
/**
* Read the data from a specific uID which means in this
* case beginning with from the Database ID
@ -213,11 +258,12 @@ class LogStreamPDO extends LogStream {
// Set new Record start, will be used in the SQL Statement!
$this->_currentRecordStart = $this->_currentRecordNum; // + 1;
// Now read new ones
$ret = $this->ReadNextRecordsFromDB($uID);
//echo "1mowl " . $this->_currentRecordStart . "=" . $this->_currentRecordNum;
//echo "!" . $ret . " " . $this->_currentRecordStart . "=" . $this->_currentRecordNum;
// Check if we found more records
if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) )
$ret = ERROR_NOMORERECORDS;
}
@ -247,6 +293,10 @@ class LogStreamPDO extends LogStream {
$arrProperitesOut[$property] = '';
}
// Run optional Message Parsers now
if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) )
$this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum;
$uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]];
@ -460,6 +510,91 @@ class LogStreamPDO extends LogStream {
return false;
}
/**
* Implementation of GetCountSortedByField
*
* In the PDO DB Logstream, the database will do most of the work
*
* @return integer Error stat
*/
public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit)
{
global $content, $dbmapping;
// Copy helper variables, this is just for better readability
$szTableType = $this->_logStreamConfigObj->DBTableType;
if ( isset($dbmapping[$szTableType][$szFieldId]) )
{
// Set DB Field name first!
$myDBFieldName = $dbmapping[$szTableType][$szFieldId];
$myDBQueryFieldName = $myDBFieldName;
$mySelectFieldName = $myDBFieldName;
// Special handling for date fields
if ( $nFieldType == FILTER_TYPE_DATE )
{
if ( $this->_logStreamConfigObj->DBType == DB_MYSQL ||
$this->_logStreamConfigObj->DBType == DB_PGSQL )
{
// Helper variable for the select statement
$mySelectFieldName = $mySelectFieldName . "grouped";
$myDBQueryFieldName = "DATE( " . $myDBFieldName . ") AS " . $mySelectFieldName ;
}
else if($this->_logStreamConfigObj->DBType == DB_MSSQL )
{
// TODO FIND A WAY FOR MSSQL!
}
}
// Create SQL String now!
$szSql = "SELECT " .
$myDBQueryFieldName . ", " .
"count(" . $myDBFieldName . ") as totalcount " .
" FROM " . $this->_logStreamConfigObj->DBTableName .
" GROUP BY " . $mySelectFieldName .
" ORDER BY totalcount DESC";
// Append LIMIT in this case!
if ( $this->_logStreamConfigObj->DBType == DB_MYSQL ||
$this->_logStreamConfigObj->DBType == DB_PGSQL )
$szSql .= " LIMIT " . $nRecordLimit;
// Perform Database Query
$this->_myDBQuery = $this->_dbhandle->query($szSql);
if ( !$this->_myDBQuery )
return ERROR_DB_QUERYFAILED;
if ( $this->_myDBQuery->rowCount() == 0 )
return ERROR_NOMORERECORDS;
// Initialize Array variable
$aResult = array();
// read data records
$iCount = 0;
while ( ($myRow = $this->_myDBQuery->fetch(PDO::FETCH_ASSOC)) && $iCount < $nRecordLimit)
{
if ( isset($myRow[$mySelectFieldName]) )
{
$aResult[ $myRow[$mySelectFieldName] ] = $myRow['totalcount'];
$iCount++;
}
}
// return finished array
if ( count($aResult) > 0 )
return $aResult;
else
return ERROR_NOMORERECORDS;
}
else
{
// return error code, field mapping not found
return ERROR_DB_DBFIELDNOTFOUND;
}
}
/*
* ============= Beginn of private functions =============
*/
@ -487,90 +622,133 @@ class LogStreamPDO extends LogStream {
// Process all filters
foreach( $this->_filters[$propertyname] as $myfilter )
{
switch( $myfilter[FILTER_TYPE] )
// Only perform if database mapping is available for this filter!
if ( isset($dbmapping[$szTableType][$propertyname]) )
{
case FILTER_TYPE_STRING:
// Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE)
$addnod = "";
else
$addnod = " NOT";
switch( $myfilter[FILTER_TYPE] )
{
case FILTER_TYPE_STRING:
// --- Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
$addnod = "";
else
$addnod = " NOT";
// ---
// If Syslog message, we have AND handling, otherwise OR!
if ( $propertyname == SYSLOG_MESSAGE )
$addor = " AND ";
else
$addor = " OR ";
// Not create LIKE Filters
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
}
break;
case FILTER_TYPE_NUMBER:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . $myfilter[FILTER_VALUE];
}
break;
case FILTER_TYPE_DATE:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= " AND ";
else
{
$tmpfilters[$propertyname][FILTER_VALUE] = "";
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_DATE;
}
if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
{
// Get current timestamp
$nNowTimeStamp = time();
if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
$nNowTimeStamp -= 60 * 60; // One Hour!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
$nNowTimeStamp -= 60 * 60 * 12; // 12 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
$nNowTimeStamp -= 60 * 60 * 24; // 24 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 7; // 7 days
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 31; // 31 days
else
// --- Either make a LIKE or a equal query!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL )
{
// Set filter to unknown and Abort in this case!
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_UNKNOWN;
break;
$szSearchBegin = " = '";
$szSearchEnd = "' ";
}
else
{
$szSearchBegin = " LIKE '%";
$szSearchEnd = "%' ";
}
// ---
// --- If Syslog message, we have AND handling, otherwise OR!
if ( $propertyname == SYSLOG_MESSAGE )
$addor = " AND ";
else
$addor = " OR ";
// ---
// Not create LIKE Filters
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd;
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd;
}
break;
case FILTER_TYPE_NUMBER:
// --- Check if user wants to include or exclude!
if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE )
{
// Add to filterset
$szArrayKey = $propertyname . "-NOT";
if ( isset($tmpfilters[$szArrayKey]) )
$tmpfilters[$szArrayKey][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$szArrayKey][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$szArrayKey][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " NOT IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]);
}
}
else
{
// Add to filterset
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
else
{
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER;
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]);
}
}
// ---
break;
case FILTER_TYPE_DATE:
if ( isset($tmpfilters[$propertyname]) )
$tmpfilters[$propertyname][FILTER_VALUE] .= " AND ";
else
{
$tmpfilters[$propertyname][FILTER_VALUE] = "";
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_DATE;
}
// Append filter
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $nNowTimeStamp) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
{
// Get current timestamp
$nNowTimeStamp = time();
break;
default:
// Nothing to do!
break;
if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
$nNowTimeStamp -= 60 * 60; // One Hour!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
$nNowTimeStamp -= 60 * 60 * 12; // 12 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
$nNowTimeStamp -= 60 * 60 * 24; // 24 Hours!
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 7; // 7 days
else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
$nNowTimeStamp -= 60 * 60 * 24 * 31; // 31 days
else
{
// Set filter to unknown and Abort in this case!
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_UNKNOWN;
break;
}
// Append filter
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $nNowTimeStamp) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
{
// Obtain Event struct for the time!
$myeventtime = GetEventTime($myfilter[FILTER_VALUE]);
$tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'";
}
break;
default:
// Nothing to do!
break;
}
}
else
{
// Check how to treat not found db mappings / filters
if ( GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 0 )
return ERROR_DB_DBFIELDNOTFOUND;
}
}
}
@ -621,13 +799,23 @@ class LogStreamPDO extends LogStream {
private function CreateMainSQLQuery($uID)
{
global $querycount;
// create query if necessary!
if ( $this->_myDBQuery == null )
// if ( $this->_myDBQuery == null )
{
// Get SQL Statement
$szSql = $this->CreateSQLStatement($uID);
// --- Append LIMIT if supported by the driver! Why the hell do we still have no unified solution for this crap in the sql language?!
if ( $this->_logStreamConfigObj->DBType == DB_MYSQL )
$szSql .= " LIMIT " . $this->_logStreamConfigObj->RecordsPerQuery;
// $szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery;
else if ( $this->_logStreamConfigObj->DBType == DB_PGSQL )
$szSql .= " LIMIT " . $this->_logStreamConfigObj->RecordsPerQuery;
// $szSql .= " LIMIT " . $this->_logStreamConfigObj->RecordsPerQuery . " OFFSET " . $this->_currentRecordStart;
// echo $szSql . "<br>";
// ---
// Perform Database Query
$this->_myDBQuery = $this->_dbhandle->query($szSql);
if ( !$this->_myDBQuery )
@ -635,6 +823,16 @@ class LogStreamPDO extends LogStream {
$this->PrintDebugError( "Invalid SQL: ".$szSql . "<br><br>Errorcode: " . $this->_dbhandle->errorCode() );
return ERROR_DB_QUERYFAILED;
}
else
{
// Skip one entry in this case
if ( $this->_currentRecordStart > 0 )
{
// Throw away
$myRow = $this->_myDBQuery->fetch(PDO::FETCH_ASSOC);
}
}
// Increment for the Footer Stats
$querycount++;
@ -653,7 +851,7 @@ class LogStreamPDO extends LogStream {
if ( $this->_myDBQuery != null )
{
// Free Query ressources
// $this->_myDBQuery->closeCursor();
$this->_myDBQuery->closeCursor();
$this->_myDBQuery = null;
}
@ -666,8 +864,11 @@ class LogStreamPDO extends LogStream {
*/
private function ReadNextRecordsFromDB($uID)
{
// Clear SQL Query first!
$this->DestroyMainSQLQuery();
// Create query if necessary
if ( $this->_myDBQuery == null )
// if ( $this->_myDBQuery == null )
{
// return error if there was one!
if ( ($res = $this->CreateMainSQLQuery($uID)) != SUCCESS )
@ -788,8 +989,7 @@ class LogStreamPDO extends LogStream {
*/
private function PrintDebugError($szErrorMsg)
{
global $CFG;
if ( isset($CFG['MiscShowDebugMsg']) && $CFG['MiscShowDebugMsg'] == 1 )
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
{
$errdesc = $this->_dbhandle == null ? "" : implode( ";", $this->_dbhandle->errorInfo() );
$errno = $this->_dbhandle == null ? "" : $this->_dbhandle->errorCode();

View File

@ -0,0 +1,60 @@
<?php
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* LogStream MSGParser abstract basic class *
* *
* All directives are explained within this file *
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution.
*********************************************************************
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
abstract class MsgParser{
public $_MsgNormalize = 0; // If set to one, the msg will be reconstructed if successfully parsed before
/**
* ParseLine
*
* @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
* @return integer Error stat
*/
public abstract function ParseMsg($szMsg, &$arrArguments);
}
?>

View File

@ -0,0 +1,146 @@
<?php
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* Apache Logfile Parser used to split WebLog fields if found
* in the msg
* *
* All directives are explained within this file *
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution.
*********************************************************************
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
class MsgParser_apache2 extends MsgParser {
// protected $_arrProperties = null;
// Constructor
public function MsgParser_apache2() {
return; // Nothing
}
/**
* ParseLine
*
* @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
* @return integer Error stat
*/
public function ParseMsg($szMsg, &$arrArguments)
{
global $content, $fields;
//return ERROR_MSG_NOMATCH;
// LogFormat "%h %l %u %t \"%r\" %>s %b" common
// LogFormat "%{Referer}i -> %U" referer
// LogFormat "%{User-agent}i" agent
// LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
// Sample (apache2): 127.0.0.1 - - [14/Sep/2008:06:50:15 +0200] "GET / HTTP/1.0" 200 19023 "-" "VoilaBot link checker"
// Sample: 65.55.211.112 - - [16/Sep/2008:13:37:47 +0200] "GET /index.php?name=News&file=article&sid=1&theme=Printer HTTP/1.1" 200 4908 "-" "msnbot/1.1 (+http://search.msn.com/msnbot.htm)"
if ( preg_match('/(.|.*?) (.|.*?) (.|.*?) \[(.*?)\] "(.*?) (.*?) (.*?)" (.|[0-9]{1,12}) (.|[0-9]{1,12}) "(.|.*?)" "(.*?)("|)$/', $szMsg, $out ) )
{
// print_r ( $out );
// exit;
// Set generic properties
$arrArguments[SYSLOG_HOST] = $out[1];
$arrArguments[SYSLOG_DATE] = GetEventTime($out[4]);
// Set weblog specific properties!
$arrArguments[SYSLOG_WEBLOG_USER] = $out[3];
$arrArguments[SYSLOG_WEBLOG_METHOD] = $out[5];
if ( strpos($out[6], "?") === false )
{
$arrArguments[SYSLOG_WEBLOG_URL] = $out[6];
$arrArguments[SYSLOG_WEBLOG_QUERYSTRING]= "";
}
else
{
$arrArguments[SYSLOG_WEBLOG_URL] = substr( $out[6], 0, strpos($out[6], "?"));
$arrArguments[SYSLOG_WEBLOG_QUERYSTRING]= substr( $out[6], strpos($out[6], "?")+1 );
}
// $arrArguments[SYSLOG_WEBLOG_QUERYSTRING] = $out[7];
$arrArguments[SYSLOG_WEBLOG_PVER] = $out[7];
$arrArguments[SYSLOG_WEBLOG_STATUS] = $out[8];
$arrArguments[SYSLOG_WEBLOG_BYTESSEND] = $out[9];
$arrArguments[SYSLOG_WEBLOG_REFERER] = $out[10];
$arrArguments[SYSLOG_WEBLOG_USERAGENT] = $out[11];
// Set msg to whole logline
$arrArguments[SYSLOG_MESSAGE] = $out[0];
if ( $this->_MsgNormalize == 1 )
{
//Init tmp msg
$szTmpMsg = "";
// Create Field Array to prepend into msg! Reverse Order here
$myFields = array( SYSLOG_WEBLOG_USER, SYSLOG_WEBLOG_PVER, SYSLOG_WEBLOG_USERAGENT, SYSLOG_WEBLOG_BYTESSEND, SYSLOG_WEBLOG_STATUS, SYSLOG_WEBLOG_REFERER, SYSLOG_WEBLOG_METHOD, SYSLOG_WEBLOG_QUERYSTRING, SYSLOG_WEBLOG_URL );
foreach ( $myFields as $myField )
{
// Set Field Caption
if ( isset($content[ $fields[$myField]['FieldCaptionID'] ]) )
$szFieldName = $content[ $fields[$myField]['FieldCaptionID'] ];
else
$szFieldName = $fields[$myField]['FieldCaptionID'];
// Append Field into msg
$szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg;
}
// copy finished MSG back!
$arrArguments[SYSLOG_MESSAGE] = $szTmpMsg;
}
}
else
{
// return no match in this case!
return ERROR_MSG_NOMATCH;
}
// Set IUT Property if success!
$arrArguments[SYSLOG_MESSAGETYPE] = IUT_WEBSERVERLOG;
// If we reached this position, return success!
return SUCCESS;
}
}
?>

View File

@ -0,0 +1,118 @@
<?php
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* EventLog MSG Parser is used to split EventLog fields if found
* in the msg
* *
* All directives are explained within this file *
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution.
*********************************************************************
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
class MsgParser_eventlog extends MsgParser {
// protected $_arrProperties = null;
// Constructor
public function MsgParser_eventlog() {
return; // Nothing
}
/**
* ParseLine
*
* @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
* @return integer Error stat
*/
public function ParseMsg($szMsg, &$arrArguments)
{
global $content, $fields;
// Sample (WinSyslog/EventReporter): 7035,XPVS2005\Administrator,Service Control Manager,System,[INF],0,The Adiscon EvntSLog service was successfully sent a start control.
// Source: %id%,%user%,%sourceproc%,%NTEventLogType%,%severity%,%category%,%msg%%$CRLF%
if ( preg_match("/([0-9]{1,12}),(.*?),(.*?),(.*?),(.*?),([0-9]{1,12}),(.*?)$/", $szMsg, $out ) )
{
// Copy parsed properties!
$arrArguments[SYSLOG_EVENT_ID] = $out[1];
$arrArguments[SYSLOG_EVENT_USER] = $out[2];
$arrArguments[SYSLOG_EVENT_SOURCE] = $out[3];
$arrArguments[SYSLOG_EVENT_LOGTYPE] = $out[4];
/// $arrArguments[SYSLOG_SEVERITY] = $out[5];
$arrArguments[SYSLOG_EVENT_CATEGORY] = $out[6];
$arrArguments[SYSLOG_MESSAGE] = $out[7];
if ( $this->_MsgNormalize == 1 )
{
//Init tmp msg
$szTmpMsg = "";
// Create Field Array to prepend into msg! Reverse Order here
$myFields = array( SYSLOG_MESSAGE, SYSLOG_EVENT_CATEGORY, SYSLOG_EVENT_LOGTYPE, SYSLOG_EVENT_SOURCE, SYSLOG_EVENT_USER, SYSLOG_EVENT_ID );
foreach ( $myFields as $myField )
{
// Set Field Caption
if ( isset($content[ $fields[$myField]['FieldCaptionID'] ]) )
$szFieldName = $content[ $fields[$myField]['FieldCaptionID'] ];
else
$szFieldName = $fields[$myField]['FieldCaptionID'];
// Append Field into msg
$szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg;
}
// copy finished MSG back!
$arrArguments[SYSLOG_MESSAGE] = $szTmpMsg;
}
}
else
{
// return no match in this case!
return ERROR_MSG_NOMATCH;
}
// Set IUT Property if success!
$arrArguments[SYSLOG_MESSAGETYPE] = IUT_NT_EventReport;
// If we reached this position, return success!
return SUCCESS;
}
}
?>

View File

@ -0,0 +1,155 @@
<?php
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* Microsoft IIS Logfile Parser used to split WebLog fields if found
* in the msg
* *
* All directives are explained within this file *
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution.
*********************************************************************
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
class MsgParser_iis extends MsgParser {
// protected $_arrProperties = null;
// Constructor
public function MsgParser_iis() {
return; // Nothing
}
/**
* ParseLine
*
* @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them.
* @return integer Error stat
*/
public function ParseMsg($szMsg, &$arrArguments)
{
global $content, $fields;
// $iSharpPos = strpos($szMsg, "#");
// if ( $iSharpPos !== false && $iSharpPos == 0 )
// return ERROR_MSG_SKIPMESSAGE;
// Special case here, if loglines start with #, they are comments and have to be skipped!
if ( ($iSharpPos = strpos($szMsg, "#")) !== false && $iSharpPos == 0 )
{
// Only init fields then
// Set generic properties
$arrArguments[SYSLOG_DATE] = "";
$arrArguments[SYSLOG_HOST] = "";
// Set weblog specific properties!
$arrArguments[SYSLOG_WEBLOG_METHOD] = "";
$arrArguments[SYSLOG_WEBLOG_URL] = "";
$arrArguments[SYSLOG_WEBLOG_QUERYSTRING] = "";
$arrArguments[SYSLOG_WEBLOG_USER] = "";
$arrArguments[SYSLOG_WEBLOG_PVER] = "";
$arrArguments[SYSLOG_WEBLOG_USERAGENT] = "";
$arrArguments[SYSLOG_WEBLOG_REFERER] = "";
$arrArguments[SYSLOG_WEBLOG_STATUS] = "";
$arrArguments[SYSLOG_WEBLOG_BYTESSEND] = "";
// Set msg to whole logline
$arrArguments[SYSLOG_MESSAGE] = $szMsg;
}
// LogFormat: date time cs-method cs-uri-stem cs-uri-query cs-username c-ip cs-version cs(User-Agent) cs(Referer) sc-status sc-bytes
// Sample: 2008-09-17 00:15:24 GET /Include/MyStyleV2.css - - 208.111.154.249 HTTP/1.0 Mozilla/5.0+(X11;+U;+Linux+i686+(x86_64);+en-US;+rv:1.8.1.11)+Gecko/20080109+(Charlotte/0.9t;+http://www.searchme.com/support/) http://www.adiscon.com/Common/en/News/MWCon-2005-09-12.php 200 1812
if ( preg_match('/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}) (.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?) (.|.*?)$/', $szMsg, $out ) )
{
// print_r ( $out );
// exit;
// Set generic properties
$arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[6];
// Set weblog specific properties!
$arrArguments[SYSLOG_WEBLOG_METHOD] = $out[2];
$arrArguments[SYSLOG_WEBLOG_URL] = $out[3];
$arrArguments[SYSLOG_WEBLOG_QUERYSTRING]= $out[4];
$arrArguments[SYSLOG_WEBLOG_USER] = $out[5];
$arrArguments[SYSLOG_WEBLOG_PVER] = $out[7];
$arrArguments[SYSLOG_WEBLOG_USERAGENT] = $out[8];
$arrArguments[SYSLOG_WEBLOG_REFERER] = $out[9];
$arrArguments[SYSLOG_WEBLOG_STATUS] = $out[10];
$arrArguments[SYSLOG_WEBLOG_BYTESSEND] = $out[11];
// Set msg to whole logline
$arrArguments[SYSLOG_MESSAGE] = $out[0];
if ( $this->_MsgNormalize == 1 )
{
//Init tmp msg
$szTmpMsg = "";
// Create Field Array to prepend into msg! Reverse Order here
$myFields = array( SYSLOG_WEBLOG_USER, SYSLOG_WEBLOG_PVER, SYSLOG_WEBLOG_USERAGENT, SYSLOG_WEBLOG_BYTESSEND, SYSLOG_WEBLOG_STATUS, SYSLOG_WEBLOG_REFERER, SYSLOG_WEBLOG_METHOD, SYSLOG_WEBLOG_QUERYSTRING, SYSLOG_WEBLOG_URL );
foreach ( $myFields as $myField )
{
// Set Field Caption
if ( isset($content[ $fields[$myField]['FieldCaptionID'] ]) )
$szFieldName = $content[ $fields[$myField]['FieldCaptionID'] ];
else
$szFieldName = $fields[$myField]['FieldCaptionID'];
// Append Field into msg
$szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg;
}
// copy finished MSG back!
$arrArguments[SYSLOG_MESSAGE] = $szTmpMsg;
}
}
else
{
// return no match in this case!
return ERROR_MSG_NOMATCH;
}
// Set IUT Property if success!
$arrArguments[SYSLOG_MESSAGETYPE] = IUT_WEBSERVERLOG;
// If we reached this position, return success!
return SUCCESS;
}
}
?>

277
src/convert.php Normal file
View File

@ -0,0 +1,277 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Configuration Converter File
*
* -> Helps to convert from config file to userdb if desired
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
define('IN_PHPLOGCON_CONVERT', true); // Extra for CONVERT Script!
define('STEPSCRIPTNAME', "convert.php"); // Helper variable for the STEP helper functions
$gl_root_path = './';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_installhelpers.php');
// This site can not require LOGIN
define('IS_NOLOGINPAGE', true);
$content['IS_NOLOGINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
// --- PreCheck if conversion is allowed!
if (
GetConfigSetting("UserDBEnabled", false) &&
GetConfigSetting("UserDBConvertAllowed", false)
)
{
// Setup static values
define('MAX_STEPS', 6);
$content['web_theme'] = "default";
$content['user_theme'] = "default";
}
else
DieWithErrorMsg( $content['LN_CONVERT_ERRORINSTALLED'] );
// ---
// --- CONTENT Vars
$content['TITLE'] = "phpLogCon :: " . $content['LN_CONVERT_TITLE'];
// ---
// --- Read Vars
if ( isset($_GET['step']) )
{
$content['CONVERT_STEP'] = intval(DB_RemoveBadChars($_GET['step']));
if ( $content['CONVERT_STEP'] > MAX_STEPS )
$content['CONVERT_STEP'] = 1;
}
else
$content['CONVERT_STEP'] = 1;
// Set Next Step
$content['CONVERT_NEXT_STEP'] = $content['CONVERT_STEP'];
if ( MAX_STEPS > $content['CONVERT_STEP'] )
{
$content['NEXT_ENABLED'] = "true";
$content['FINISH_ENABLED'] = "false";
$content['CONVERT_NEXT_STEP']++;
}
else
{
$content['NEXT_ENABLED'] = "false";
$content['FINISH_ENABLED'] = "true";
}
// ---
// --- BEGIN Custom Code
// Set Bar Images
$content['BarImagePlus'] = $gl_root_path . "images/bars/bar-middle/green_middle_17.png";
$content['BarImageLeft'] = $gl_root_path . "images/bars/bar-middle/green_left_17.png";
$content['BarImageRight'] = $gl_root_path . "images/bars/bar-middle/green_right_17.png";
$content['WidthPlus'] = intval( $content['CONVERT_STEP'] * (100 / MAX_STEPS) ) - 8;
$content['WidthPlusText'] = "Installer Step " . $content['CONVERT_STEP'];
// --- Set Title
$content['TITLE'] = GetAndReplaceLangStr( $content['TITLE'], $content['CONVERT_STEP'] );
$content['LN_CONVERT_TITLETOP'] = GetAndReplaceLangStr( $content['LN_CONVERT_TITLETOP'], $content['CONVERT_STEP'] );
// ---
// --- Start Setup Processing
if ( $content['CONVERT_STEP'] == 2 )
{
// Check the database connect
$link_id = mysql_connect( GetConfigSetting("UserDBServer"), GetConfigSetting("UserDBUser"), GetConfigSetting("UserDBPass") );
if (!$link_id)
RevertOneStep( $content['CONVERT_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORCONNECTFAILED'], GetConfigSetting("UserDBServer") . "<br>" . DB_ReturnSimpleErrorMsg() ) );
// Try to select the DB!
$db_selected = mysql_select_db(GetConfigSetting("UserDBName"), $link_id);
if(!$db_selected)
RevertOneStep( $content['CONVERT_STEP']-1,GetAndReplaceLangStr( $content['LN_INSTALL_ERRORACCESSDENIED'], GetConfigSetting("UserDBName") . "<br>" . DB_ReturnSimpleErrorMsg() ) );
}
else if ( $content['CONVERT_STEP'] == 3 )
{
// Predefine sql helper vars
$content['sql_sucess'] = 0;
$content['sql_failed'] = 0;
// Init $totaldbdefs
$totaldbdefs = "";
// Read the table GLOBAL definitions
ImportDataFile( $content['BASEPATH'] . "include/db_template.txt" );
// Process definitions ^^
if ( strlen($totaldbdefs) <= 0 )
{
$content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = GetAndReplaceLangStr( $content['LN_INSTALL_ERRORINVALIDDBFILE'], $content['BASEPATH'] . "include/db_template.txt");
$content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = "";
$content['sql_failed']++;
}
// Replace stats_ with the custom one ;)
$totaldbdefs = str_replace( "`logcon_", "`" . GetConfigSetting("UserDBPref"), $totaldbdefs );
// Now split by sql command
$mycommands = split( ";\n", $totaldbdefs );
// // check for different linefeed
// if ( count($mycommands) <= 1 )
// $mycommands = split( ";\n", $totaldbdefs );
//Still only one? Abort
if ( count($mycommands) <= 1 )
{
$content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = GetAndReplaceLangStr( $content['LN_INSTALL_ERRORINSQLCOMMANDS'], $content['BASEPATH'] . "include/db_template.txt");
$content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = "";
$content['sql_failed']++;
}
// Append INSERT Statement for Config Table to set the Database Version ^^!
$mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', " . $content['database_internalversion'] . ")";
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
// Establish DB Connection
DB_Connect();
for($i = 0; $i < count($mycommands); $i++)
{
if ( strlen(trim($mycommands[$i])) > 1 )
{
$result = DB_Query( $mycommands[$i], false );
if ($result == FALSE)
{
$content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = DB_ReturnSimpleErrorMsg();
$content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = $mycommands[$i];
// --- Set CSS Class
if ( $content['sql_failed'] % 2 == 0 )
$content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line1";
else
$content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line2";
// ---
$content['sql_failed']++;
}
else
$content['sql_sucess']++;
// Free result
DB_FreeQuery($result);
}
}
}
else if ( $content['CONVERT_STEP'] == 4 )
{
if ( isset($_SESSION['MAIN_Username']) )
$content['MAIN_Username'] = $_SESSION['MAIN_Username'];
else
$content['MAIN_Username'] = "";
$content['MAIN_Password1'] = "";
$content['MAIN_Password2'] = "";
// Check for Error Msg
if ( isset($_GET['errormsg']) )
{
$content['iserror'] = "true";
$content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) );
}
}
else if ( $content['CONVERT_STEP'] == 5 )
{
// Verify Username and Password Input
if ( isset($_POST['username']) )
$_SESSION['MAIN_Username'] = DB_RemoveBadChars($_POST['username']);
else
RevertOneStep( $content['CONVERT_STEP']-1, $content['LN_INSTALL_MISSINGUSERNAME'] );
if ( isset($_POST['password1']) )
$_SESSION['MAIN_Password1'] = DB_RemoveBadChars($_POST['password1']);
else
$_SESSION['MAIN_Password1'] = "";
if ( isset($_POST['password2']) )
$_SESSION['MAIN_Password2'] = DB_RemoveBadChars($_POST['password2']);
else
$_SESSION['MAIN_Password2'] = "";
if (
strlen($_SESSION['MAIN_Password1']) < 4 ||
$_SESSION['MAIN_Password1'] != $_SESSION['MAIN_Password2']
)
RevertOneStep( $content['CONVERT_STEP']-1, $content['LN_INSTALL_PASSWORDNOTMATCH'] );
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
// Establish DB Connection
DB_Connect();
// Everything is fine, lets go create the User!
CreateUserName( $_SESSION['MAIN_Username'], $_SESSION['MAIN_Password1'], 1 );
// Show User success!
$content['MAIN_Username'] = $_SESSION['MAIN_Username'];
$content['createduser'] = true;
}
else if ( $content['CONVERT_STEP'] == 6 )
{
// To be on the save side, establish DB Connection
DB_Connect();
// Perform conversion of settings into the database now!
ConvertCustomSearches();
ConvertCustomViews();
ConvertCustomSources();
// Import General Settings in the last step!
ConvertGeneralSettings();
}
// ---
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "convert.html");
$page -> output();
// ---
// --- Helper functions
// ---
?>

View File

@ -22,6 +22,12 @@
display: none;
}
.ShownContent
{
visibility: visible;
display: inline;
}
.SelectSavedFilter
{
margin-top: 2px;
@ -81,3 +87,17 @@
{
height: 16px;
}
.borderless
{
border:0px solid;
background-color: transparent;
}
.borderlessbuttons
{
border:0px solid;
background-color: transparent;
width:20px;
padding: 0px;
}

View File

@ -50,7 +50,7 @@
position: absolute;
top: 12px;
left: 4px; /* to position them to the right of their containing block */
width: 350; /* width is based on the containing block */
width: 400; /* width is based on the containing block */
}
div#menu ul ul,

View File

@ -245,9 +245,9 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING )
{
if ( $mycolkey == SYSLOG_MESSAGE )
$content['fields'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes($logArray[$mycolkey]);
$content['fields'][$mycolkey]['fieldvalue'] = ReplaceLineBreaksInString( GetStringWithHTMLCodes($logArray[$mycolkey]) );
else // kindly copy!
$content['fields'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey];
$content['fields'][$mycolkey]['fieldvalue'] = ReplaceLineBreaksInString( $logArray[$mycolkey] );
// --- HOOK here to add context links!
AddContextLinks($content['fields'][$mycolkey]['fieldvalue']);
@ -348,12 +348,11 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
$content['error_code'] = $ret;
if ( $ret == ERROR_FILE_NOT_FOUND )
$content['detailederror'] = "Syslog file could not be found.";
$content['detailederror'] = $content['LN_ERROR_FILE_NOT_FOUND'];
else if ( $ret == ERROR_FILE_NOT_READABLE )
$content['detailederror'] = "Syslog file is not readable, read access may be denied. ";
$content['detailederror'] = $content['LN_ERROR_FILE_NOT_READABLE'];
else
$content['detailederror'] = "Unknown or unhandeled error occured.";
$content['detailederror'] = $content['LN_ERROR_UNKNOWN'];
}
// Close file!

425
src/export.php Normal file
View File

@ -0,0 +1,425 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Export Code File
*
* -> Exports data from a search and site into a data format
*
* All directives are explained within this file
*
* Copyright (C) 2008 Adiscon GmbH.
*
* This file is part of phpLogCon.
*
* PhpLogCon 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 3 of the License, or
* (at your option) any later version.
*
* PhpLogCon 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 phpLogCon. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this
* distribution
*********************************************************************
*/
// *** Default includes and procedures *** //
define('IN_PHPLOGCON', true);
$gl_root_path = './';
// Now include necessary include files!
include($gl_root_path . 'include/functions_common.php');
include($gl_root_path . 'include/functions_frontendhelpers.php');
include($gl_root_path . 'include/functions_filters.php');
// Include LogStream facility
include($gl_root_path . 'classes/logstream.class.php');
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// ---
// --- READ CONTENT Vars
if ( isset($_GET['uid']) )
$content['uid_current'] = intval($_GET['uid']);
else
$content['uid_current'] = UID_UNKNOWN;
// Read direction parameter
if ( isset($_GET['direction']) && $_GET['direction'] == "desc" )
$content['read_direction'] = EnumReadDirection::Forward;
else
$content['read_direction'] = EnumReadDirection::Backward;
// If direction is DESC, should we SKIP one?
if ( isset($_GET['skipone']) && $_GET['skipone'] == "true" )
$content['skipone'] = true;
else
$content['skipone'] = false;
// Init variables
$content['searchstr'] = "";
$content['error_occured'] = false;
// Check required input parameters
if (
(isset($_GET['op']) && $_GET['op'] == "export") &&
(isset($_GET['exporttype']) && array_key_exists($_GET['exporttype'], $content['EXPORTTYPES']))
)
{
$content['exportformat'] = $_GET['exporttype'];
/*
// Check for extensions
if ( $content['exportformat'] == EXPORT_PDF && !$content['PDF_IS_ENABLED'] )
{
$content['error_occured'] = true;
$content['error_details'] = $content['LN_GEN_ERROR_PDFMISSINGEXTENSION'];
}
*/
}
else
{
$content['error_occured'] = true;
$content['error_details'] = $content['LN_GEN_ERROR_INVALIDEXPORTTYPE'];
}
// ---
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
// Append custom title part!
if ( isset($content['searchstr']) && strlen($content['searchstr']) > 0 )
$content['TITLE'] .= " :: Results for the search '" . $content['searchstr'] . "'"; // Append search
else
$content['TITLE'] .= " :: Syslogmessages";
// --- END CREATE TITLE
// --- Read and process filters from search dialog!
if ( (isset($_POST['search']) || isset($_GET['search'])) || (isset($_POST['filter']) || isset($_GET['filter'])) )
{
// Copy search over
if ( isset($_POST['search']) )
$mysearch = $_POST['search'];
else if ( isset($_GET['search']) )
$mysearch = $_GET['search'];
if ( isset($_POST['filter']) )
$myfilter = $_POST['filter'];
else if ( isset($_GET['filter']) )
$myfilter = $_GET['filter'];
// Message is just appended
if ( isset($myfilter) && strlen($myfilter) > 0 )
$content['searchstr'] = $myfilter;
}
// ---
// --- BEGIN Custom Code
if ( !$content['error_occured'] )
{
if ( isset($content['Sources'][$currentSourceID]) )
{
// Obtain and get the Config Object
$stream_config = $content['Sources'][$currentSourceID]['ObjRef'];
// Create LogStream Object
$stream = $stream_config->LogStreamFactory($stream_config);
$stream->SetFilter($content['searchstr']);
// Copy current used columns here!
$content['Columns'] = $content['Views'][$currentViewID]['Columns'];
// --- Init the fields we need
foreach($content['Columns'] as $mycolkey)
{
if ( isset($fields[$mycolkey]) )
{
$content['fields'][$mycolkey]['FieldID'] = $mycolkey;
$content['fields'][$mycolkey]['FieldCaption'] = $content[ $fields[$mycolkey]['FieldCaptionID'] ];
$content['fields'][$mycolkey]['FieldType'] = $fields[$mycolkey]['FieldType'];
$content['fields'][$mycolkey]['DefaultWidth'] = $fields[$mycolkey]['DefaultWidth'];
}
}
// ---
$res = $stream->Open( $content['Columns'], true );
if ( $res == SUCCESS )
{
// TODO Implement ORDER
$stream->SetReadDirection($content['read_direction']);
// Set current ID and init Counter
$uID = $content['uid_current'];
$counter = 0;
// If uID is known, we need to init READ first - this will also seek for available records first!
if ($uID != UID_UNKNOWN)
{
// First read will also set the start position of the Stream!
$ret = $stream->Read($uID, $logArray);
}
else
$ret = $stream->ReadNext($uID, $logArray);
// --- Check if Read was successfull!
if ( $ret == SUCCESS )
{
// If Forward direction is used, we need to SKIP one entry!
if ( $content['read_direction'] == EnumReadDirection::Forward )
{
if ( $content['skipone'] )
{
// Skip this entry and move to the next
$stream->ReadNext($uID, $logArray);
}
}
}
else
{
// This will disable to Main SyslogView and show an error message
$content['error_occured'] = true;
$content['error_details'] = $content['LN_ERROR_NORECORDS'];
}
// ---
// We found matching records, so continue
if ( $ret == SUCCESS )
{
//Loop through the messages!
do
{
// --- Extra stuff for suppressing messages
if (
GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1
&&
isset($logArray[SYSLOG_MESSAGE])
)
{
if ( !isset($szLastMessage) ) // Only set lastmgr
$szLastMessage = $logArray[SYSLOG_MESSAGE];
else
{
// Skip if same msg
if ( $szLastMessage == $logArray[SYSLOG_MESSAGE] )
{
// Set last mgr
$szLastMessage = $logArray[SYSLOG_MESSAGE];
// Skip entry
continue;
}
}
}
// ---
// --- Now we populate the values array!
foreach($content['Columns'] as $mycolkey)
{
if ( isset($fields[$mycolkey]) && isset($logArray[$mycolkey]) )
{
// Set defaults
$content['syslogmessages'][$counter][$mycolkey]['FieldColumn'] = $mycolkey;
$content['syslogmessages'][$counter][$mycolkey]['uid'] = $uID;
// Copy value as it is first!
$content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = $logArray[$mycolkey];
// Now handle fields types differently
if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE )
{
$content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]);
}
else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER )
{
// Special style classes and colours for SYSLOG_FACILITY
if ( $mycolkey == SYSLOG_FACILITY )
{
if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0)
{
// Set Human readable Facility!
$content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] );
}
}
else if ( $mycolkey == SYSLOG_SEVERITY )
{
if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0)
{
// Set Human readable Facility!
$content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] );
}
}
else if ( $mycolkey == SYSLOG_MESSAGETYPE )
{
if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) )
{
// Set Human readable Facility!
$content['syslogmessages'][$counter][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] );
}
}
}
/*
else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING )
{
}
*/
}
}
// ---
// Increment Counter
$counter++;
} while ($counter < $content['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS);
if ( $content['read_direction'] == EnumReadDirection::Forward )
{
// Back Button was clicked, so we need to flip the array
$content['syslogmessages'] = array_reverse ( $content['syslogmessages'] );
}
// DEBUG
//print_r ( $content['syslogmessages'] );
}
}
else
{
// This will disable to Main SyslogView and show an error message
$content['error_occured'] = true;
$content['error_details'] = GetErrorMessage($res);
if ( isset($extraErrorDescription) )
$content['error_details'] .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
// Close file!
$stream->Close();
}
else
{
$content['error_occured'] = true;
$content['error_details'] = GetAndReplaceLangStr( $content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID);
}
}
// ---
// --- Convert and Output
if ( $content['error_occured'] )
{
InitTemplateParser();
$page -> parser($content, "export.html");
$page -> output();
}
else
{
// Create a CVS File!
$szOutputContent = "";
$szOutputMimeType = "text/plain";
$szOutputCharset = "";
$szOutputFileName = "ExportMessages";
$szOutputFileExtension = ".txt";
if ( $content['exportformat'] == EXPORT_CVS )
{
// Set MIME TYPE and File Extension
$szOutputMimeType = "text/csv";
$szOutputFileExtension = ".csv";
// Set Column line in cvs file!
foreach($content['Columns'] as $mycolkey)
{
if ( isset($fields[$mycolkey]) )
{
// Prepend Comma if needed
if (strlen($szOutputContent) > 0)
$szOutputContent .= ",";
// Append column name
$szOutputContent .= $content[ $fields[$mycolkey]['FieldCaptionID'] ];
}
}
// Append line break
$szOutputContent .= "\n";
// Append messages into output
foreach ( $content['syslogmessages'] as $myIndex => $mySyslogMessage )
{
$szLine = "";
// --- Process columns
foreach($mySyslogMessage as $myColkey => $mySyslogField)
{
// Prepend Comma if needed
if (strlen($szLine) > 0)
$szLine .= ",";
// Append field contents
$szLine .= '"' . str_replace('"', '\\"', $mySyslogField['fieldvalue']) . '"';
}
// ---
// Append line!
$szOutputContent .= $szLine . "\n";
}
}
else if ( $content['exportformat'] == EXPORT_XML )
{
// Set MIME TYPE and File Extension
$szOutputMimeType = "application/xml";
$szOutputFileExtension = ".xml";
$szOutputCharset = "charset=UTF-8";
// Create XML Header and first node!!
$szOutputContent .= "\xef\xbb\xbf";
$szOutputContent .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$szOutputContent .= "<syslogmessages>\n";
// Append messages into output
foreach ( $content['syslogmessages'] as $myIndex => $mySyslogMessage )
{
$szXmlLine = "\t<syslogmsg>\n";
// --- Process columns
foreach($mySyslogMessage as $myColkey => $mySyslogField)
{
// if ( isset($content[ $fields[$mycolkey]['FieldCaptionID'] ]) )
// $szNodeTitle = $content[ $fields[$mycolkey]['FieldCaptionID'] ];
// else
// Append field content | first run htmlentities,tnen utf8 encoding!!
$szXmlLine .= "\t\t<" . $myColkey . ">" . utf8_encode( htmlentities($mySyslogField['fieldvalue']) ) . "</" . $myColkey . ">\n";
}
// ---
$szXmlLine .= "\t</syslogmsg>\n";
// Append line!
$szOutputContent .= $szXmlLine;
}
// End first XML Node
$szOutputContent .= "</syslogmessages>";
}
// Set needed Header properties
header('Content-type: ' . $szOutputMimeType . "; " . $szOutputCharset);
header("Content-Length: " . strlen($szOutputContent) );
header('Content-Disposition: attachment; filename="' . $szOutputFileName . $szOutputFileExtension . '"');
// Output Content!
print( $szOutputContent );
}
// ---
?>

BIN
src/images/icons/books.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 875 B

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

BIN
src/images/icons/earth.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

BIN
src/images/icons/find.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

BIN
src/images/icons/gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/images/icons/help.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 B

BIN
src/images/icons/help2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

BIN
src/images/icons/help3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

View File

@ -37,7 +37,11 @@ if ( !defined('IN_PHPLOGCON') )
}
// ---
// --- Database options
// --- UserDB options
/* If UserDB is enabled, all options will and have to be configured in the database.
* All Options below the UserDB options here will not be used, unless a setting
* is missing in the database.
*/
$CFG['UserDBEnabled'] = false;
$CFG['UserDBServer'] = "";
$CFG['UserDBPort'] = 3306;
@ -45,20 +49,26 @@ $CFG['UserDBName'] = "";
$CFG['UserDBPref'] = "";
$CFG['UserDBUser'] = "";
$CFG['UserDBPass'] = "";
$CFG['UserDBLoginRequired'] = false;
// ---
// --- Misc Options
$CFG['MiscShowDebugMsg'] = 0; // if enabled, you will get additional output on certain places
$CFG['MiscDebugToSyslog'] = 0; // if enabled, debug messages from phpLogCon will be send to syslog on linux, and into the EventLog on Windows
$CFG['MiscShowDebugGridCounter'] = 0; // Only for debugging purposes, will add a counter column into the grid!
$CFG["MiscShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings
$CFG['MiscEnableGzipCompression'] = 1; // If enabled, phplogcon will use gzip compression for output, we recommend
// to have this option enabled, it will highly reduce bandwith usage.
$CFG['MiscMaxExecutionTime'] = 30; // phpLogCon will try to overwrite the default script timeout with this value during runtime!
// This can of course only work if phpLogCon is allowed to changed the script timeout.
$CFG['DebugUserLogin'] = 0; // if enabled, you will see additional informations on failed logins
// ---
// --- Default Frontend Options
$CFG['PrependTitle'] = ""; // If set, this text will be prepended withint the title tag
$CFG['ViewUseTodayYesterday'] = 1; // If enabled, the date from today and yesterday is displayed as "today" and "yesterday"
$CFG['ViewMessageCharacterLimit'] = 80; // Default character limit for the message gets trunscated.
$CFG['ViewMessageCharacterLimit'] = 80; // Default character limit for the message gets trunscated! 0 means NO trunscation.
$CFG['ViewStringCharacterLimit'] = 30; // Default character limit for all other string type fields before they get trunscated! 0 means NO trunscation.
$CFG['ViewEntriesPerPage'] = 50; // Default number of syslog entries shown per page
$CFG['ViewEnableDetailPopups'] = 1; // If enabled, you will see additional Details for each syslog message on mouse over.
$CFG['ViewDefaultTheme'] = "default"; // This sets the default theme the user is going to see when he opens phplogcon the first time.
@ -70,6 +80,9 @@ $CFG['SearchCustomButtonCaption'] = "I'd like to feel sad"; // Default caption f
$CFG['SearchCustomButtonSearch'] = "error"; // Default search string for the custom search button
$CFG['EnableIPAddressResolve'] = 1; // If enabled, IP Addresses inline messages are automatically resolved and the result is added in brackets {} behind the IP Address
$CFG['SuppressDuplicatedMessages'] = 0; // If enabled, duplicated messages will be suppressed in the main display.
$CFG['TreatNotFoundFiltersAsTrue'] = 0; // If you filter / search for messages, and the fields you are filtering for is not found, the filter result is treaten as TRUE!
$CFG['PopupMenuTimeout'] = 3000; // This variable defines the default timeout value for popup menus in milliseconds. (those menus which popup when you click on the value of a field.
// ---
// --- Define which fields you want to see
@ -90,18 +103,28 @@ $CFG['Search'][] = array ( "DisplayName" => "All messages from last 31 days", "S
// $CFG['Search'][] = array ( "DisplayName" => "", "SearchQuery" => "" );
// ---
// --- Predefined Charts!
$CFG['Charts'][] = array ( "DisplayName" => "Top Hosts", "chart_type" => CHART_BARS_HORIZONTAL, "chart_width" => 400, "chart_field" => SYSLOG_HOST, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 );
$CFG['Charts'][] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 );
$CFG['Charts'][] = array ( "DisplayName" => "Severity Occurences", "chart_type" => CHART_BARS_VERTICAL, "chart_width" => 400, "chart_field" => SYSLOG_SEVERITY, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 );
$CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 );
// ---
// --- Source Options
/* Example for DiskType Source:
$CFG['Sources']['Source1']['ID'] = "Source1";
$CFG['Sources']['Source1']['Name'] = "Syslog Disk File";
$CFG['Sources']['Source1']['SourceType'] = SOURCE_DISK;
$CFG['Sources']['Source1']['LogLineType'] = "syslog";
$CFG['Sources']['Source1']['MsgParserList'] = "";
$CFG['Sources']['Source1']['MsgNormalize'] = 0;
$CFG['Sources']['Source1']['DiskFile'] = "/var/log/syslog";
$CFG['Sources']['Source1']['ViewID'] = "SYSLOG";
$CFG['Sources']['Source2']['ID'] = "Source5";
$CFG['Sources']['Source2']['Name'] = "WinSyslog DB";
$CFG['Sources']['Source2']['SourceType'] = SOURCE_DB;
$CFG['Sources']['Source1']['MsgParserList'] = "";
$CFG['Sources']['Source2']['DBTableType'] = "winsyslog";
$CFG['Sources']['Source2']['DBType'] = DB_MYSQL;
$CFG['Sources']['Source2']['DBServer'] = "localhost";

View File

@ -45,10 +45,13 @@ define('ERROR_FILE_NOT_FOUND', 2);
define('ERROR_FILE_CANT_CLOSE', 3);
define('ERROR_FILE_EOF', 4);
define('ERROR_FILE_BOF', 5);
define('ERROR_FILE_NOT_READABLE', 15);
define('ERROR_FILE_NOMORETIME', 22);
define('ERROR_UNDEFINED', 6);
define('ERROR_EOS', 7);
define('ERROR_NOMORERECORDS', 8);
define('ERROR_FILTER_NOT_MATCH', 9);
define('ERROR_SOURCENOTFOUND', 24);
define('ERROR_DB_CONNECTFAILED', 10);
define('ERROR_DB_CANNOTSELECTDB', 11);
@ -56,8 +59,12 @@ define('ERROR_DB_QUERYFAILED', 12);
define('ERROR_DB_NOPROPERTIES', 13);
define('ERROR_DB_INVALIDDBMAPPING', 14);
define('ERROR_DB_INVALIDDBDRIVER', 16);
define('ERROR_DB_TABLENOTFOUND', 17);
define('ERROR_DB_DBFIELDNOTFOUND', 19);
define('ERROR_FILE_NOT_READABLE', 15);
define('ERROR_MSG_NOMATCH', 18);
define('ERROR_CHARTS_NOTCONFIGURED', 20);
define('ERROR_MSG_SKIPMESSAGE', 21);
define('ERROR_MSG_SCANABORTED', 23);
?>

View File

@ -58,13 +58,15 @@ define('DATE_LASTX_31DAYS', 5);
// Helper constants needed for parsing filters
define('FILTER_TMP_KEY', 0);
define('FILTER_TMP_VALUE', 1);
define('FILTER_TMP_MODE', 2);
define('FILTER_DATEMODE', 'datemode');
define('FILTER_TYPE', 'filtertype');
define('FILTER_DATEMODENAME', 'datemodename');
define('FILTER_VALUE', 'value');
define('FILTER_MODE', 'filtermode');
define('FILTER_MODE_INCLUDE', 0);
define('FILTER_MODE_EXCLUDE', 1);
define('FILTER_MODE_INCLUDE', 1);
define('FILTER_MODE_EXCLUDE', 2);
define('FILTER_MODE_SEARCHFULL', 4);
// --- Init Facility LIST
$content['filter_facility_list'][] = array( "ID" => SYSLOG_KERN, "DisplayName" => "KERN", "selected" => "" );
@ -109,5 +111,6 @@ $content['filter_severity_list'][] = array( "ID" => SYSLOG_DEBUG, "DisplayName"
$content['filter_messagetype_list'][] = array( "ID" => IUT_Syslog, "DisplayName" => "Syslog", "selected" => "" );
$content['filter_messagetype_list'][] = array( "ID" => IUT_NT_EventReport, "DisplayName" => "WinEventLog", "selected" => "" );
$content['filter_messagetype_list'][] = array( "ID" => IUT_File_Monitor, "DisplayName" => "File Monitor", "selected" => "" );
$content['filter_messagetype_list'][] = array( "ID" => IUT_WEBSERVERLOG, "DisplayName" => "Webserver Logfile", "selected" => "" );
?>

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