<commit_before><?php
/**
 * Generates a graphical bar.
 *
 * @package     phpMyFAQ 
 * @author      <NAME> <<EMAIL>>
 * @since       2003-10-26
 * @version     SVN: $Id$
 * @copyright   (c) 2003-2009 phpMyFAQ Team
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

define('PMF_ROOT_DIR', dirname(dirname(__FILE__)));

require_once(PMF_ROOT_DIR.'/inc/Init.php');
PMF_Init::cleanRequest();
session_name(PMF_COOKIE_NAME_AUTH . trim($faqconfig->get('main.phpMyFAQToken')));
session_start();

header ("Content-type: image/png");
$image = @imagecreate (50, 15) or die ("Sorry, but phpMyFAQ cannot initialize new GD image stream.");
$backgroundColor = imagecolorallocate ($image, 211, 211, 211);
$textColor = imagecolorallocate ($image, 0, 0, 0);

if (isset($_GET["num"]) && $_GET["num"] != "") {
    $num = round(($_GET["num"] * 20));
    if ($num < 25) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor = imagecolorallocate ($image, 255, 0, 0);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    } elseif ($num > 75) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor = imagecolorallocate ($image, 0, 128, 0);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    } elseif ($num <= 75 AND $num >= 25) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor = imagecolorallocate ($image, 150, 150, 150);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    }
    imagestring ($image, 2, 1, 1, $num."%", $textColor);
} else {
    imagestring ($image, 1, 5, 5, "n/a", $textColor);
}

imagepng($image);
<commit_msg>Code cleanup<commit_after><?php
/**
 * Generates a graphical bar.
 *
 * @package    phpMyFAQ 
 * @subpackage Administration
 * @author     <NAME> <<EMAIL>>
 * @since      2003-10-26
 * @copyright  2003-2009 phpMyFAQ Team
 * @version    SVN: $Id$
 *
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 */

define('PMF_ROOT_DIR', dirname(dirname(__FILE__)));

require_once PMF_ROOT_DIR . '/inc/Init.php';
PMF_Init::cleanRequest();
session_name(PMF_COOKIE_NAME_AUTH . trim($faqconfig->get('main.phpMyFAQToken')));
session_start();

$image           = @imagecreate (50, 15) or die ("Sorry, but phpMyFAQ cannot initialize a new image stream.");
$backgroundColor = imagecolorallocate ($image, 211, 211, 211);
$textColor       = imagecolorallocate ($image, 0, 0, 0);
$num             = PMF_Filter::filterInput(INPUT_GET, 'num', FILTER_VALIDATE_INT);

if (!is_null($num)) {
    $num = round($num * 20);
    if ($num < 25) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor  = imagecolorallocate ($image, 255, 0, 0);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    } elseif ($num > 75) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor  = imagecolorallocate ($image, 0, 128, 0);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    } elseif ($num <= 75 && $num >= 25) {
        $textColor = imagecolorallocate ($image, 255, 255, 255);
        $barColor  = imagecolorallocate ($image, 150, 150, 150);
        imagefilledrectangle ($image, 0, 0, round(($num/100)*50), 15, $barColor);
    }
    imagestring ($image, 2, 1, 1, $num . '%', $textColor);
} else {
    imagestring ($image, 1, 5, 5, 'n/a', $textColor);
}

header ('Content-type: image/png');
imagepng($image);
{'fraction_non_alphanumeric': 0.1548136290875829, 'fraction_numerical': 0.056254287674365425, 'mean_word_length': 3.7235421166306697, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7120790', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1387, 'n_words': 450}