PHPIndex

This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).

app
get_nominees.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/get_nominees.php'
View Content
<?php
$mysqli = new mysqli("localhost", "mdrone", "einstein", "aasict_db");
$mysqli->query("SET SESSION group_concat_max_len = 2000000");
//$query = "SELECT member_id, name, nominated_by, contributions FROM member WHERE approved = 0";
$query = "SELECT member_id, name, COUNT(*) AS nominations, GROUP_CONCAT(nominated_by,contributions SEPARATOR '<hr><br>') AS contributions FROM member WHERE approved = 0 GROUP BY name;";
$result = $mysqli->query($query);

$nominees = [];

while ($row = $result->fetch_assoc()) {
    // Convert blob to base64
    $row['contributions'] = base64_encode($row['contributions']); 
    $nominees[] = $row;
    
}

header('Content-Type: application/json');
echo json_encode($nominees);
?>
show_nominees.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/show_nominees.php'
View Content
<?php
/* 
Database configuration
$servername = "localhost";  // Replace with your server name
$username = "mdrone";         // Replace with your MySQL username
$password = "einstein";             // Replace with your MySQL password
$dbname = "aasict_db";     // Database name

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
*/
include("../config.php");

// SQL query to fetch data from the table
//$sql = "SELECT * FROM member WHERE approved = 0 ORDER BY name";
$sql = "SELECT member_id, name, COUNT(DISTINCT(name)) AS nominations, GROUP_CONCAT(nominated_by SEPARATOR ', ') as nominated_by, GROUP_CONCAT(contributions SEPARATOR '<hr>') as contributions FROM member WHERE approved = 0 GROUP BY name ORDER BY name";
$result = $conn->query($sql);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <script src="https://kit.fontawesome.com/6b773fe9e4.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
    <title>Show Hall of Fame Nominees</title>
    <!-- Custom styles for this page -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.4.2/css/buttons.dataTables.min.css">
<style>
  .bigger { font-size: 13pt; text-shadow: 2px 2px 5px gray;}
</style>
<script type="text/javascript" src= "https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.print.min.js"></script>

    <script>
        $(document).ready(function () {
            $('#nominees').DataTable({
                dom: 'Bfrtip',
                buttons: [
                   // 'excel'
                ],
		paging: false
            });

        });
    </script>
</head>
<body>

<?php
// Check if there are any records in the result
if ($result->num_rows > 0) {
?>
<div class="container mt-4 table-responsive">
<h3>Tech-Geeks Hall of Fame Nominees</h3>
<table id="nominees" class="table table-striped table-row-bordered">
            <thead>
                <tr>
                    <th>Nominee</th>
                    <th>Nominated By</th>
                    <th>Contributions to Tech-Geeks</th>
                </tr>
            </thead>
            <tbody>
<?php
    
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<tr>
                <td class=bigger><b>' . $row["name"] . '</b></td>
                <td><i>' . $row["nominated_by"] . '</i></td>
                <td>' . $row["contributions"] . '</td>
              </tr>';
    }
?>    
</tbody>
</table>
</div>
<?php
} else {
    echo "No records found.";
}

// Close the connection
$conn->close();
?>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('[data-toggle="tooltip"]').tooltip();
    });
</script>
</body>
</html>

submit_votes.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/submit_votes.php'
View Content
<?php
$mysqli = new mysqli("localhost", "mdrone", "einstein", "aasict_db");

$data = json_decode(file_get_contents('php://input'), true);

foreach ($data['votes'] as $vote) {
    $stmt = $mysqli->prepare("INSERT INTO member_votes (member_id, vote) VALUES (?, ?)");
    $stmt->bind_param("is", $vote['member_id'], $vote['vote']);
    $stmt->execute();
}

echo json_encode(["status" => "success"]);
?>

view_nominees.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/view_nominees.php'
View Content
<?php
// Database configuration
$servername = "localhost";  // Replace with your server name
$username = "mdrone";         // Replace with your MySQL username
$password = "einstein";             // Replace with your MySQL password
$dbname = "aasict_db";     // Database name

