<commit_before><?php
    $SelectedCategory = $_REQUEST[ "Category" ];
    include("../include.php");
    // establish connection to MySQL database or output error message.
    $link = mysql_connect ($dbHost, $dbUser, $dbPassword);
    if (!mysql_select_db($dbName, $link)) {
        echo mysql_errno().": ".mysql_error()."<br>";
    }

    $Title = "Search";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Comment Search</title>
</head>
<body>

<?php
    $CatOptions = "<option value=\"-1\">search all categories</option>";
    $CategoryListQuery = "SELECT i_CategoryId
                               , vc_Name
                            FROM Category
                        ORDER BY vc_Name";
    $CategoryListResultId =  mysql_query ($CategoryListQuery, $link);

    while ( $CategoryListResult = mysql_fetch_object($CategoryListResultId) ) {
        $CatOptions .= "<option value=\"$CategoryListResult->i_CategoryId\"";

        if ( $SelectedCategory == $CategoryListResult->i_CategoryId ) {
            $CatOptions .= " selected=\"selected\"";
        }

        $CatOptions .= ">$CategoryListResult->vc_Name</option>";
    }

    $intMinCommentArchive = 1;
    $intTrueMaxCommentArchive = 29;
    $intMaxCommentArchive = $intTrueMaxCommentArchive;
    $strCurrentArchive = "";

    $intFirstCommentId = 0;
    $intLastCommentId = -1;
    $strCommentRange = "";

    $LookFor = $_REQUEST[ 'LookFor' ];
    $ArchiveToSearch = $_REQUEST[ 'ArchiveToSearch' ];
    $ByUser = $_REQUEST[ 'ByUser' ];

    $Total = 0;
    echo "<h1>".$Title."</h1>";
    if ( !Empty( $LookFor ) ) {
        echo "Results for <b>$LookFor</b>";

        if ( $ByUser != "" ) {
            echo " posted by user <b>$ByUser</b>";
        }

        if ( $ArchiveToSearch > 0 ) {
            echo " in CommentArchive$ArchiveToSearch ";
            $intMinCommentArchive = $ArchiveToSearch;
            $intMaxCommentArchive = $ArchiveToSearch;
        }
        else if ( $ArchiveToSearch == 0 ) {
            $intMinCommentArchive = 1001;
            $intMaxCommentArchive = 0;
        }

        echo "<span style=\"font-size: 10px;\"> ";

        for ( $intCurrentCA = $intMinCommentArchive; $intCurrentCA <= $intMaxCommentArchive; $intCurrentCA++ ) {
            $strCurrentArchive = "CommentArchive$intCurrentCA";

            $Query = "SELECT count(t_Comment) as counter
                        FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
                $Query.= "JOIN Users On Users.i_UID = $strCurrentArchive.i_UID
                AND Users.vc_Username = \"$ByUser\" ";
            }

            $Query.="   WHERE t_Comment LIKE '%$LookFor%'";

            if ( $SelectedCategory > 0 ) {
              $Query.= " AND i_CategoryId = $SelectedCategory";
            }

            $Q2 = "     SELECT $strCurrentArchive.i_CommentId AS
                  LABELLER FROM $strCurrentArchive ";

            if ( $ByUser != "" ) {
                $Q2.= "JOIN Users On Users.i_UID =
                        $strCurrentArchive.i_UID
                    AND Users.vc_Username = \"$ByUser\" ";
            }

            $Q2.= " WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Q2.= " AND i_CategoryId = $SelectedCategory";
            }
            $Q2.= " ORDER BY $strCurrentArchive.i_CommentId ASC";

            $UInfId = mysql_query ($Query, $link);
            $UInfRes = mysql_fetch_object($UInfId);

            $intFirstCommentId = ( ($intCurrentCA-1) * 50000) + 1;
            $intLastCommentId = $intFirstCommentId + 49999;

            $strCommentRange = "$intFirstCommentId - $intLastCommentId";

            if (!Empty($UInfRes->COUNTER)) {
                echo "<hr>$UInfRes->COUNTER Results in $strCommentRange <BR>"; $Total += $UInfRes->COUNTER;
            }
            else echo "<hr />0 Results in $strCommentRange<br />";
            $UInfId2 = mysql_query ($Q2, $link);
            while ($UInfRes = mysql_fetch_object($UInfId2)) {
                echo "<a href=\"../main.php?ViewPost=$UInfRes->LABELLER\">p$UInfRes->LABELLER</A> | ";
            }
        }

        // search comment table
        if ( $ArchiveToSearch < 1 ) {
            $strCurrentArchive = "Comment";

            $Query = "  SELECT COUNT(t_Comment) AS COUNTER
                    FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
                $Query.="JOIN Users on Users.i_UID = Comment.i_UID
                    AND Users.vc_Username = \"$ByUser\" ";
            }
            $Query.="   WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Query.= " AND i_CategoryId = $SelectedCategory";
            }

            $Q2 = "     SELECT $strCurrentArchive.i_CommentId AS LABELLER
                    FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
               $Q2.="JOIN Users on Users.i_UID = Comment.i_UID
                   AND Users.vc_Username = \"$ByUser\" ";
            }
            $Q2.= " WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Q2.= " AND i_CategoryId = $SelectedCategory";
            }
            $Q2.= " ORDER BY $strCurrentArchive.i_CommentId ASC";

            $Query = $Q2;
            $UInfId = mysql_query ($Query, $link);
            $UInfRes = mysql_fetch_object($UInfId);

            $intFirstCommentId = ($intTrueMaxCommentId * 50000) + 1;
            $intLastCommentId = $intFirstCommentId + 49999;

            $strCommentRange = "Current Comment Table";

            if (!Empty($UInfRes->COUNTER)) {
                echo "<hr>$UInfRes->COUNTER Results in $strCommentRange <br>"; $Total += $UInfRes->COUNTER;
            }
            else {
                echo "<hr>0 Results in $strCommentRange<br>";
            }
            $UInfId2 = mysql_query ($Q2, $link);
            while ($UInfRes = mysql_fetch_object($UInfId2)) {
                echo "<a href=\"../main.php?ViewPost=$UInfRes->LABELLER\">p$UInfRes->LABELLER</a> | ";
            }
        }
    }
