$StartPoint = 1; } //Start point can't be greater than the list size if ($RowsPerPage < $ListSize) { //Slice array if it's larger than RowsPerPage $SiteList = array_slice($SiteList, $StartPoint, $RowsPerPage); } //Draw Table Headers------------------------------------------------- echo '<div class="sys-group">' . PHP_EOL; echo '<table id="blocked-table">'; //Table Start echo '<tr><th>#</th><th>Time</th><th>Site</th></tr>' . PHP_EOL; //Draw Table Cells--------------------------------------------------- $i = $StartPoint; foreach ($SiteList as $Site) { echo '<tr><td>' . $i . '</td><td>' . date('d M - H:i:s', $Site[0]) . '</td><td>' . $Site[1] . '</td></tr>' . PHP_EOL; $i++; } echo '</table></div>' . PHP_EOL; if ($ListSize > $RowsPerPage) { echo '<div class="sys-group">' . PHP_EOL; DisplayPagination($ListSize); echo '</div>' . PHP_EOL; } ?> </div> <div id="scrollup" class="button-scroll" onclick="ScrollToTop()"><img src="./svg/arrow-up.svg" alt="up"></a></div> <div id="scrolldown" class="button-scroll" onclick="ScrollToBottom()"><img src="./svg/arrow-down.svg" alt="down"></a></div> </body> </html>
function DisplaySiteList() { global $List, $SearchStr, $StartPoint, $RowsPerPage; //1. Check if a Search has been made //2a. Loop through List doing a strpos check to see if search string exists in List[x][0] (site name) //2b. Copy items to a Temp Array //2c. Copy Temp array back to List //2d. Delete Temp array //3. Draw page if ($SearchStr != '') { //Is user searching? $TempArray = array(); foreach ($List as $Site) { //Go through array if (strpos($Site[0], $SearchStr) !== false) { $TempArray[] = $Site; //Copy matching string to temp array } } $List = $TempArray; //Copy temp array to List unset($TempArray); //Delete temp array } $ListSize = count($List); if ($List[$ListSize - 1][0] == '') { //Last line is sometimes blank array_splice($List, $ListSize - 1); //Cut last line out } if ($StartPoint >= $ListSize) { $StartPoint = 1; } //Start point can't be greater than the list size if ($RowsPerPage < $ListSize) { //Slice array if it's larger than RowsPerPage $List = array_slice($List, $StartPoint, $RowsPerPage); } echo '<div class="sys-group">'; echo '<h5>Sites Blocked</h5>' . PHP_EOL; echo '<div class="centered">' . PHP_EOL; echo '<form action="?" method="get">'; echo '<input type="hidden" name="v" value="sites">'; echo AddHiddenVar('C'); if ($SearchStr == '') { echo '<input type="text" name="s" id="search" placeholder="Search">'; } else { echo '<input type="text" name="s" id="search" value="' . $SearchStr . '">'; } echo '</form></div>' . PHP_EOL; if ($ListSize > $RowsPerPage) { //Is Pagination needed echo '<br /><div class="row">'; DisplayPagination($ListSize, 'sites'); echo '</div>' . PHP_EOL; } echo '</div>' . PHP_EOL; echo '<div class="sys-group">'; if ($ListSize == 0) { echo 'No sites found in Block List' . PHP_EOL; echo '</div>'; return; } echo '<table id="block-table">' . PHP_EOL; $i = $StartPoint; foreach ($List as $Site) { if ($Site[1] == 'Active') { echo '<tr><td>' . $i . '</td><td>' . $Site[0] . '</td><td>' . $Site[2] . '<td></td></tr>' . PHP_EOL; } else { echo '<tr class="dark"><td>' . $i . '</td><td><s>' . $Site[0] . '</s></td><td><s>' . $Site[2] . '</s><td></td></tr>' . PHP_EOL; } $i++; } echo '</table></div>' . PHP_EOL; if ($ListSize > $RowsPerPage) { //Is Pagination needed echo '<div class="sys-group">'; DisplayPagination($ListSize, 'sites'); echo '</div>' . PHP_EOL; } return null; }