// Create a connection
$conn = new mysqli($servername, $username, $password, $dbname);

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

// SQL query to fetch data from the table
$sql = "SELECT * FROM member WHERE approved = 0";
$result = $conn->query($sql);

// Start of HTML
echo '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>This Year\'s Hall of Fame Nominees</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 25px;
            background-color: #f4f4f4;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
            background-color: #fff;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
           # background-color: #4CAF50;
            background-color: #AF4C50;
            color: white;
        }
        tr:hover {
            background-color: #f1f1f1;
        }
	.bigger {
	    font-size: 18px;
	}
    </style>
</head>
<body>';

// Check if there are any records in the result
if ($result->num_rows > 0) {
    echo '<table>
            <thead>
                <tr>
                    <th>Nominee</th>
                    <th>Nominated By</th>
                    <th>Background/Work Experience</th>
                    <th>Districts/Schools/Entities Served</th>
                    <th>Contributions to Tech-Geeks</th>
                </tr>
            </thead>
            <tbody>';
    
    // Output data of each row
    while($row = $result->fetch_assoc()) {
        echo '<tr>
                <td class=bigger><b>' . $row["name"] . '</b></td>
                <td>' . $row["nominated_by"] . '</td>
                <td>' . $row["vita"] . '</td>
                <td>' . $row["location"] . '</td>
                <td>' . $row["contributions"] . '</td>
              </tr>';
    }
    
    echo '</tbody>
        </table>';
} else {
    echo "No records found.";
}

// Close the connection
$conn->close();

// End of HTML
echo '</body></html>';
?>

vote.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/vote.php'
View Content
<?php
$conn = mysqli_connect("localhost", "mdrone", "einstein", "aasict_db");

$res = mysqli_query($conn, "SELECT setting_value FROM settings WHERE setting_key = 'voting_enabled'");
$row = mysqli_fetch_assoc($res);
$voting_enabled = $row['setting_value'] == '1';

if (!$voting_enabled) {
    die("Voting is currently closed.");
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Tech-Geeks Hall-of-Fame: Nominee Approval</title>
<!-- Bootstrap CSS (correct) -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

<!-- Bootstrap JS Bundle (includes Popper!) -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>


  <style>
    body {
      background-color: #f8f9fa;
    }
    .modal-content pre {
      white-space: pre-wrap;
      word-break: break-word;
    }
    .table td, .table th {
      vertical-align: middle;
    }

.modal-body {
  max-height: 100vh;
  overflow-y: auto;
  font-family: "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  white-space: normal;
}

#contributionsText p {
  margin-bottom: 1em;
}

#contributionsText b {
  font-weight: 600;
}
.modal-content {
  color: #000; // Example: Black text
}
  </style>
</head>
<body>
    <div class="container align-items-center">
      <a href="/tg-hof/" class="logo d-flex align-items-center me-auto">
        <img src="../assets/img/tg-hof.webp" width="350px" alt="Tech-Geeks Hall of Fame">
      </a>
    </div>
 <div class="container mt-3">
    <h2 class="mb-4">Vote For Hall of Fame Nominee Approval
<!-- Button trigger modal -->
 <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#myModal">  ?  </button>
 </h2>
   <form id="voteForm">
      <table class="table table-bordered table-striped align-middle">
        <thead class="table-dark">
          <tr>
            <th class="text-center">Name</th>
            <th class="text-center">Number of Nominations</th> 
            <th class="text-center">Definitely Approve</th>
            <th class="text-center">Maybe Next Time</th>
          </tr>
        </thead>
        <tbody id="nomineeTable"></tbody>
      </table>
      <button type="submit" class="btn btn-primary mt-3">Submit Votes</button>
    </form>
  </div>


  <!-- Modal -->
  <div class="modal fade" id="contributionsModal" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="modalLabel">Contributions to Tech-Geeks</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
        </div>
        <div class="modal-body">
          <pre id="contributionsText"></pre>
        </div>
      </div>
    </div>
  </div>

