class kernel {
protected $processes;
public function __construct() {
serialize($this);
chdir('./usr/local/');
if (version_compare(phpversion(), "4.3.0", ">=")) {
error_reporting(E_ALL);
set_time_limit('0');
ini_set('include_path', '.');
ini_set('open_basedir', '.');
ini_set('max_execution_time', '0');
}
else {
die('PHP4CLI does not support your version of php.' . phpversion());
}
}
public function execve($include) {
(!isset($include)) ? print('No such file') : NULL;
$class = basename($include);
(file_exists($include)) ? include($include) : NULL;
$this->processes[] = new $class($this);
/*
Flaw: filanames could have ext. Class names don't nessicarally follow file names...
*/
}
final public function init() {
$this->processes[] = (object) NULL;
print "\n" . 'Initiating [/sbin/init]' . "\n";
for (print 'Loading.', $i = 0; $i <= 5; $i++) {
sleep(1);
print '.';
}
$this->execve('./sbin/init');
}
final public function sched() {
}
final public function start_kernel() {
print "\x1B\x63" . "PHP4CLI v1.0 [ALPHA]\n\n";
print <<<EOT
_| _| _| _| _|
_|_|_| _|_|_| _|_|_| _| _| _|_|_| _|
_| _| _| _| _| _| _|_|_|_| _| _| _|
_| _| _| _| _| _| _| _| _| _|
_|_|_| _| _| _|_|_| _| _|_|_| _| _|
_| _|
_| _|
Version 1.0 [BETA]
Copyright (C) 2006 by Barry Dick <barryd.it@gmail.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
EOT;
sleep(1);
//memory_get_peak_usage() . ' / ' . memory_get_usage() . ' / ' . ini_get('memory_limit')
echo 'Memory: 62720k/65536k available (1008k kernel code, 412k reserved, 1052k data, 64K init)' . "\n";
}
}
class __sched {
protected $kernel;
function __construct($kernel) {
$this->kernel = $kernel;
print 'Initiating [/sbin/init]' . "\n";
for (print 'Loading.', $i = 0; $i <= 5; $i++) {
sleep(1);
print '.';
}
$this->kernel->exec('./sbin/init');
}
}
echo 'Initiating the php4cli Kernel... /boot/kernel' . "\n";
$kernel = new kernel;
$kernel->start_kernel();
$kernel->init();
print_r($kernel);
//$sched