<commit_before><?php
session_start();
//new function
function getlist() {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "User"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);


    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }
    // $sql = "SELECT SName FROM Song";

    $sql = "SELECT Song.SName FROM Song WHERE Song.SName NOT IN (SELECT Likes.Rname FROM Likes WHERE Likes.Username= '$temp')";

    $result = $conn->query($sql);
    $arrayofrows = array();

    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            array_push($arrayofrows ,$row['SName']);
        }
    } else {
        echo "0 results";
    }
    $conn->close();

    return $arrayofrows;
    
}

/**
 * @param $num
 * @return mixed
 */
function recommendSongs($num) {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "Song"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);


    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }
    $sql = "SELECT Preference FROM User WHERE Username= '$temp'";

    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            $preference = $row["Preference"];
        }
    }

    $sql = "SELECT DISTINCT Song.SName FROM Song JOIN Likes JOIN User WHERE Song.SName = Likes.Rname AND Likes.Username = User.Username AND User.preference = '$preference' AND Song.SName NOT IN (SELECT Rname From Likes WHERE Username = '$temp')";

    $result = $conn->query($sql);
    $arrayofrows = array();
    $count = 0;
    while($row = mysqli_fetch_array($result))
    {
        $arrayofrows[$count] = $row;
        $count++;
    }
  
    $conn->close();
    if ($num <= $count) {
        return $arrayofrows[$num]['SName'];
    }
}

function showPreview($num) {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "User"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);


    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }

    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }

    $SName = recommendSongs($num);
    $sql = "SELECT URL FROM Song WHERE SName = '$SName'";
    $result = $conn->query($sql);
    $conn->close();

    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            return $row["URL"];
        }
    }

}
?>

<html>
<head>
    <!-- Theme Made By www.w3schools.com - No Copyright -->
    <title>RadioHub</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <style>
        body {
            font: 20px Montserrat, sans-serif;
            line-height: 1.8;
            color: #f5f6f7;
        }
        p {font-size: 16px;}
        .margin {margin-bottom: 45px;}
        .bg-1 {<commit_msg>no error<commit_after><?php
session_start();
//new function
function getlist() {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "User"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }
    // $sql = "SELECT SName FROM Song";
    $sql = "SELECT Song.SName FROM Song WHERE Song.SName NOT IN (SELECT Likes.Rname FROM Likes WHERE Likes.Username= '$temp')";
    $result = $conn->query($sql);
    $arrayofrows = array();
    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            array_push($arrayofrows ,$row['SName']);
        }
    } else {
        echo "0 results";
    }
    $conn->close();
    return $arrayofrows;
    
}
/**
 * @param $num
 * @return mixed
 */
function recommendSongs($num) {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "Song"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }
    $sql = "SELECT Preference FROM User WHERE Username= '$temp'";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        // output data of each row
        while($row = $result->fetch_assoc()) {
            $preference = $row["Preference"];
        }
    }
    $sql = "SELECT DISTINCT Song.SName FROM Song JOIN Likes JOIN User WHERE Song.SName = Likes.Rname AND Likes.Username = User.Username AND User.preference = '$preference' AND Song.SName NOT IN (SELECT Rname From Likes WHERE Username = '$temp')";
    $result = $conn->query($sql);
    $arrayofrows = array();
    $count = 0;
    while($row = mysqli_fetch_array($result))
    {
        $arrayofrows[$count] = $row;
        $count++;
    }
  
    $conn->close();
    if ($num <= $count) {
        return $arrayofrows[$num]['SName'];
    }
}
function showPreview($num) {
    $hostname = "engr-cpanel-mysql.engr.illinois.edu"; // usually is localhost
    $db_user = "csprojec_admin"; // change to your database password
    $db_password = "<PASSWORD>"; // change to your database password
    $database = "csprojec_radiohub"; // provide your database name
    $db_table = "User"; // your database table name
    $conn = new mysqli($hostname, $db_user, $db_password, $database);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if (isset($_SESSION['login_user'])) {
        $temp = $_SESSION['login_user'];
    }
    $SName = recommendSongs($num);
    $sql = "SELECT URL FROM Song WHERE SName = '$SName'";
    $result = $conn->query($sql);
    $conn->close();
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            return $row["URL"];
        }
    }
}
?>

<html>
<head>
    <!-- Theme Made By www.w3schools.com - No Copyright -->
    <title>RadioHub</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link href="http://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <style>
        body {
            font: 20px Montserrat, sans-serif;
            line-height: 1.8;
            color: #f5f6f7;
        }
        p {font-size: 16px;}
        .margin {margin-bottom: 45px;}
        .bg-1 {
{'fraction_non_alphanumeric': 0.16332540491561898, 'fraction_numerical': 0.0067957866123003734, 'mean_word_length': 2.786449399656947, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 83, 'https://': 2, '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': '2247890', 'n_tokens_mistral': 2896, 'n_tokens_neox': 2812, 'n_words': 667}