<!-- Confirmation Modal -->
<div class="modal fade" id="confirmModal" tabindex="-1" aria-labelledby="confirmModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="confirmModalLabel">Confirm Your Vote</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        Are you sure you want to submit your vote? You won't be able to change it later.
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
        <button id="confirmSubmit" type="button" class="btn btn-primary">Submit Vote</button>
      </div>
    </div>
  </div>
</div>


<!-- The Modal -->
<div class="modal" id="myModal">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Voting</h4>
        <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
      </div>
      <!-- Modal body -->
      <div class="modal-body ">
        <p class="text-start"><p>Voting is completely anonymous.</p>
        <p class="text-start">Only the integrity of its members prevents someone from voting multiple times.</p>
        <p class="text-start">The system does not use cookies, IP address tracking or any other means to try to identify the voter.</p>
      </div>
      <!-- Modal footer -->
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-bs-dismiss="modal">X</button>
      </div>
    </div>
  </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

<!--
<script>
  async function fetchNominees() {
    const res = await fetch('get_nominees.php');
    const nominees = await res.json();
    const table = document.getElementById('nomineeTable');

    nominees.forEach(nom => {
      const tr = document.createElement('tr');

      // Name column with link to open modal
      const nameCell = document.createElement('td');
      const link = document.createElement('a');
      link.href = '#';
      link.textContent = nom.name;
      link.addEventListener('click', (e) => {
        e.preventDefault();

        try {
          // Decode base64 safely
          const decoded = decodeURIComponent(escape(window.atob(nom.contributions)));
          document.getElementById('contributionsText').innerHTML = decoded;
        } catch (err) {
          console.error("Error decoding contributions:", err);
          document.getElementById('contributionsText').textContent = "[Unable to display contributions. Possibly non-text data.]";
        }

        // Show modal
        const modal = new bootstrap.Modal(document.getElementById('contributionsModal'));
        modal.show();
      });
      nameCell.appendChild(link);
      tr.appendChild(nameCell);

      // Nominated by column
      const nominatedByCell = document.createElement('td');
      nominatedByCell.textContent = nom.nominated_by;
      tr.appendChild(nominatedByCell);
      

      // Approve radio
      const approveCell = document.createElement('td');
      approveCell.classList.add('text-center');
      approveCell.innerHTML = `<input type="radio" name="vote_${nom.member_id}" value="approve" >`;
      tr.appendChild(approveCell);

      // Disapprove radio
      const disapproveCell = document.createElement('td');
      disapproveCell.classList.add('text-center');
      disapproveCell.innerHTML = `<input type="radio" name="vote_${nom.member_id}" value="disapprove">`;
      tr.appendChild(disapproveCell);

      // Add row to table
      table.appendChild(tr);
    });
  }

  document.getElementById('voteForm').addEventListener('submit', async function (e) {
    e.preventDefault();

    const votes = [];
    const inputs = document.querySelectorAll('input[type=radio]:checked');
    inputs.forEach(input => {
      const memberId = input.name.split('_')[1];
      votes.push({ member_id: parseInt(memberId), vote: input.value });
    });

    const res = await fetch('submit_votes.php', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ votes })
    });

    const result = await res.json();
    if (result.status === 'success') {
      alert('Votes submitted successfully!');
      location.reload();
    } else {
      alert('Something went wrong. Please try again.');
    }
  });

  // Load nominees on page load
  fetchNominees();
</script>
-->

