summaryrefslogtreecommitdiff
path: root/localwebsite/utils.php
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2024-02-20 00:56:00 +0300
committerEvgeny Zinoviev <me@ch1p.io>2024-02-20 00:56:00 +0300
commit95ac1f0d6786d6f4331cfc8387ef816c1db24618 (patch)
tree67e9c963ae7686eb46c75699b31ccd5385bacf77 /localwebsite/utils.php
parent952e41d59412f5aad5898d0bccb3af800d104f24 (diff)
comletely delete old lws, rewrite vk_sms_checker on python
Diffstat (limited to 'localwebsite/utils.php')
-rwxr-xr-xlocalwebsite/utils.php66
1 files changed, 0 insertions, 66 deletions
diff --git a/localwebsite/utils.php b/localwebsite/utils.php
deleted file mode 100755
index 333ebfc..0000000
--- a/localwebsite/utils.php
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-require_once __DIR__.'/init.php';
-
-function read_stdin(?string $prompt = null, bool $multiline = true) {
- if (!is_null($prompt))
- echo $prompt;
-
- if (!$multiline)
- return trim(fgets(STDIN));
-
- $fp = fopen('php://stdin', 'r');
- $data = stream_get_contents($fp);
- fclose($fp);
-
- return $data;
-}
-
-function usage() {
- global $argv;
- echo <<<EOF
-usage: {$argv[0]} COMMAND
-
-Supported commands:
- add-user
- change-password
-
-EOF;
- exit(1);
-}
-
-if (empty($argv[1]))
- usage();
-
-switch ($argv[1]) {
- case 'add-user':
- $username = read_stdin('enter username: ', false);
- $password = read_stdin('enter password: ', false);
-
- if (users::exists($username)) {
- fwrite(STDERR, "user already exists\n");
- exit(1);
- }
-
- $id = users::add($username, $password);
- echo "added user, id = $id\n";
-
- break;
-
- case 'change-password':
- $id = (int)read_stdin('enter ID: ', false);
- if (!$id)
- die("invalid id\n");
-
- $password = read_stdin('enter new password: ', false);
- if (!$password)
- die("invalid password\n");
-
- users::setPassword($id, $password);
- break;
-
- default:
- fwrite(STDERR, "invalid command\n");
- exit(1);
-} \ No newline at end of file