Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
s22-tech committed Jun 1, 2024
1 parent 2f1e5ff commit 8ccd481
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 28 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ OBM II is a rewrite of Brendan LaMarche's fantastic OpenBookmark script, to brin
<li>Update CSS</li>
<li>Add mobile view</li>
</ul>
The look of this script hasn't changed from the original, since CSS is not my strong suit. If someone would like to help update the look and feel of this script, please send a pull request.
This script works great on the desktop but it's useless on a phone. Since CSS is not my strongsuit, if anyone would like to contribute a mobile view, that would be fantastic. If you decide to submit a pull request, please keep in mind that I'm trying to keep this script as lightweight as possible, so adding jQuery and Bootstrap bundles is out of the question. Also, this script must remain self contained, so no links to 3rd-party scripts.

## Requirements
<ul>
<li>PHP 8.0 or higher</li>
<li>Imagick</li>
<li>convert (linux cli tool)</li>
<li>identify (linux cli tool)</li>
<li>php-curl extension</li>
</ul>

## Screenshots
Expand Down
2 changes: 1 addition & 1 deletion bookmarks/bookmarks.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ function list_bookmarks($bookmarks, $show_checkbox, $show_folder, $show_icon, $s

echo '<form name="bookmarks" action="" class="nav">' . PHP_EOL;

// debug_logger(name:'BOOKMARKS', variable: $bookmarks, file: __FILE__, function: __FUNCTION__);

foreach ($bookmarks as $value) {
echo '<div class="bookmark">' . PHP_EOL;
Expand Down Expand Up @@ -233,3 +232,4 @@ function list_bookmarks($bookmarks, $show_checkbox, $show_folder, $show_icon, $s
}
echo '</form>' . PHP_EOL;
}

5 changes: 1 addition & 4 deletions bookmarks/delete_bookmark.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
logged_in_only();

if (!empty($username) && $username !== 'demo') {
debug_logger(name: 'SERVER[QUERY_STRING]', variable: $_SERVER['QUERY_STRING'], file: __FILE__, function: __FUNCTION__);

$qs = ltrim($_SERVER['QUERY_STRING'], '?');
parse_str($qs, $qs_arr);

$bmlist = $qs_arr['bmlist']; // Comma separated string of bookmark ID's, e.g. 4186,4193,5825
$icons_to_delete = $qs_arr['bookmarks']; // Array of favicon name's.

debug_logger(name: 'bmlist', variable: $bmlist, file: __FILE__, function: __FUNCTION__);
debug_logger(name: 'icons_to_delete', variable: $icons_to_delete, file: __FILE__, function: __FUNCTION__);


$query_delete = sprintf("
Expand Down Expand Up @@ -57,7 +54,6 @@
unlink(DOC_ROOT .'/icons/'. $favicon);
}
else {
debug_logger(name: 'ERROR -- Favicon was not found: ', variable: $favicon, file: __FILE__, function: __FUNCTION__);
}
}
}
Expand All @@ -69,3 +65,4 @@
echo '<input type="button" value=" Cancel " onclick="self.close()">';
}


5 changes: 2 additions & 3 deletions bookmarks/delete_bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,12 @@
<br>
<?php

debug_logger(name: 'bookmarks-2', variable: $bookmarks, file: __FILE__, function: __FUNCTION__);

}
else {
message($mysql->error);
}
}

