summaryrefslogtreecommitdiff
path: root/cli_util.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-01-31 06:11:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-01-31 20:45:40 +0300
commitc0dc531ebefd8912819f3b6c8bda1fed3c7e750c (patch)
tree2c75aa9df182260aef09faf4befd81a4c2b9c5e2 /cli_util.php
parent48d688cdf7f9eae1bf11b8a6f0e5b98687c604cb (diff)
make it simple, but not simpler
Diffstat (limited to 'cli_util.php')
-rwxr-xr-xcli_util.php20
1 files changed, 10 insertions, 10 deletions
diff --git a/cli_util.php b/cli_util.php
index 0c42bb5..e883ae7 100755
--- a/cli_util.php
+++ b/cli_util.php
@@ -4,12 +4,13 @@
namespace cli_util;
use cli;
+use pages;
use posts;
+use tags;
use uploads;
-use pages;
-use config;
require_once __DIR__.'/init.php';
+require_once 'lib/stored_config.php';
$cli = new cli(__NAMESPACE__);
$cli->run();
@@ -24,18 +25,18 @@ function admin_reset(): void {
if (trim($pwd1) == '')
cli::die("Password can not be empty");
- if (!config::set('admin_pwd', salt_password($pwd1)))
+ if (!scSet('admin_pwd', salt_password($pwd1)))
cli::die("Database error");
}
function admin_check(): void {
- $pwd = config::get('admin_pwd');
+ $pwd = scGet('admin_pwd');
echo is_null($pwd) ? "Not set" : $pwd;
echo "\n";
}
function blog_erase(): void {
- $db = getDb();
+ $db = DB();
$tables = ['posts', 'posts_tags', 'tags'];
foreach ($tables as $t) {
$db->query("TRUNCATE TABLE $t");
@@ -43,14 +44,14 @@ function blog_erase(): void {
}
function tags_recount(): void {
- $tags = posts::getAllTags(true);
+ $tags = tags::getAll(true);
foreach ($tags as $tag)
- posts::recountPostsWithTag($tag->id);
+ posts::tagsRecountPosts($tag->id);
}
function posts_html(): void {
$kw = ['include_hidden' => true];
- $posts = posts::getPosts(0, posts::getPostsCount(...$kw), ...$kw);
+ $posts = posts::getList(0, posts::getCount(...$kw), ...$kw);
foreach ($posts as $p) {
$p->updateHtml();
$p->updateText();
@@ -59,7 +60,7 @@ function posts_html(): void {
function posts_images(): void {
$kw = ['include_hidden' => true];
- $posts = posts::getPosts(0, posts::getPostsCount(...$kw), ...$kw);
+ $posts = posts::getList(0, posts::getCount(...$kw), ...$kw);
foreach ($posts as $p) {
$p->updateImagePreviews(true);
}
@@ -77,7 +78,6 @@ function add_files_to_uploads(): void {
if (!file_exists($path))
cli::die("file $path doesn't exists");
$name = basename($path);
- $ext = extension($name);
$id = uploads::add($path, $name, '');
echo "upload id: $id\n";
}