-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbookmark.cgi
More file actions
37 lines (29 loc) · 758 Bytes
/
bookmark.cgi
File metadata and controls
37 lines (29 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl
require './filemin-lib.pl';
use lib './lib';
&ReadParse();
get_paths();
print_ajax_header();
$confdir = get_config_dir();
my @errors;
if(!-e $confdir) {
mkdir $confdir or push @error, "$text{'error_creating_conf'}: $!";
}
if(!-e "$confdir/.bookmarks") {
utime time, time, "$configdir/.bookmarks";
}
$bookmarks = &read_file_lines($confdir.'/.bookmarks');
# Check if already exists
my %h_bookmarks = map { $_ => 1 } @$bookmarks;
if(exists($h_bookmarks{$path})) {
push @errors, $text{'bookmark_exists'};
} else {
push @$bookmarks, $path;
}
#@bookmarks = sort(@bookmarks);
&flush_file_lines("$confdir/.bookmarks");
if (scalar(@errors) > 0) {
print status('error', \@errors);
} else {
print status('success', 1);
}