initial commit

This commit is contained in:
ghost 2021-12-22 06:15:54 +02:00
parent 8784a8c57d
commit d1cd3286b0
8 changed files with 51 additions and 0 deletions

BIN
database/cloud-server.mwb Normal file

Binary file not shown.

View File

@ -0,0 +1,3 @@
<?php
require(PROJECT_DIR . '/view/index.phtml');

View File

@ -0,0 +1,20 @@
<?php
class Model {
protected $db;
public function __construct(string $database,
string $hostname,
int $port,
string $user,
string $password) {
try {
$this->db = new PDO('mysql:dbname=' . $database . ';host=' . $hostname . ';port=' . $port . ';charset=utf8', $user, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
} catch(PDOException $e) {
trigger_error($e->getMessage());
}
}
}

View File

5
src/bootstrap.php Normal file
View File

@ -0,0 +1,5 @@
<?php
require(__DIR__ . '/config.php');
require(PROJECT_DIR . '/model/model.php');

12
src/config-default.php Normal file
View File

@ -0,0 +1,12 @@
<?php
// COMMON
define('PROJECT_HOST', '');
define('PROJECT_DIR', __DIR__);
// DB
define('DB_HOSTNAME', 'localhost');
define('DB_PORT', 3306);
define('DB_DATABASE', '');
define('DB_USERNAME', '');
define('DB_PASSWORD', '');

3
src/public/index.php Normal file
View File

@ -0,0 +1,3 @@
<?php
require('../bootstrap.php');

View File

@ -0,0 +1,8 @@
<?php
function plural(int $number,
array $texts) {
$cases = [2, 0, 1, 1, 1, 2];
return $texts[(($number % 100) > 4 && ($number % 100) < 20) ? 2 : $cases[min($number % 10, 5)]];
}