<commit_before><?php

// set up template title & style
$title = 'MVHPC :: Search Images';
$template->setCurrentPage('archives');
$template->setStyle('oneColumn');
$headerExtras['custom'] = "<style type='text/css'>.single_col{padding: 15px 0;}</style>";

$terms = strtolower(urldecode($subpage2));
$page = (isset($subpage3) && !empty($subpage3)) ? $subpage3 : 1;

if (!empty($terms)) {
    $db = Database::getDatabase();
    $result = $db->query("SELECT thumbnail,id, MATCH(tags, information) AGAINST('$terms') AS score FROM search WHERE MATCH(tags, information) AGAINST('$terms') and live = '1' ORDER BY score DESC, views DESC");
    $num = $db->numRows($result) ? $db->numRows($result) : 0;

    if ($num == 0) {
        $result = $db->query("SELECT thumbnail,id FROM search WHERE live = '1' and (tags LIKE '%$terms%' OR information LIKE '%$terms%') ORDER BY views DESC");
        $num = $db->numRows($result) ? $db->numRows($result) : 0;
        if ($num == 0) {
            $noResults = "<p class='body_text'>No results found for the search \"" . $terms . "\".&nbsp;&nbsp;Please try a different search.</p>";
        }
    }
}

ob_start();
?>

<h1 class="ribbon">Image Search</h1>

<input name="terms" type="text" id="global"/>
<input class="button" id="search" type="submit" value="Search" />
<commit_msg>Fix search paging problem in Issue #32. Still a bit hacky and will cause problems if tags have /<commit_after><?php

// set up template title & style
$title = 'MVHPC :: Search Images';
$template->setCurrentPage('archives');
$template->setStyle('oneColumn');
$headerExtras['custom'] = "<style type='text/css'>.single_col{padding: 15px 0;}</style>";

if(strstr($subpage2, '/')){
    $tmp = explode('/', $subpage2);
    $subpage2 = $tmp[0];
    $subpage3 = $tmp[1];
}

$terms = strtolower(urldecode($subpage2));
$page = (isset($subpage3) && !empty($subpage3)) ? $subpage3 : 1;

if (!empty($terms)) {
    $db = Database::getDatabase();
    $result = $db->query("SELECT thumbnail,id, MATCH(tags, information) AGAINST('$terms') AS score FROM search WHERE MATCH(tags, information) AGAINST('$terms') and live = '1' ORDER BY score DESC, views DESC");
    $num = $db->numRows($result) ? $db->numRows($result) : 0;

    if ($num == 0) {
        $result = $db->query("SELECT thumbnail,id FROM search WHERE live = '1' and (tags LIKE '%$terms%' OR information LIKE '%$terms%') ORDER BY views DESC");
        $num = $db->numRows($result) ? $db->numRows($result) : 0;
        if ($num == 0) {
            $noResults = "<p class='body_text'>No results found for the search \"" . $terms . "\".&nbsp;&nbsp;Please try a different search.</p>";
        }
    }
}

ob_start();
?>

<h1 class="ribbon">Image Search</h1>

<input name="terms" type="text" id="global"/>
<input class="button" id="search" type="submit" value="Search" />

{'fraction_non_alphanumeric': 0.20298083747338538, 'fraction_numerical': 0.014194464158977998, 'mean_word_length': 4.308851224105461, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3344344', 'n_tokens_mistral': 991, 'n_tokens_neox': 943, 'n_words': 250}