statics data
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
$CONFIG = require 'config.php';
|
||||
|
||||
$dsn = "mysql:host=" . $CONFIG['host'] . ";dbname=" . $CONFIG['database'] . ";charset=utf8";
|
||||
$opt = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
$PDO = new PDO($dsn, $CONFIG['user'], $CONFIG['password'], $opt);
|
||||
20
www/internals/base.php
Normal file
20
www/internals/base.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
|
||||
|
||||
$CONFIG = require 'config.php';
|
||||
|
||||
$PDO = NULL;
|
||||
|
||||
function connect()
|
||||
{
|
||||
global $CONFIG;
|
||||
global $PDO;
|
||||
|
||||
$dsn = "mysql:host=" . $CONFIG['host'] . ";dbname=" . $CONFIG['database'] . ";charset=utf8";
|
||||
$opt = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::ATTR_EMULATE_PREPARES => false,
|
||||
];
|
||||
|
||||
$PDO = new PDO($dsn, $CONFIG['user'], $CONFIG['password'], $opt);
|
||||
}
|
||||
33
www/internals/blog.php
Normal file
33
www/internals/blog.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class Blog
|
||||
{
|
||||
public static function listAll()
|
||||
{
|
||||
return
|
||||
[
|
||||
[ 'id' => 5, 'date' => '2009-04-08', 'visible' => true, 'title' => 'Beginning the log', 'fragment' => 'initial.md', 'type' => 'plain', 'cat' => 'log' ],
|
||||
[ 'id' => 6, 'date' => '2009-05-01', 'visible' => false, 'title' => 'Mess with the best ...', 'fragment' => 'hack.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 4, 'date' => '2009-06-22', 'visible' => true, 'title' => 'New Layout!', 'fragment' => 'newlayout.txt', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 10, 'date' => '2009-06-28', 'visible' => true, 'title' => '"FUN" update', 'fragment' => 'funupdate.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 11, 'date' => '2009-07-05', 'visible' => true, 'title' => 'New Download: LAN Control 2.0', 'fragment' => 'lancontrol.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 12, 'date' => '2009-09-07', 'visible' => false, 'title' => 'Airline BSOD', 'fragment' => 'bsod.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 13, 'date' => '2009-11-22', 'visible' => true, 'title' => 'Spammers gonna spam', 'fragment' => 'spammers.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 15, 'date' => '2012-04-14', 'visible' => true, 'title' => 'New Download: Infinity Tournament', 'fragment' => 'inftournament.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 16, 'date' => '2012-05-27', 'visible' => true, 'title' => 'New Download: Borderline Defense', 'fragment' => 'borderlinedef.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 17, 'date' => '2012-05-28', 'visible' => true, 'title' => 'Big clean up', 'fragment' => 'cleanup.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 18, 'date' => '2013-01-03', 'visible' => true, 'title' => 'New Download: Crystal Grid', 'fragment' => 'crystalgrid.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 2, 'date' => '2014-05-14', 'visible' => true, 'title' => 'Let\'s do Befunge-93', 'fragment' => 'befunge93.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
[ 'id' => 14, 'date' => '2014-06-30', 'visible' => true, 'title' => 'Language changes', 'fragment' => 'language.txt', 'type' => 'plain', 'cat' => 'log' ],
|
||||
[ 'id' => 1, 'date' => '2014-07-10', 'visible' => true, 'title' => 'Project Euler with Befunge', 'fragment' => '', 'type' => 'euler', 'cat' => 'blog' ],
|
||||
[ 'id' => 3, 'date' => '2014-07-15', 'visible' => true, 'title' => '.Net format specifier Cheat Sheet', 'fragment' => 'net_format_spec.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
[ 'id' => 19, 'date' => '2014-08-04', 'visible' => true, 'title' => 'I am Number Four', 'fragment' => 'v4.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 7, 'date' => '2014-09-28', 'visible' => true, 'title' => 'My BFJoust arena and battle-bot', 'fragment' => 'bfjoust.php', 'type' => 'php', 'cat' => 'blog' ],
|
||||
[ 'id' => 8, 'date' => '2014-11-05', 'visible' => true, 'title' => 'Rapla Enhancement Script', 'fragment' => 'rapla_css.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
[ 'id' => 20, 'date' => '2015-01-09', 'visible' => true, 'title' => 'More Befunge with Project Euler', 'fragment' => 'more_euler.md', 'type' => 'markdown', 'cat' => 'log' ],
|
||||
[ 'id' => 9, 'date' => '2016-10-22', 'visible' => true, 'title' => 'A complete sudoku solver in Befunge-93', 'fragment' => 'sudoku_befunge.md', 'type' => 'markdown', 'cat' => 'blog' ],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
36
www/internals/euler.php
Normal file
36
www/internals/euler.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
|
||||
|
||||
class Euler
|
||||
{
|
||||
public static function readSingle($f)
|
||||
{
|
||||
$a = require $f;
|
||||
$a['rating'] = self::rateTime($a);
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function listAll()
|
||||
{
|
||||
$files = glob(__DIR__ . '/../statics/euler/euler_*.php');
|
||||
|
||||
return array_map('self::readSingle', $files);
|
||||
}
|
||||
|
||||
public static function rateTime($problem)
|
||||
{
|
||||
if ($problem['time'] < 100) // < 100ms
|
||||
return 0;
|
||||
|
||||
if ($problem['time'] < 15 * 1000) // < 5s
|
||||
return 1;
|
||||
|
||||
if ($problem['time'] < 60 * 1000) // < 1min
|
||||
return 2;
|
||||
|
||||
if ($problem['time'] < 5 * 60 * 1000) // < 5min
|
||||
return 3;
|
||||
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
17
www/internals/programs.php
Normal file
17
www/internals/programs.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php if(count(get_included_files()) ==1) exit("Direct access not permitted.");
|
||||
|
||||
class Programs
|
||||
{
|
||||
public static function readSingle($f)
|
||||
{
|
||||
$a = require $f;
|
||||
return $a;
|
||||
}
|
||||
|
||||
public static function listAll()
|
||||
{
|
||||
$files = glob(__DIR__ . '/../statics/programs/*.php');
|
||||
|
||||
return array_map(readSingle, $files);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user