require_once(realpath(DOC_ROOT . '/footer.php'));
?>
require_once(realpath(DOC_ROOT . '/footer.inc.php'));
?>
3 changes: 1 addition & 2 deletions bookmarks/edit_bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
require_once(realpath(DOC_ROOT . '/favicon.inc.php'));
$favicon = new Favicon($used_url);
$new_fav = $favicon->favicon;
debug_logger(name:'favicon->favicon >>', variable:$new_fav, file:__FILE__, function:__FUNCTION__);
if ($new_fav) {
$update_query = sprintf("
UPDATE `obm_bookmarks`
Expand All @@ -152,7 +151,6 @@
$mysql->escape($username),
$mysql->escape($bmlist[0])
);
debug_logger(name:'bm-query', variable:$update_query, file:__FILE__, function:__FUNCTION__);
if (!$mysql->query($update_query)) {
message($mysql->error);
}
Expand Down Expand Up @@ -245,3 +243,4 @@

require_once(realpath(DOC_ROOT . '/footer.php'));
?>

11 changes: 2 additions & 9 deletions bookmarks/move_bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
require_once(realpath(dirname(__DIR__, 1) . '/header.php'));
logged_in_only();

debug_logger( name:'------------', variable: '-------', file: __FILE__, function: __FUNCTION__ );

$bmlist = set_post_num_list('bmlist'); // Returns an array.
debug_logger( name:'bmlist-1', variable: print_r($bmlist, true), file: __FILE__, function: __FUNCTION__ );

if (count($bmlist) == 0) {
$bmlist = set_get_num_list('bmlist'); // Returns an array.
debug_logger( name:'bmlist-2', variable: print_r($bmlist, true), file: __FILE__, function: __FUNCTION__ );
?>

<h2 class="title">Move bookmarks to:</h2>
Expand All @@ -18,8 +15,6 @@
<div style="width:100%; height:330px; overflow:auto;">

<?php
debug_logger( name:'bmlist-form', variable: $bmlist, file: __FILE__, function: __FUNCTION__ );
debug_logger( name:'folderid-form', variable: $folderid, file: __FILE__, function: __FUNCTION__ );
require_once(realpath(DOC_ROOT . '/folders/folder.php'));
$tree = new Folder();
$tree->make_tree(0);
Expand All @@ -42,7 +37,6 @@
<?php
}
elseif ($folderid == '') {
debug_logger( name:'folderid-empty', variable: $folderid, file: __FILE__, function: __FUNCTION__ );
message('No destination Folder selected.');
}
else {
Expand All @@ -56,15 +50,14 @@
);

if ($mysql->query($query)) {
debug_logger( name:'success', variable: $query, file: __FILE__, function: __FUNCTION__ );
echo 'Bookmarks moved.<br>'. PHP_EOL;
echo '<script> reloadclose(); </script>';
}
else {
debug_logger( name:'error', variable: $query, file: __FILE__, function: __FUNCTION__ );
message($mysql->error);
}
}

require_once(realpath(DOC_ROOT . '/footer.php'));
require_once(realpath(DOC_ROOT . '/footer.inc.php'));
?>

7 changes: 1 addition & 6 deletions bookmarks/new_bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
}
unset($_SESSION['title'], $_SESSION['url']);

debug_logger(variable:$post_url, name:'post_url', file:__FILE__, function:__FUNCTION__);

///////////////////////////
// SAVE Favicon
Expand All @@ -109,7 +108,6 @@
if ($settings['show_bookmark_icon']) {
require_once(realpath(DOC_ROOT . '/favicon.inc.php'));
$favicon = new Favicon($post_url);
debug_logger(variable:print_r($favicon, true), name:'favicon-object', file:__FILE__, function:__FUNCTION__);

if (!empty($favicon->favicon)) {
$update_query = sprintf("
Expand All @@ -121,16 +119,13 @@
$mysql->escape($username),
$mysql->escape($bm_id)
);
debug_logger(variable:$update_query, name:'update-query', file:__FILE__, function:__FUNCTION__);
if (!$mysql->query($update_query)) {
message($mysql->error);
}
$icon = '<img src="/icons/'.$favicon->favicon.'">';
}
else {
$icon = $bookmark_image;
debug_logger(variable:$icon, name:'favicon->favicon was NOT set', file:__FILE__, function:__FUNCTION__);
debug_logger(variable:debug_backtrace(), name:'debug_backtrace()', file:__FILE__, function:__FUNCTION__);
}
}

Expand All @@ -148,4 +143,4 @@
}
}
require_once(realpath(DOC_ROOT . '/footer.php'));
?>
?>
4 changes: 2 additions & 2 deletions lib/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function message($message) {
if (isset($message)) {
echo '<p>' . $message . '</p>';
}
require_once(realpath(DOC_ROOT . '/footer.php'));
require_once(realpath(DOC_ROOT . '/footer.inc.php'));
}


Expand All @@ -45,7 +45,7 @@ function logged_in_only() {
if (empty($_SESSION['logged_in']) || ! $_SESSION['logged_in']) {
global $auth;
$auth->display_login_form();
require_once(realpath(DOC_ROOT . '/footer.php'));
require_once(realpath(DOC_ROOT . '/footer.inc.php'));
}
}

Expand Down

0 comments on commit 8ccd481

Please sign in to comment.