Create MadelineCLI

This commit is contained in:
Hearot 2017-10-10 15:23:21 +02:00
commit 9ed6cad494
3 changed files with 251 additions and 0 deletions

View File

@ -0,0 +1,44 @@
<?php
if (!function_exists('readline')) {
function readline($prompt = null)
{
if ($prompt) {
echo $prompt;
}
$fp = fopen('php://stdin', 'r');
$line = rtrim(fgets($fp, 1024));
return $line;
}
}
function latinreadline($message)
{
do {
if (isset($res)) {
echo 'Only latin letters, numbers, dashes (-) and underscores (_) can be used!' . PHP_EOL;
}
$res = readline($message);
} while (!preg_match('/^[A-Za-z0-9_.-]+$/', $res));
return $res;
}
function platinreadline($message)
{
do {
if (isset($res)) {
echo 'A project with this name already exists!' . PHP_EOL;
}
$res = latinreadline($message);
} while (file_exists($res));
return $res;
}
function emailreadline($message)
{
do {
if (isset($res)) {
echo 'This is not a valid email!' . PHP_EOL;
}
$res = readline($message);
} while (!filter_var($res, FILTER_VALIDATE_EMAIL));
return $res;
}

File diff suppressed because one or more lines are too long

0
start_madelineclient.php Normal file
View File