-
Notifications
You must be signed in to change notification settings - Fork 0
/
isbn-search.php
executable file
·47 lines (41 loc) · 1.14 KB
/
isbn-search.php
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
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/php -q
<?php
################################################################################
# Author: ServerOK Software
# Web: https://serverok.in
# Email: admin@serverok.in
################################################################################
require __DIR__ . '/config.php';
if (isset($argv[1])) {
$searchString = $argv[1];
} else {
echo "Usage: isbn-search ISBN_HERE\n";
exit;
}
if (! is_dir(DIR_CSV_DONE)) {
die("ERROR:Directory not found: " . DIR_CSV_DONE . "\n");
}
$csvFiles = scandir(DIR_CSV_DONE);
$fileFound = array();
foreach ($csvFiles as $csvFile) {
if ($csvFile == '.' || $csvFile == '..') {
continue;
}
$csvFilePath = DIR_CSV_DONE . $csvFile;
if (is_dir($csvFilePath)) {
echo "SKIP $csvFile is not file\n";
continue;
}
$fileContent = file("$csvFilePath");
foreach ($fileContent as $fileLine) {
$found = strpos($fileLine, $searchString);
if ($found !== false) {
$fileFound[] = $csvFilePath;
echo "$csvFilePath\n";
break;
}
}
}
if (empty($fileFound)) {
echo "No files found with isbn\n";
}