-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
s22-tech
committed
May 26, 2024
1 parent
d3facb5
commit 9ee496c
Showing
5 changed files
with
707 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/local/bin/php | ||
<?php | ||
|
||
ini_set('display_errors', 1); | ||
require_once(realpath(dirname(__DIR__, 1) . '/config/config.php')); | ||
require_once(realpath(dirname(__DIR__, 1) . '/lib/mysql.php')); | ||
$mysql = new mysql; | ||
|
||
$param = $argv[1] ?? PHP_SAPI ?? ''; | ||
|
||
////////////////////////////////// | ||
// Retrieve favicon names from db. | ||
////////////////////////////////// | ||
$query = " | ||
SELECT * FROM `obm_bookmarks` | ||
GROUP BY `favicon` HAVING COUNT(`favicon`) >= 1; | ||
"; | ||
|
||
if ($mysql->query($query)) { | ||
$favicons_sql = []; | ||
while ($row = mysqli_fetch_assoc($mysql->result)) { | ||
if (!empty($row['favicon'])) { | ||
$favicons_sql[$row['id']] = $row['favicon']; | ||
} | ||
} | ||
// print_r($favicons_sql); //:debug | ||
} | ||
|
||
|
||
////////////////////////////////// | ||
// Delete favicons from the server. | ||
////////////////////////////////// | ||
$favicons = []; | ||
$icons_path = realpath(DOC_ROOT . '/icons/'); | ||
foreach (glob($icons_path . '/*') as $filename) { | ||
if (!in_array(basename($filename), $favicons_sql)) { | ||
$favicons[] = $filename; | ||
unlink($filename); | ||
} | ||
} | ||
|
||
|
||
////////////////////////////////// | ||
// Print results. | ||
////////////////////////////////// | ||
if ($param !== 'cron') { | ||
$deleted_icons = implode(PHP_EOL, $favicons); | ||
echo 'Deleted favicons:' . PHP_EOL; | ||
echo $deleted_icons . PHP_EOL; | ||
} | ||
|
||
__halt_compiler(); | ||
This script will delete all unsused favicons on the server as often as it's run either manually or scheduled via cron. Helps to keep the icon footprint as small as possible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
CREATE TABLE `obm_bookmarks` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`childof` int(11) NOT NULL DEFAULT 0, | ||
`user` char(20) NOT NULL DEFAULT '', | ||
`title` varchar(200) NOT NULL DEFAULT '', | ||
`url` varchar(512) NOT NULL DEFAULT '', | ||
`description` longtext DEFAULT NULL, | ||
`deleted` enum('0','1') NOT NULL DEFAULT '0', | ||
`favicon` varchar(1048) DEFAULT NULL, | ||
`private` enum('0','1') DEFAULT NULL, | ||
`public` enum('0','1') NOT NULL DEFAULT '0', | ||
`last_visit` datetime DEFAULT NULL, | ||
`date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
`date_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
PRIMARY KEY (`id`), | ||
FULLTEXT KEY `title` (`title`,`url`,`description`) | ||
) ENGINE=Aria AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; | ||
|
||
|
||
CREATE TABLE `obm_folders` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`childof` int(11) NOT NULL DEFAULT 0, | ||
`name` char(70) NOT NULL DEFAULT '', | ||
`user` char(20) NOT NULL DEFAULT '', | ||
`deleted` enum('0','1') NOT NULL DEFAULT '0', | ||
`public` enum('0','1') NOT NULL DEFAULT '0', | ||
UNIQUE KEY `id` (`id`) | ||
) ENGINE=Aria AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; | ||
|
||
|
||
CREATE TABLE `obm_users` ( | ||
`username` char(50) NOT NULL DEFAULT '', | ||
`password` char(50) NOT NULL DEFAULT '', | ||
`theme` varchar(50) NOT NULL DEFAULT '', | ||
`admin` enum('0','1') NOT NULL DEFAULT '0', | ||
`language` char(20) NOT NULL DEFAULT '', | ||
`root_folder_name` char(50) NOT NULL DEFAULT 'My Bookmarks', | ||
`column_width_folder` smallint(3) NOT NULL DEFAULT 0, | ||
`column_width_bookmark` smallint(3) NOT NULL DEFAULT 0, | ||
`table_height` smallint(3) NOT NULL DEFAULT 0, | ||
`confirm_delete` enum('0','1') NOT NULL DEFAULT '1', | ||
`open_new_window` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_bookmark_description` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_bookmark_icon` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_date` enum('0','1') NOT NULL DEFAULT '1', | ||
`date_format` smallint(6) NOT NULL DEFAULT 0, | ||
`show_column_edit` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_move` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_delete` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_folder_minus` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_folder_plus` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_symbol` enum('0','1') NOT NULL DEFAULT '1', | ||
`simple_tree_mode` enum('0','1') NOT NULL DEFAULT '0', | ||
`show_public` enum('0','1') NOT NULL DEFAULT '1', | ||
`private_mode` enum('0','1') NOT NULL DEFAULT '1', | ||
`notes` varchar(512) DEFAULT NULL, | ||
UNIQUE KEY `id` (`username`) | ||
) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
CREATE TABLE `obm_bookmarks` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`childof` int(11) NOT NULL DEFAULT 0, | ||
`user` char(20) NOT NULL DEFAULT '', | ||
`title` varchar(200) NOT NULL DEFAULT '', | ||
`url` varchar(512) NOT NULL DEFAULT '', | ||
`description` longtext DEFAULT NULL, | ||
`deleted` enum('0','1') NOT NULL DEFAULT '0', | ||
`favicon` varchar(1048) DEFAULT NULL, | ||
`private` enum('0','1') DEFAULT NULL, | ||
`public` enum('0','1') NOT NULL DEFAULT '0', | ||
`last_visit` datetime DEFAULT NULL, | ||
`date` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
`date_created` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', | ||
PRIMARY KEY (`id`), | ||
FULLTEXT KEY `title` (`title`,`url`,`description`) | ||
) ENGINE=Aria AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; | ||
|
||
|
||
CREATE TABLE `obm_folders` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`childof` int(11) NOT NULL DEFAULT 0, | ||
`name` char(70) NOT NULL DEFAULT '', | ||
`user` char(20) NOT NULL DEFAULT '', | ||
`deleted` enum('0','1') NOT NULL DEFAULT '0', | ||
`public` enum('0','1') NOT NULL DEFAULT '0', | ||
UNIQUE KEY `id` (`id`) | ||
) ENGINE=Aria AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; | ||
|
||
|
||
CREATE TABLE `obm_users` ( | ||
`username` char(50) NOT NULL DEFAULT '', | ||
`password` char(50) NOT NULL DEFAULT '', | ||
`theme` varchar(50) NOT NULL DEFAULT '', | ||
`admin` enum('0','1') NOT NULL DEFAULT '0', | ||
`language` char(20) NOT NULL DEFAULT '', | ||
`root_folder_name` char(50) NOT NULL DEFAULT 'My Bookmarks', | ||
`column_width_folder` smallint(3) NOT NULL DEFAULT 0, | ||
`column_width_bookmark` smallint(3) NOT NULL DEFAULT 0, | ||
`table_height` smallint(3) NOT NULL DEFAULT 0, | ||
`confirm_delete` enum('0','1') NOT NULL DEFAULT '1', | ||
`open_new_window` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_bookmark_description` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_bookmark_icon` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_date` enum('0','1') NOT NULL DEFAULT '1', | ||
`date_format` smallint(6) NOT NULL DEFAULT 0, | ||
`show_column_edit` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_move` enum('0','1') NOT NULL DEFAULT '1', | ||
`show_column_delete` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_folder_minus` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_folder_plus` enum('0','1') NOT NULL DEFAULT '1', | ||
`fast_symbol` enum('0','1') NOT NULL DEFAULT '1', | ||
`simple_tree_mode` enum('0','1') NOT NULL DEFAULT '0', | ||
`show_public` enum('0','1') NOT NULL DEFAULT '1', | ||
`private_mode` enum('0','1') NOT NULL DEFAULT '1', | ||
`notes` varchar(512) DEFAULT NULL, | ||
UNIQUE KEY `id` (`username`) | ||
) ENGINE=Aria DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci PAGE_CHECKSUM=1; |
Oops, something went wrong.