gitignore

This commit is contained in:
tp_dhu 2025-02-17 01:25:42 +00:00
parent 2785a5406f
commit 423f6ae383
2 changed files with 58 additions and 3 deletions

1
.gitignore vendored
View File

@ -4,5 +4,4 @@ downloads/
app/.env.cfg
public/tmp/
storage/
/public/test.php
public/test.php

View File

@ -1,6 +1,62 @@
<?php
$password = "pass!local";
class TicketPhraseGen {
echo password_hash($password, PASSWORD_DEFAULT);
private $opinion = ['amazing', 'cool', 'wicked', 'lovely'];
private $size = ['little', 'tiny', 'small', 'medium', 'large', 'huge', 'gigantic'];
private $age = ['young', 'old', 'ancient', 'new'];
private $shape = ['round', 'square', 'oval', 'long', 'short'];
private $color = ['red', 'orange', 'pink', 'blue', 'green', 'yellow', 'purple'];
private $origin = ['American', 'English', 'French', 'German', 'Spanish', 'Scottish', 'Welsh', 'Irish'];
private $material = ['wooden', 'silver', 'gold', 'plastic', 'glass'];
private $purpose = ['working', 'funny', 'serious', 'whittling'];
private $noun = ['ticket', 'device', 'gadget', 'system', 'dragon'];
public function convert_id_to_phrase(int $id): string {
$list = ['opinion', 'size', 'age', 'shape', 'color', 'origin', 'material', 'purpose', 'noun'];
$bases = [
'opinion' => count($this->opinion),
'size' => count($this->size),
'age' => count($this->age),
'shape' => count($this->shape),
'color' => count($this->color),
'origin' => count($this->origin),
'material' => count($this->material),
'purpose' => count($this->purpose),
'noun' => count($this->noun),
];
// perform mixed-radix conversion
$order = ['noun', 'purpose', 'material', 'origin', 'color', 'shape', 'age', 'size', 'opinion'];
$digits = [];
foreach($order as $category){
$radix = $bases[$category];
$digits[$category] = $id % $radix;
$id = intdiv($id, $radix);
}
if($id > 0){
throw new Exception("ID too large");
}
foreach($list as $k){
$phrase[] = $this->$k[$digits[$k]];
}
return implode('-', $phrase);
}
}
function generate(){
$generator = new TicketPhraseGen();
$ticket_number = 2;
$phrase = $generator->convert_id_to_phrase($ticket_number);
echo "Ticket #{$ticket_number} is {$phrase}";
}
generate();
function password_test(){
$password = "pass!local";
echo password_hash($password, PASSWORD_DEFAULT);
}