<commit_before><?php
/**
 * TimThumb by <NAME> and <NAME>
 * Based on work done by <NAME> and <NAME>
 * http://code.google.com/p/timthumb/
 *
 * GNU General Public License, version 2
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * Examples and documentation available on the project homepage
 * http://www.binarymoon.co.uk/projects/timthumb/
 *
 * $Rev$
 */

/**
 * Bolt specific code: turn /100x200f/foo.jpg into $_GET parameters timthumb understands.
 *
 * options for zoomcrop:
 * http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
 * 'f' ('fit') -> zc=0
 * 'c' (crop, default) -> zc=1
 * 'b' (borders) -> zc=2
 * 'r' (resize) -> zc=3
 */

// @see: http://stackoverflow.com/questions/6483912/php-serverredirect-url-vs-serverrequest-uri
if (!empty($_SERVER['REDIRECT_URL']) && (strpos($_SERVER['REDIRECT_URL'], 'timthumb.php') === false)) {
    $requesturi = $_SERVER['REDIRECT_URL'];
} else {
    $requesturi = $_SERVER['REQUEST_URI'];
}

// Make sure we don't get cruft after the '?'.
$parsed_url = parse_url($requesturi);

// Match the width, height, cropping type and filename..
$res = preg_match("^thumbs/([0-9]+)x([0-9]+)([a-z]*)/(.*)^i", $parsed_url['path'] , $matches);

if (empty($matches[1]) || empty($matches[2]) || empty($matches[4])) {
    die("Malformed thumbnail URL. Should look like '/thumbs/320x240c/filename.jpg'.");
}

// Let's get on with the rest..
$yamlparser = new Symfony\Component\Yaml\Parser();
$config['general'] = $yamlparser->parse(file_get_contents(BOLT_CONFIG_DIR .'/config.yml') . "\n");

// Set some default settings, as defined in our config.yml
define('DEFAULT_Q', !empty($config['general']['thumbnails']['quality'])
    ? $config['general']['thumbnails']['quality']
    : 70);
define('DEFAULT_ZC', !empty($config['general']['thumbnails']['cropping'])
    ? $config['general']['thumbnails']['cropping']
    : 'crop');
define('NOT_FOUND_IMAGE', !empty($config['general']['thumbnails']['notfound_image'])
    ? "../" . $config['general']['thumbnails']['notfound_image']<commit_msg>Fix thumbnail issue introduced in pull #937<commit_after><?php
/**
 * TimThumb by <NAME> and <NAME>
 * Based on work done by <NAME> and <NAME>
 * http://code.google.com/p/timthumb/
 *
 * GNU General Public License, version 2
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 *
 * Examples and documentation available on the project homepage
 * http://www.binarymoon.co.uk/projects/timthumb/
 *
 * $Rev$
 */

/**
 * Bolt specific code: turn /100x200f/foo.jpg into $_GET parameters timthumb understands.
 *
 * options for zoomcrop:
 * http://www.binarymoon.co.uk/demo/timthumb-zoom-crop/
 * 'f' ('fit') -> zc=0
 * 'c' (crop, default) -> zc=1
 * 'b' (borders) -> zc=2
 * 'r' (resize) -> zc=3
 */

// @see: http://stackoverflow.com/questions/6483912/php-serverredirect-url-vs-serverrequest-uri
if (!empty($_SERVER['REDIRECT_URL']) && (strpos($_SERVER['REDIRECT_URL'], 'timthumb.php') === false)) {
    $requesturi = $_SERVER['REDIRECT_URL'];
} else {
    $requesturi = $_SERVER['REQUEST_URI'];
}

// Make sure we don't get cruft after the '?'.
$parsed_url = parse_url($requesturi);

// Match the width, height, cropping type and filename..
$res = preg_match("^thumbs/([0-9]+)x([0-9]+)([a-z]*)/(.*)^i", $parsed_url['path'] , $matches);

if (empty($matches[1]) || empty($matches[2]) || empty($matches[4])) {
    die("Malformed thumbnail URL. Should look like '/thumbs/320x240c/filename.jpg'.");
}

/**
 * Bolt specific: Set BOLT_PROJECT_ROOT_DIR, and Bolt-specific settings..
 */
if (substr(__DIR__, -20) == DIRECTORY_SEPARATOR.'bolt-public'.DIRECTORY_SEPARATOR.'classes') { // installed bolt with composer
    require_once __DIR__ . '/../../../vendor/bolt/bolt/app/bootstrap.php';
} else {
    require_once __DIR__ . '/../bootstrap.php';
}

// Let's get on with the rest..
$yamlparser = new Symfony\Component\Yaml\Parser();
$config['general'] = $yamlparser->parse(file_get_contents(BOLT_CONFIG_DIR .'/config.yml') . "\n");

// Set some default settings, as defined in our config.yml
define('DEFAULT_Q', !empty($config['general']['thumbnails']['quality'])
    ? $config['general']['thumbnails']['quality']
    : 70);
define('DEFAULT_ZC', !empty($config['general']['thumbnails']['cropping'])
    ? $config['general']['thumbnails']['cropping']
    : 'crop');
define('NOT_FOUND_IMAGE', !empty($config['general']['thumbnails']['notfound_image'])
    ? "../" . $config['general']['thumbnails']['notfound_image']
{'fraction_non_alphanumeric': 0.21161638901395768, 'fraction_numerical': 0.016884286357496624, 'mean_word_length': 4.588679245283019, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '6055923', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1528, 'n_words': 301}