?>
</span><br /><br />
<?Php
    echo "$Total Total Results Found";
?>
<br />
<br />
    <form action="custom.php" method="post">
    <table>
        <tr>
            <td width="20%">
                Search Phrase:
            </td>
            <td>
                <input name="LookFor" TYPE="Text"
value="<?php echo $LookFor; ?>">
            </td>
        </tr>
        <tr>
            <td>
                    Search by user
            </td>
            <td>
                <input type="text" name="ByUser"
value="<?php echo $ByUser ?>" />
            </td>
        </tr>
        <tr>
            <td>
                Search comment archive:
            </td>
            <td>
                <select name="ArchiveToSearch"><commit_msg>Reformatting code.<commit_after><?php
    $SelectedCategory = $_REQUEST[ "Category" ];
    include("../include.php");
    // establish connection to MySQL database or output error message.
    $link = mysql_connect ($dbHost, $dbUser, $dbPassword);
    if (!mysql_select_db($dbName, $link)) {
        echo mysql_errno().": ".mysql_error()."<br>";
    }

    $Title = "Search";
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Comment Search</title>
</head>
<body>

<?php
    $CatOptions = "<option value=\"-1\">search all categories</option>";
    $CategoryListQuery = "SELECT i_CategoryId
                               , vc_Name
                            FROM Category
                        ORDER BY vc_Name";
    $CategoryListResultId =  mysql_query ($CategoryListQuery, $link);

    while ( $CategoryListResult = mysql_fetch_object($CategoryListResultId) ) {
        $CatOptions .= "<option value=\"$CategoryListResult->i_CategoryId\"";

        if ( $SelectedCategory == $CategoryListResult->i_CategoryId ) {
            $CatOptions .= " selected=\"selected\"";
        }

        $CatOptions .= ">$CategoryListResult->vc_Name</option>";
    }

    $intMinCommentArchive = 1;
    $intTrueMaxCommentArchive = 29;
    $intMaxCommentArchive = $intTrueMaxCommentArchive;
    $strCurrentArchive = "";

    $intFirstCommentId = 0;
    $intLastCommentId = -1;
    $strCommentRange = "";

    $LookFor = $_REQUEST[ 'LookFor' ];
    $ArchiveToSearch = $_REQUEST[ 'ArchiveToSearch' ];
    $ByUser = $_REQUEST[ 'ByUser' ];

    $Total = 0;
    echo "<h1>".$Title."</h1>";
    if ( !Empty( $LookFor ) ) {
        echo "Results for <b>$LookFor</b>";

        if ( $ByUser != "" ) {
            echo " posted by user <b>$ByUser</b>";
        }

        if ( $ArchiveToSearch > 0 ) {
            echo " in CommentArchive$ArchiveToSearch ";
            $intMinCommentArchive = $ArchiveToSearch;
            $intMaxCommentArchive = $ArchiveToSearch;
        }
        else if ( $ArchiveToSearch == 0 ) {
            $intMinCommentArchive = 1001;
            $intMaxCommentArchive = 0;
        }

        echo "<span style=\"font-size: 10px;\"> ";

        for ( $intCurrentCA = $intMinCommentArchive; $intCurrentCA <= $intMaxCommentArchive; $intCurrentCA++ ) {
            $strCurrentArchive = "CommentArchive$intCurrentCA";

            $Query = "SELECT count(t_Comment) as counter
                        FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
                $Query.= "JOIN Users On Users.i_UID = $strCurrentArchive.i_UID
                AND Users.vc_Username = \"$ByUser\" ";
            }

            $Query.="   WHERE t_Comment LIKE '%$LookFor%'";

            if ( $SelectedCategory > 0 ) {
              $Query.= " AND i_CategoryId = $SelectedCategory";
            }

            $Q2 = "     SELECT $strCurrentArchive.i_CommentId AS
                  LABELLER FROM $strCurrentArchive ";

            if ( $ByUser != "" ) {
                $Q2.= "JOIN Users On Users.i_UID =
                        $strCurrentArchive.i_UID
                    AND Users.vc_Username = \"$ByUser\" ";
            }

            $Q2.= " WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Q2.= " AND i_CategoryId = $SelectedCategory";
            }
            $Q2.= " ORDER BY $strCurrentArchive.i_CommentId ASC";

            $UInfId = mysql_query ($Query, $link);
            $UInfRes = mysql_fetch_object($UInfId);

            $intFirstCommentId = ( ($intCurrentCA-1) * 50000) + 1;
            $intLastCommentId = $intFirstCommentId + 49999;

            $strCommentRange = "$intFirstCommentId - $intLastCommentId";

            if (!Empty($UInfRes->COUNTER)) {
                echo "<hr>$UInfRes->COUNTER Results in $strCommentRange <BR>"; $Total += $UInfRes->COUNTER;
            }
            else {
                echo "<hr />0 Results in $strCommentRange<br />";
            }
            $UInfId2 = mysql_query ($Q2, $link);
            while ($UInfRes = mysql_fetch_object($UInfId2)) {
                echo "<a href=\"../main.php?ViewPost=$UInfRes->LABELLER\">p$UInfRes->LABELLER</A> | ";
            }
        }

        // search comment table
        if ( $ArchiveToSearch < 1 ) {
            $strCurrentArchive = "Comment";

            $Query = "  SELECT COUNT(t_Comment) AS COUNTER
                    FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
                $Query.="JOIN Users on Users.i_UID = Comment.i_UID
                    AND Users.vc_Username = \"$ByUser\" ";
            }
            $Query.="   WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Query.= " AND i_CategoryId = $SelectedCategory";
            }

            $Q2 = "     SELECT $strCurrentArchive.i_CommentId AS LABELLER
                    FROM $strCurrentArchive ";
            if ( $ByUser != "" ) {
               $Q2.="JOIN Users on Users.i_UID = Comment.i_UID
                   AND Users.vc_Username = \"$ByUser\" ";
            }
            $Q2.= " WHERE t_Comment LIKE '%$LookFor%' ";

            if ( $SelectedCategory > 0 ) {
                $Q2.= " AND i_CategoryId = $SelectedCategory";
            }
            $Q2.= " ORDER BY $strCurrentArchive.i_CommentId ASC";

            $Query = $Q2;
            $UInfId = mysql_query ($Query, $link);
            $UInfRes = mysql_fetch_object($UInfId);

            $intFirstCommentId = ($intTrueMaxCommentId * 50000) + 1;
            $intLastCommentId = $intFirstCommentId + 49999;

            $strCommentRange = "Current Comment Table";

            if (!Empty($UInfRes->COUNTER)) {
                echo "<hr>$UInfRes->COUNTER Results in $strCommentRange <br>"; $Total += $UInfRes->COUNTER;
            }
            else {
                echo "<hr>0 Results in $strCommentRange<br>";
            }
            $UInfId2 = mysql_query ($Q2, $link);
            while ($UInfRes = mysql_fetch_object($UInfId2)) {
                echo "<a href=\"../main.php?ViewPost=$UInfRes->LABELLER\">p$UInfRes->LABELLER</a> | ";
            }
        }
    }
?>
</span><br /><br />
<?php
    echo "$Total Total Results Found";
?>
<br />
<br />
    <form action="custom.php" method="post">
    <table>
        <tr>
            <td width="20%">
                Search Phrase:
            </td>
            <td>
                <input name="LookFor" TYPE="Text"
value="<?php echo $LookFor; ?>">
            </td>
        </tr>
        <tr>
            <td>
                    Search by user
            </td>
            <td>
                <input type="text" name="ByUser"
value="<?php echo $ByUser ?>" />
            </td>
        </tr>
        <tr>
            <td>
                Search comment archive:
            </td>
            <td>
                <select name="ArchiveToSearch">
{'fraction_non_alphanumeric': 0.14150600218261186, 'fraction_numerical': 0.01018552200800291, 'mean_word_length': 1.7117774709015585, 'pattern_counts': {'":': 2, '<': 131, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3538959', 'n_tokens_mistral': 4293, 'n_tokens_neox': 3977, 'n_words': 836}