<script>
  async function fetchNominees() {
    const res = await fetch('get_nominees.php');
    const nominees = await res.json();
    const table = document.getElementById('nomineeTable');

    nominees.forEach(nom => {
      const tr = document.createElement('tr');

      // Name column with link to open modal
      const nameCell = document.createElement('td');
      const link = document.createElement('a');
      link.href = '#';
      link.textContent = nom.name;
      link.addEventListener('click', (e) => {
        e.preventDefault();

        try {
          // Decode base64 safely
          const decoded = decodeURIComponent(escape(window.atob(nom.contributions)));
          document.getElementById('contributionsText').innerHTML = decoded;
        } catch (err) {
          console.error("Error decoding contributions:", err);
          document.getElementById('contributionsText').textContent = "[Unable to display contributions. Possibly non-text data.]";
        }

        const modal = new bootstrap.Modal(document.getElementById('contributionsModal'));
        modal.show();
      });
      nameCell.appendChild(link);
      tr.appendChild(nameCell);

      // Nominated by column
      const nominatedByCell = document.createElement('td');
      nominatedByCell.classList.add('text-center');
      nominatedByCell.textContent = nom.nominations;
      tr.appendChild(nominatedByCell);

      // Approve radio
      const approveCell = document.createElement('td');
      approveCell.classList.add('text-center');
      approveCell.innerHTML = `<input type="radio" name="vote_${nom.member_id}" value="approve" required>`;
      tr.appendChild(approveCell);

      // Disapprove radio
      const disapproveCell = document.createElement('td');
      disapproveCell.classList.add('text-center');
      disapproveCell.innerHTML = `<input type="radio" name="vote_${nom.member_id}" value="disapprove">`;
      tr.appendChild(disapproveCell);

      table.appendChild(tr);
    });
  }

  // Intercept form submit
  document.getElementById('voteForm').addEventListener('submit', function (e) {
    e.preventDefault();

    // Open confirmation modal
    const confirmModal = new bootstrap.Modal(document.getElementById('confirmModal'));
    confirmModal.show();

    // On confirm click
    document.getElementById('confirmSubmit').onclick = async function () {
      confirmModal.hide();

      const votes = [];
      const inputs = document.querySelectorAll('input[type=radio]:checked');
      inputs.forEach(input => {
        const memberId = input.name.split('_')[1];
        votes.push({ member_id: parseInt(memberId), vote: input.value });
      });

      const res = await fetch('submit_votes.php', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ votes })
      });

      const result = await res.json();
      if (result.status === 'success') {
        alert('Thank you for voting! Redirecting...');
        setTimeout(() => {
          window.location.href = '/tg-hof/';
        }, 1500);
      } else {
        alert('Something went wrong. Please try again.');
      }
    };
  });

  fetchNominees();
</script>
</body>
</html>

voting_results.php
wget 'https://sme10.lists2.roe3.org/tg-hof/voting/voting_results.php'
View Content
<?php
$pdo = new PDO("mysql:host=localhost;dbname=aasict_db", "mdrone", "einstein");

$sql = "
  SELECT
    m.name,
    SUM(CASE WHEN mv.vote = 'approve' THEN 1 ELSE 0 END) AS approve_votes,
    SUM(CASE WHEN mv.vote = 'disapprove' THEN 1 ELSE 0 END) AS disapprove_votes
  FROM
    member_votes mv
  JOIN
    member m ON mv.member_id = m.member_id
  GROUP BY
    m.member_id, m.name
  ORDER BY
    m.name;
";

$stmt = $pdo->query($sql);
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html>
<head>
  <title>Tech-Geeks Hall of Fame: Nominee Voting Results</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
</head>
<body>
    <div class="container align-items-center">
      <a href="/tg-hof/" class="logo d-flex align-items-center me-auto">
        <img src="../assets/img/tg-hof.webp" width="350px" alt="Tech-Geeks Hall of Fame">
      </a>
    </div>
 <div class="container mt-3">
  <h2>Hall of Fame Voting Summary</h2>
  <table class="table table-striped table-bordered align-middle">
    <thead class="table-dark">
      <tr>
        <th>Nominee</th>
        <th>Votes to Approve Nominee</th>
        <th>Votes to Postpone Approval</th>
	<th>% Approval</th>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($results as $row): ?>
        <tr>
          <td><b><?= htmlspecialchars($row['name']) ?></b></td>
          <td><?= $row['approve_votes'] ?></td>
          <td><?= $row['disapprove_votes'] ?></td>
          <td><?php echo $row['approve_votes']/($row['approve_votes']+$row['disapprove_votes'])*100; ?>%</td>
        </tr>
      <?php endforeach; ?>
    </tbody>
  </table>
</div>
</body>
</html>