mirror of
https://github.com/djav1985/v-wordpress-plugin-updater.git
synced 2025-08-20 19:20:38 +08:00
modified: README.md modified: mu-plugin/v-sys-plugin-updater-mu.php modified: mu-plugin/v-sys-plugin-updater.php modified: mu-plugin/v-sys-theme-updater.php deleted: update-api/app/forms/home-forms.php deleted: update-api/app/forms/plupdate-forms.php deleted: update-api/app/forms/thupdate-forms.php deleted: update-api/app/helpers/home-helper.php deleted: update-api/app/helpers/logs-helper.php deleted: update-api/app/helpers/plupdate-helper.php deleted: update-api/app/helpers/thupdate-helper.php new file: update-api/classes/forms/HomeFormHandler.php new file: update-api/classes/forms/PlFormHandler.php new file: update-api/classes/forms/ThFormHandler.php new file: update-api/classes/helpers/HomeHelper.php new file: update-api/classes/helpers/LogsHelper.php new file: update-api/classes/helpers/PlHelper.php new file: update-api/classes/helpers/ThHelper.php new file: update-api/classes/util/security.php modified: update-api/lib/auth-lib.php new file: update-api/lib/class-lib.php modified: update-api/lib/load-lib.php deleted: update-api/lib/waf-lib.php modified: update-api/public/.htaccess new file: update-api/public/api.php modified: update-api/public/assets/css/login.css modified: update-api/public/assets/css/mobile.css deleted: update-api/public/assets/css/pages.css modified: update-api/public/assets/css/styles.css modified: update-api/public/index.php modified: update-api/public/login.php deleted: update-api/public/plugins/api.php deleted: update-api/public/plugins/download.php deleted: update-api/public/themes/api.php deleted: update-api/public/themes/download.php renamed: update-api/app/pages/home.php -> update-api/views/home.php renamed: update-api/app/pages/logs.php -> update-api/views/logs.php renamed: update-api/app/pages/plupdate.php -> update-api/views/plupdate.php renamed: update-api/app/pages/thupdate.php -> update-api/views/thupdate.php
98 lines
3.5 KiB
PHP
98 lines
3.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Project: Update API
|
|
* Author: Vontainment
|
|
* URL: https://vontainment.com
|
|
* File: HomeHelper.php
|
|
* Description: WordPress Update API Helper for Home page
|
|
*/
|
|
|
|
namespace UpdateApi\helpers;
|
|
|
|
class HomeHelper
|
|
{
|
|
public static function generateHostsTableRow($lineNumber, $domain, $key)
|
|
{
|
|
return '<tr>
|
|
<form method="post" action="/">
|
|
<input type="hidden" name="id" value="' . htmlspecialchars($lineNumber, ENT_QUOTES, 'UTF-8') . '">
|
|
<td><input class="hosts-domain" type="text" name="domain" value="' .
|
|
htmlspecialchars($domain, ENT_QUOTES, 'UTF-8') .
|
|
'"></td>
|
|
<td>
|
|
<input class="hosts-key" type="text" name="key" value="' .
|
|
htmlspecialchars($key, ENT_QUOTES, 'UTF-8') .
|
|
'">
|
|
</td>
|
|
<td>
|
|
<input class="hosts-submit" type="submit" name="update_entry" value="Update">
|
|
<input class="hosts-submit" type="submit" name="delete_entry" value="Delete">
|
|
</td>
|
|
</form>
|
|
</tr>';
|
|
}
|
|
|
|
/**
|
|
* Generates the hosts table HTML for display.
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function getHostsTableHtml()
|
|
{
|
|
$hostsFile = HOSTS_ACL . '/HOSTS';
|
|
$entries = file($hostsFile, FILE_IGNORE_NEW_LINES);
|
|
$hostsTableHtml = '';
|
|
if (count($entries) > 0) {
|
|
$halfCount = ceil(count($entries) / 2);
|
|
$entriesColumn1 = array_slice($entries, 0, $halfCount);
|
|
$entriesColumn2 = array_slice($entries, $halfCount);
|
|
$hostsTableHtml .= '<div class="row">';
|
|
// Column 1
|
|
$hostsTableHtml .= '<div class="column">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Domain</th>
|
|
<th>Key</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
foreach ($entriesColumn1 as $index => $entry) {
|
|
$lineNumber = $index;
|
|
// Correct line number for column 1
|
|
$fields = explode(' ', $entry);
|
|
$domain = isset($fields[0]) ? $fields[0] : '';
|
|
$key = isset($fields[1]) ? $fields[1] : '';
|
|
$hostsTableHtml .= self::generateHostsTableRow($lineNumber, $domain, $key);
|
|
}
|
|
|
|
$hostsTableHtml .= '</tbody></table></div>';
|
|
// Column 2
|
|
$hostsTableHtml .= '<div class="column">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Domain</th>
|
|
<th>Key</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>';
|
|
foreach ($entriesColumn2 as $index => $entry) {
|
|
$lineNumber = $index + $halfCount;
|
|
// Correct line number for column 2
|
|
$fields = explode(' ', $entry);
|
|
$domain = isset($fields[0]) ? $fields[0] : '';
|
|
$key = isset($fields[1]) ? $fields[1] : '';
|
|
$hostsTableHtml .= self::generateHostsTableRow($lineNumber, $domain, $key);
|
|
}
|
|
|
|
$hostsTableHtml .= '</tbody></table></div></div>';
|
|
} else {
|
|
$hostsTableHtml = "No entries found.";
|
|
}
|
|
return $hostsTableHtml;
|
|
}
|
|
}
|