-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.php
43 lines (37 loc) · 1.15 KB
/
category.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
<?php
################################################################################
# Author: ServerOk
# Web: https://serverok.in
# Email: admin@serverok.in
################################################################################
$csvPath = __DIR__ . '/category-table.csv';
if (!file_exists($csvPath)) {
echo "$csvPath not found.\n"; exit;
}
$fileContent = file($csvPath);
$categoryMatch = array();
foreach ($fileContent as $categoryLine) {
$categoryLine = trim($categoryLine);
if (empty($categoryLine)) {
continue;
}
$categoryLineArray = explode(',,', $categoryLine);
if (count($categoryLineArray) == 2) {
$catName = trim($categoryLineArray[0]);
$catID = trim($categoryLineArray[1]);
$categoryMatch["$catName"] = $catID;
} else {
echo "SKIP: $categoryLine\n";
}
}
function getCategryID($category) {
global $categoryMatch;
$category = trim($category);
if (isset($categoryMatch["$category"])) {
$categoryID = $categoryMatch["$category"];
} else {
echo "ERROR: Category not found \"$category\"\n";
$categoryID = 0;
}
return $categoryID;
}