Browse Source

initial commit

main
ghost 3 years ago
parent
commit
d1cd3286b0
  1. BIN
      database/cloud-server.mwb
  2. 3
      src/application/controller/index.php
  3. 20
      src/application/model/model.php
  4. 0
      src/application/view/index.phtml
  5. 5
      src/bootstrap.php
  6. 12
      src/config-default.php
  7. 3
      src/public/index.php
  8. 8
      src/system/helper/common.php

BIN
database/cloud-server.mwb

Binary file not shown.

3
src/application/controller/index.php

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

20
src/application/model/model.php

@ -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());
}
}
}

0
src/application/view/index.phtml

5
src/bootstrap.php

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

12
src/config-default.php

@ -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

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

8
src/system/helper/common.php

@ -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)]];
}
Loading…
Cancel
Save