summaryrefslogtreecommitdiff
path: root/html/includes
diff options
context:
space:
mode:
Diffstat (limited to 'html/includes')
-rwxr-xr-xhtml/includes/config.php65
-rw-r--r--html/includes/css/themes/tooltipster-light.css12
-rw-r--r--html/includes/css/themes/tooltipster-noir.css12
-rw-r--r--html/includes/css/themes/tooltipster-punk.css12
-rw-r--r--html/includes/css/themes/tooltipster-shadow.css12
-rw-r--r--html/includes/css/tooltipster.css283
-rw-r--r--html/includes/encoding.php304
-rwxr-xr-xhtml/includes/footer.php2
-rwxr-xr-xhtml/includes/ftptimestamp.php2
-rwxr-xr-xhtml/includes/header.php25
-rw-r--r--html/includes/js/adapters/standalone-framework.js18
-rw-r--r--html/includes/js/clickrows.js8
-rw-r--r--html/includes/js/clocks.js561
-rw-r--r--html/includes/js/highcharts-3d.js45
-rw-r--r--html/includes/js/highcharts-all.js471
-rw-r--r--html/includes/js/highcharts-functions.js1
-rw-r--r--html/includes/js/highcharts-more.js53
-rw-r--r--html/includes/js/highcharts.js308
-rw-r--r--html/includes/js/jquery-1.11.1.min.js4
-rw-r--r--html/includes/js/jquery.tooltipster.min.js1
-rw-r--r--html/includes/js/modules/canvas-tools.js133
-rw-r--r--html/includes/js/modules/data.js24
-rw-r--r--html/includes/js/modules/drilldown.js15
-rw-r--r--html/includes/js/modules/exporting.js23
-rw-r--r--html/includes/js/modules/funnel.js13
-rw-r--r--html/includes/js/modules/heatmap.js23
-rw-r--r--html/includes/js/modules/multicolor_series.js567
-rw-r--r--html/includes/js/modules/no-data-to-display.js12
-rw-r--r--html/includes/js/modules/solid-gauge.js13
-rw-r--r--html/includes/js/themes/dark-blue.js254
-rw-r--r--html/includes/renderer-ctf.php264
-rw-r--r--html/includes/renderer-dm.php252
-rw-r--r--html/includes/renderer-dom.php396
-rw-r--r--html/includes/renderer-general-import.php168
-rw-r--r--html/includes/renderer-general-output.php195
-rwxr-xr-xhtml/includes/teamstats.php12
36 files changed, 4545 insertions, 18 deletions
diff --git a/html/includes/config.php b/html/includes/config.php
index 7b086f6..11f069b 100755
--- a/html/includes/config.php
+++ b/html/includes/config.php
@@ -16,7 +16,8 @@ $import_homedir = '';
// Use the MySQL temporary tables feature?
// Available since MySQL 3.23 - requires CREATE TEMPORARY TABLE privilege since 4.0.2
-$import_use_temporary_tables = true; // set to true if available
+// No longer supported from UTStats version 4.3 onwards. Left here for historical purposes.
+$import_use_temporary_tables = false; // DON'T USE IF YOU DON'T KNOW WHAT YOU'RE DOING!
// Use temporary heap tables?
// This will (at any cost) keep the entire table in RAM and may speed and/or fuck things up
@@ -41,7 +42,6 @@ $import_log_backup = "yes";
// Purge old logs after x days. 0 to disable.
$import_log_backups_purge_after = 0;
-
// After how many seconds should we reload the import page?
// This is to prevent the 'maximum execution time exeeded' error. It will reload
// the page after the amount of seconds you specify in order to bypass php's time limit.
@@ -140,6 +140,7 @@ $pic_enable = true;
// FTP Connection Details
$ftp_use = false; // Whether to auto get the log files
$ftp_interval = 0; // How often in minutes to allow stats update
+$ftp_debug = false; // Debugging output that may help you to resolve ftp problems
$ftp_type = 'sockets'; // Which FTP module do you want to use?
// sockets - (recommended)
// Use PHP's socket extension to connect to the FTP server
@@ -150,9 +151,6 @@ $ftp_type = 'sockets'; // Which FTP module do you want to use?
// Debugging will not be available with this module and
// error handling may not be as good as with the other modules
-$ftp_debug = false; // Debugging output that may help you to resolve ftp problems
-
-
// UT Server 1
$i = 0;
$ftp_hostname[$i] = ''; // FTP server location here
@@ -183,4 +181,61 @@ $ftp_passive[$i] = true; // Use passive transfer mode for this connection?
$ftp_delete[$i] = true; // Delete logs after download?
*/
+// This section is for stats graphs as of version 4.3
+$renderer_folder = "renderings";
+$renderer_width = 350;
+$renderer_heigth = 250;
+$renderer_color['team'][0][0] = '#ff3333'; // team red color 1
+$renderer_color['team'][0][1] = '#cc0000'; // team red color 2
+$renderer_color['team'][1][0] = '#0080ff'; // team blue color 1
+$renderer_color['team'][1][1] = '#0000cc'; // team blue color 2
+$renderer_color['team'][2][0] = '#88d8b0'; // team green color 1
+$renderer_color['team'][2][1] = '#009f50'; // team green color 2
+$renderer_color['team'][3][0] = '#ffeead'; // team gold color 1
+$renderer_color['team'][3][1] = '#e5b021'; // team gold color 2
+$renderer_color['player'][0][0] = '#a7d848'; // player 1 color 1
+$renderer_color['player'][0][1] = '#98be44'; // player 1 color 2
+$renderer_color['player'][1][0] = '#6ccdd0'; // player 2 color 1
+$renderer_color['player'][1][1] = '#66af9f'; // player 2 color 2
+$renderer_color['player'][2][0] = '#ffce59'; // player 3 color 1
+$renderer_color['player'][2][1] = '#ffa65a'; // player 3 color 2
+$renderer_color['player'][3][0] = '#fba263'; // player 4 color 1
+$renderer_color['player'][3][1] = '#eb7254'; // player 4 color 2
+$renderer_color['player'][4][0] = '#fb6370 '; // player 5 color 1
+$renderer_color['player'][4][1] = '#fb6363'; // player 5 color 2
+$renderer_color['background'] = '#262626';// background color 1
+$renderer_color['band'][0] = '#666666';// band color 1
+$renderer_color['band'][1] = '#515151';// band color 2
+$renderer_color['heading'] = '#bbdeff';// font heading
+$renderer_color['font'] = '#999999';// font other
+$renderer_color['amp'] = '#aa02db';// color amp
+$renderer_color_transparancy = 0.3;// color amp
+
+define("TIMERATIO", 1.09863333333333333333333333333333333333333333333333333333333);
+
+define("RENDERER_CHARTTYPE_LINE", "line");
+define("RENDERER_CHARTTYPE_COLUMN", "column");
+define("RENDERER_CHARTTYPE_BAR", "bar");
+define("RENDERER_CHARTTYPE_LINESTEP", "linestep");
+define("RENDERER_CHARTTYPE_LINECOLUMN", "linecolumn");
+define("RENDERER_CHARTTYPE_LINESTEPCOLUMN", "linestepcolumn");
+define("RENDERER_CHARTTYPE_RADAR", "radar");
+
+define("RENDERER_CHART_CTF_TEAMSCORE", 10);
+define("RENDERER_CHART_CTF_GRABBREAKDOWN", 11);
+
+define("RENDERER_CHART_DOM_SCOREDERIV", 21);
+
+define("RENDERER_CHART_FRAGS_TEAMSCORE", 90);
+define("RENDERER_CHART_FRAGS_TEAMDERIV", 91);
+define("RENDERER_CHART_FRAGS_TEAMNORMAL", 92);
+define("RENDERER_CHART_FRAGS_PLAYERSCORE", 93);
+define("RENDERER_CHART_FRAGS_PLAYERDERIV", 94);
+define("RENDERER_CHART_FRAGS_PLAYERNORMAL", 95);
+define("RENDERER_CHART_FRAGS_PLAYERSCORE5", 96);
+define("RENDERER_CHART_FRAGS_PLAYERNORMAL5", 97);
+
+define("RENDERER_CHART_ITEMS_TEAMPICKUPS", 100);
+define("RENDERER_CHART_ITEMS_PLAYERPICKUPS", 101);
+define("RENDERER_CHART_ITEMS_AMPRUNS", 102);
?>
diff --git a/html/includes/css/themes/tooltipster-light.css b/html/includes/css/themes/tooltipster-light.css
new file mode 100644
index 0000000..945aa69
--- /dev/null
+++ b/html/includes/css/themes/tooltipster-light.css
@@ -0,0 +1,12 @@
+.tooltipster-light {
+ border-radius: 5px;
+ border: 1px solid #cccccc;
+ background: #ededed;
+ color: #666666;
+}
+.tooltipster-light .tooltipster-content {
+ font-family: Arial, sans-serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+} \ No newline at end of file
diff --git a/html/includes/css/themes/tooltipster-noir.css b/html/includes/css/themes/tooltipster-noir.css
new file mode 100644
index 0000000..548b245
--- /dev/null
+++ b/html/includes/css/themes/tooltipster-noir.css
@@ -0,0 +1,12 @@
+.tooltipster-noir {
+ border-radius: 0px;
+ border: 3px solid #2c2c2c;
+ background: #fff;
+ color: #2c2c2c;
+}
+.tooltipster-noir .tooltipster-content {
+ font-family: 'Georgia', serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+} \ No newline at end of file
diff --git a/html/includes/css/themes/tooltipster-punk.css b/html/includes/css/themes/tooltipster-punk.css
new file mode 100644
index 0000000..0b7362c
--- /dev/null
+++ b/html/includes/css/themes/tooltipster-punk.css
@@ -0,0 +1,12 @@
+.tooltipster-punk {
+ border-radius: 5px;
+ border-bottom: 3px solid #f71169;
+ background: #2a2a2a;
+ color: #fff;
+}
+.tooltipster-punk .tooltipster-content {
+ font-family: 'Courier', monospace;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+} \ No newline at end of file
diff --git a/html/includes/css/themes/tooltipster-shadow.css b/html/includes/css/themes/tooltipster-shadow.css
new file mode 100644
index 0000000..e869c5e
--- /dev/null
+++ b/html/includes/css/themes/tooltipster-shadow.css
@@ -0,0 +1,12 @@
+.tooltipster-shadow {
+ border-radius: 5px;
+ background: #fff;
+ box-shadow: 0px 0px 14px rgba(0,0,0,0.3);
+ color: #2c2c2c;
+}
+.tooltipster-shadow .tooltipster-content {
+ font-family: 'Arial', sans-serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+} \ No newline at end of file
diff --git a/html/includes/css/tooltipster.css b/html/includes/css/tooltipster.css
new file mode 100644
index 0000000..14c70d0
--- /dev/null
+++ b/html/includes/css/tooltipster.css
@@ -0,0 +1,283 @@
+/* This is the default Tooltipster theme (feel free to modify or duplicate and create multiple themes!): */
+.tooltipster-default {
+ border-radius: 5px;
+ border: 1px solid #1e1e1e;
+ background: -webkit-linear-gradient(#3b383b, #1e1e1e); /* For Safari 5.1 to 6.0 */
+ background: -o-linear-gradient(#3b383b, #1e1e1e); /* For Opera 11.1 to 12.0 */
+ background: -moz-linear-gradient(#3b383b, #1e1e1e); /* For Firefox 3.6 to 15 */
+ background: linear-gradient(#3b383b, #1e1e1e); /* Standard syntax */
+ color: #fff;
+ cursor: pointer;
+ -webkit-box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75);
+ -moz-box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75);
+ box-shadow: 10px 10px 26px -10px rgba(0,0,0,0.75);
+ max-width: 400px;
+}
+
+/* Use this next selector to style things like font-size and line-height: */
+.tooltipster-default .tooltipster-content {
+ font-family: GothamLight, sans-serif;
+ font-size: 14px;
+ line-height: 16px;
+ padding: 8px 10px;
+ overflow: hidden;
+}
+
+/* This next selector defines the color of the border on the outside of the arrow. This will automatically match the color and size of the border set on the main tooltip styles. Set display: none; if you would like a border around the tooltip but no border around the arrow */
+.tooltipster-default .tooltipster-arrow .tooltipster-arrow-border {
+ /* border-color: ... !important; */
+}
+
+
+/* If you're using the icon option, use this next selector to style them */
+.tooltipster-icon {
+ cursor: pointer;
+ margin-left: 4px;
+}
+
+
+
+
+
+
+
+
+/* This is the base styling required to make all Tooltipsters work */
+.tooltipster-base {
+ padding: 0;
+ font-size: 0;
+ line-height: 0;
+ position: absolute;
+ left: 0;
+ top: 0;
+ z-index: 9999999;
+ pointer-events: none;
+ width: auto;
+ overflow: visible;
+
+}
+.tooltipster-base .tooltipster-content {
+ overflow: hidden;
+}
+
+
+/* These next classes handle the styles for the little arrow attached to the tooltip. By default, the arrow will inherit the same colors and border as what is set on the main tooltip itself. */
+.tooltipster-arrow {
+ display: block;
+ text-align: center;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: -1;
+}
+.tooltipster-arrow span, .tooltipster-arrow-border {
+ display: block;
+ width: 0;
+ height: 0;
+ position: absolute;
+}
+.tooltipster-arrow-top span, .tooltipster-arrow-top-right span, .tooltipster-arrow-top-left span {
+ border-left: 8px solid transparent !important;
+ border-right: 8px solid transparent !important;
+ border-top: 8px solid;
+ bottom: -7px;
+}
+.tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-top-left .tooltipster-arrow-border {
+ border-left: 9px solid transparent !important;
+ border-right: 9px solid transparent !important;
+ border-top: 9px solid;
+ bottom: -7px;
+}
+
+.tooltipster-arrow-bottom span, .tooltipster-arrow-bottom-right span, .tooltipster-arrow-bottom-left span {
+ border-left: 8px solid transparent !important;
+ border-right: 8px solid transparent !important;
+ border-bottom: 8px solid;
+ top: -7px;
+}
+.tooltipster-arrow-bottom .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
+ border-left: 9px solid transparent !important;
+ border-right: 9px solid transparent !important;
+ border-bottom: 9px solid;
+ top: -7px;
+}
+.tooltipster-arrow-top span, .tooltipster-arrow-top .tooltipster-arrow-border, .tooltipster-arrow-bottom span, .tooltipster-arrow-bottom .tooltipster-arrow-border {
+ left: 0;
+ right: 0;
+ margin: 0 auto;
+}
+.tooltipster-arrow-top-left span, .tooltipster-arrow-bottom-left span {
+ left: 6px;
+}
+.tooltipster-arrow-top-left .tooltipster-arrow-border, .tooltipster-arrow-bottom-left .tooltipster-arrow-border {
+ left: 5px;
+}
+.tooltipster-arrow-top-right span, .tooltipster-arrow-bottom-right span {
+ right: 6px;
+}
+.tooltipster-arrow-top-right .tooltipster-arrow-border, .tooltipster-arrow-bottom-right .tooltipster-arrow-border {
+ right: 5px;
+}
+.tooltipster-arrow-left span, .tooltipster-arrow-left .tooltipster-arrow-border {
+ border-top: 8px solid transparent !important;
+ border-bottom: 8px solid transparent !important;
+ border-left: 8px solid;
+ top: 50%;
+ margin-top: -7px;
+ right: -7px;
+}
+.tooltipster-arrow-left .tooltipster-arrow-border {
+ border-top: 9px solid transparent !important;
+ border-bottom: 9px solid transparent !important;
+ border-left: 9px solid;
+ margin-top: -8px;
+}
+.tooltipster-arrow-right span, .tooltipster-arrow-right .tooltipster-arrow-border {
+ border-top: 8px solid transparent !important;
+ border-bottom: 8px solid transparent !important;
+ border-right: 8px solid;
+ top: 50%;
+ margin-top: -7px;
+ left: -7px;
+}
+.tooltipster-arrow-right .tooltipster-arrow-border {
+ border-top: 9px solid transparent !important;
+ border-bottom: 9px solid transparent !important;
+ border-right: 9px solid;
+ margin-top: -8px;
+}
+
+
+/* Some CSS magic for the awesome animations - feel free to make your own custom animations and reference it in your Tooltipster settings! */
+
+.tooltipster-fade {
+ opacity: 0;
+ -webkit-transition-property: opacity;
+ -moz-transition-property: opacity;
+ -o-transition-property: opacity;
+ -ms-transition-property: opacity;
+ transition-property: opacity;
+}
+.tooltipster-fade-show {
+ opacity: 1;
+}
+
+.tooltipster-grow {
+ -webkit-transform: scale(0,0);
+ -moz-transform: scale(0,0);
+ -o-transform: scale(0,0);
+ -ms-transform: scale(0,0);
+ transform: scale(0,0);
+ -webkit-transition-property: -webkit-transform;
+ -moz-transition-property: -moz-transform;
+ -o-transition-property: -o-transform;
+ -ms-transition-property: -ms-transform;
+ transition-property: transform;
+ -webkit-backface-visibility: hidden;
+}
+.tooltipster-grow-show {
+ -webkit-transform: scale(1,1);
+ -moz-transform: scale(1,1);
+ -o-transform: scale(1,1);
+ -ms-transform: scale(1,1);
+ transform: scale(1,1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+
+.tooltipster-swing {
+ opacity: 0;
+ -webkit-transform: rotateZ(4deg);
+ -moz-transform: rotateZ(4deg);
+ -o-transform: rotateZ(4deg);
+ -ms-transform: rotateZ(4deg);
+ transform: rotateZ(4deg);
+ -webkit-transition-property: -webkit-transform, opacity;
+ -moz-transition-property: -moz-transform;
+ -o-transition-property: -o-transform;
+ -ms-transition-property: -ms-transform;
+ transition-property: transform;
+}
+.tooltipster-swing-show {
+ opacity: 1;
+ -webkit-transform: rotateZ(0deg);
+ -moz-transform: rotateZ(0deg);
+ -o-transform: rotateZ(0deg);
+ -ms-transform: rotateZ(0deg);
+ transform: rotateZ(0deg);
+ -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -moz-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -ms-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ -o-transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+ transition-timing-function: cubic-bezier(0.230, 0.635, 0.495, 2.4);
+}
+
+.tooltipster-fall {
+ top: 0;
+ -webkit-transition-property: top;
+ -moz-transition-property: top;
+ -o-transition-property: top;
+ -ms-transition-property: top;
+ transition-property: top;
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+.tooltipster-fall-show {
+}
+.tooltipster-fall.tooltipster-dying {
+ -webkit-transition-property: all;
+ -moz-transition-property: all;
+ -o-transition-property: all;
+ -ms-transition-property: all;
+ transition-property: all;
+ top: 0px !important;
+ opacity: 0;
+}
+
+.tooltipster-slide {
+ left: -40px;
+ -webkit-transition-property: left;
+ -moz-transition-property: left;
+ -o-transition-property: left;
+ -ms-transition-property: left;
+ transition-property: left;
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1);
+ -webkit-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -moz-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -ms-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ -o-transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+ transition-timing-function: cubic-bezier(0.175, 0.885, 0.320, 1.15);
+}
+.tooltipster-slide.tooltipster-slide-show {
+}
+.tooltipster-slide.tooltipster-dying {
+ -webkit-transition-property: all;
+ -moz-transition-property: all;
+ -o-transition-property: all;
+ -ms-transition-property: all;
+ transition-property: all;
+ left: 0px !important;
+ opacity: 0;
+}
+
+
+/* CSS transition for when contenting is changing in a tooltip that is still open. The only properties that will NOT transition are: width, height, top, and left */
+.tooltipster-content-changing {
+ opacity: 0.5;
+ -webkit-transform: scale(1.1, 1.1);
+ -moz-transform: scale(1.1, 1.1);
+ -o-transform: scale(1.1, 1.1);
+ -ms-transform: scale(1.1, 1.1);
+ transform: scale(1.1, 1.1);
+}
diff --git a/html/includes/encoding.php b/html/includes/encoding.php
new file mode 100644
index 0000000..a559a3b
--- /dev/null
+++ b/html/includes/encoding.php
@@ -0,0 +1,304 @@
+<?php
+/*
+Copyright (c) 2008 Sebastián Grignoli
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+/**
+ * @author "Sebastián Grignoli" <grignoli@gmail.com>
+ * @package Encoding
+ * @version 2.0
+ * @link https://github.com/neitanod/forceutf8
+ * @example https://github.com/neitanod/forceutf8
+ * @license Revised BSD
+ */
+namespace ForceUTF8;
+class Encoding {
+ const ICONV_TRANSLIT = "TRANSLIT";
+ const ICONV_IGNORE = "IGNORE";
+ const WITHOUT_ICONV = "";
+ protected static $win1252ToUtf8 = array(
+ 128 => "\xe2\x82\xac",
+ 130 => "\xe2\x80\x9a",
+ 131 => "\xc6\x92",
+ 132 => "\xe2\x80\x9e",
+ 133 => "\xe2\x80\xa6",
+ 134 => "\xe2\x80\xa0",
+ 135 => "\xe2\x80\xa1",
+ 136 => "\xcb\x86",
+ 137 => "\xe2\x80\xb0",
+ 138 => "\xc5\xa0",
+ 139 => "\xe2\x80\xb9",
+ 140 => "\xc5\x92",
+ 142 => "\xc5\xbd",
+ 145 => "\xe2\x80\x98",
+ 146 => "\xe2\x80\x99",
+ 147 => "\xe2\x80\x9c",
+ 148 => "\xe2\x80\x9d",
+ 149 => "\xe2\x80\xa2",
+ 150 => "\xe2\x80\x93",
+ 151 => "\xe2\x80\x94",
+ 152 => "\xcb\x9c",
+ 153 => "\xe2\x84\xa2",
+ 154 => "\xc5\xa1",
+ 155 => "\xe2\x80\xba",
+ 156 => "\xc5\x93",
+ 158 => "\xc5\xbe",
+ 159 => "\xc5\xb8"
+ );
+ protected static $brokenUtf8ToUtf8 = array(
+ "\xc2\x80" => "\xe2\x82\xac",
+ "\xc2\x82" => "\xe2\x80\x9a",
+ "\xc2\x83" => "\xc6\x92",
+ "\xc2\x84" => "\xe2\x80\x9e",
+ "\xc2\x85" => "\xe2\x80\xa6",
+ "\xc2\x86" => "\xe2\x80\xa0",
+ "\xc2\x87" => "\xe2\x80\xa1",
+ "\xc2\x88" => "\xcb\x86",
+ "\xc2\x89" => "\xe2\x80\xb0",
+ "\xc2\x8a" => "\xc5\xa0",
+ "\xc2\x8b" => "\xe2\x80\xb9",
+ "\xc2\x8c" => "\xc5\x92",
+ "\xc2\x8e" => "\xc5\xbd",
+ "\xc2\x91" => "\xe2\x80\x98",
+ "\xc2\x92" => "\xe2\x80\x99",
+ "\xc2\x93" => "\xe2\x80\x9c",
+ "\xc2\x94" => "\xe2\x80\x9d",
+ "\xc2\x95" => "\xe2\x80\xa2",
+ "\xc2\x96" => "\xe2\x80\x93",
+ "\xc2\x97" => "\xe2\x80\x94",
+ "\xc2\x98" => "\xcb\x9c",
+ "\xc2\x99" => "\xe2\x84\xa2",
+ "\xc2\x9a" => "\xc5\xa1",
+ "\xc2\x9b" => "\xe2\x80\xba",
+ "\xc2\x9c" => "\xc5\x93",
+ "\xc2\x9e" => "\xc5\xbe",
+ "\xc2\x9f" => "\xc5\xb8"
+ );
+ protected static $utf8ToWin1252 = array(
+ "\xe2\x82\xac" => "\x80",
+ "\xe2\x80\x9a" => "\x82",
+ "\xc6\x92" => "\x83",
+ "\xe2\x80\x9e" => "\x84",
+ "\xe2\x80\xa6" => "\x85",
+ "\xe2\x80\xa0" => "\x86",
+ "\xe2\x80\xa1" => "\x87",
+ "\xcb\x86" => "\x88",
+ "\xe2\x80\xb0" => "\x89",
+ "\xc5\xa0" => "\x8a",
+ "\xe2\x80\xb9" => "\x8b",
+ "\xc5\x92" => "\x8c",
+ "\xc5\xbd" => "\x8e",
+ "\xe2\x80\x98" => "\x91",
+ "\xe2\x80\x99" => "\x92",
+ "\xe2\x80\x9c" => "\x93",
+ "\xe2\x80\x9d" => "\x94",
+ "\xe2\x80\xa2" => "\x95",
+ "\xe2\x80\x93" => "\x96",
+ "\xe2\x80\x94" => "\x97",
+ "\xcb\x9c" => "\x98",
+ "\xe2\x84\xa2" => "\x99",
+ "\xc5\xa1" => "\x9a",
+ "\xe2\x80\xba" => "\x9b",
+ "\xc5\x93" => "\x9c",
+ "\xc5\xbe" => "\x9e",
+ "\xc5\xb8" => "\x9f"
+ );
+ static function toUTF8($text){
+ /**
+ * Function \ForceUTF8\Encoding::toUTF8
+ *
+ * This function leaves UTF8 characters alone, while converting almost all non-UTF8 to UTF8.
+ *
+ * It assumes that the encoding of the original string is either Windows-1252 or ISO 8859-1.
+ *
+ * It may fail to convert characters to UTF-8 if they fall into one of these scenarios:
+ *
+ * 1) when any of these characters: ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß
+ * are followed by any of these: ("group B")
+ * ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶•¸¹º»¼½¾¿
+ * For example: %ABREPRESENT%C9%BB. «REPRESENTÉ»
+ * The "«" (%AB) character will be converted, but the "É" followed by "»" (%C9%BB)
+ * is also a valid unicode character, and will be left unchanged.
+ *
+ * 2) when any of these: àáâãäåæçèéêëìíîï are followed by TWO chars from group B,
+ * 3) when any of these: ðñòó are followed by THREE chars from group B.
+ *
+ * @name toUTF8
+ * @param string $text Any string.
+ * @return string The same string, UTF8 encoded
+ *
+ */
+ if(is_array($text))
+ {
+ foreach($text as $k => $v)
+ {
+ $text[$k] = self::toUTF8($v);
+ }
+ return $text;
+ } elseif(is_string($text)) {
+ if ( function_exists('mb_strlen') && ((int) ini_get('mbstring.func_overload')) & 2) {
+ $max = mb_strlen($text,'8bit');
+ } else {
+ $max = strlen($text);
+ }
+ $buf = "";
+ for($i = 0; $i < $max; $i++){
+ $c1 = $text{$i};
+ if($c1>="\xc0"){ //Should be converted to UTF8, if it's not UTF8 already
+ $c2 = $i+1 >= $max? "\x00" : $text{$i+1};
+ $c3 = $i+2 >= $max? "\x00" : $text{$i+2};
+ $c4 = $i+3 >= $max? "\x00" : $text{$i+3};
+ if($c1 >= "\xc0" & $c1 <= "\xdf"){ //looks like 2 bytes UTF8
+ if($c2 >= "\x80" && $c2 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ $buf .= $c1 . $c2;
+ $i++;
+ } else { //not valid UTF8. Convert it.
+ $cc1 = (chr(ord($c1) / 64) | "\xc0");
+ $cc2 = ($c1 & "\x3f") | "\x80";
+ $buf .= $cc1 . $cc2;
+ }
+ } elseif($c1 >= "\xe0" & $c1 <= "\xef"){ //looks like 3 bytes UTF8
+ if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ $buf .= $c1 . $c2 . $c3;
+ $i = $i + 2;
+ } else { //not valid UTF8. Convert it.
+ $cc1 = (chr(ord($c1) / 64) | "\xc0");
+ $cc2 = ($c1 & "\x3f") | "\x80";
+ $buf .= $cc1 . $cc2;
+ }
+ } elseif($c1 >= "\xf0" & $c1 <= "\xf7"){ //looks like 4 bytes UTF8
+ if($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf"){ //yeah, almost sure it's UTF8 already
+ $buf .= $c1 . $c2 . $c3 . $c4;
+ $i = $i + 3;
+ } else { //not valid UTF8. Convert it.
+ $cc1 = (chr(ord($c1) / 64) | "\xc0");
+ $cc2 = ($c1 & "\x3f") | "\x80";
+ $buf .= $cc1 . $cc2;
+ }
+ } else { //doesn't look like UTF8, but should be converted
+ $cc1 = (chr(ord($c1) / 64) | "\xc0");
+ $cc2 = (($c1 & "\x3f") | "\x80");
+ $buf .= $cc1 . $cc2;
+ }
+ } elseif(($c1 & "\xc0") == "\x80"){ // needs conversion
+ if(isset(self::$win1252ToUtf8[ord($c1)])) { //found in Windows-1252 special cases
+ $buf .= self::$win1252ToUtf8[ord($c1)];
+ } else {
+ $cc1 = (chr(ord($c1) / 64) | "\xc0");
+ $cc2 = (($c1 & "\x3f") | "\x80");
+ $buf .= $cc1 . $cc2;
+ }
+ } else { // it doesn't need conversion
+ $buf .= $c1;
+ }
+ }
+ return $buf;
+ } else {
+ return $text;
+ }
+ }
+ static function toWin1252($text, $option = self::WITHOUT_ICONV) {
+ if(is_array($text)) {
+ foreach($text as $k => $v) {
+ $text[$k] = self::toWin1252($v, $option);
+ }
+ return $text;
+ } elseif(is_string($text)) {
+ return static::utf8_decode($text, $option);
+ } else {
+ return $text;
+ }
+ }
+ static function toISO8859($text) {
+ return self::toWin1252($text);
+ }
+ static function toLatin1($text) {
+ return self::toWin1252($text);
+ }
+ static function fixUTF8($text, $option = self::WITHOUT_ICONV){
+ if(is_array($text)) {
+ foreach($text as $k => $v) {
+ $text[$k] = self::fixUTF8($v, $option);
+ }
+ return $text;
+