Enabled user registration
This commit is contained in:
@@ -16,6 +16,7 @@ abstract class Server {
|
||||
private $mo = NULL; // Our Mode object
|
||||
private $co = NULL;
|
||||
protected $blp = 0; // Size of Bottom Line Pollution
|
||||
protected $baseline = ''; // Whats on the baseline currently
|
||||
protected $pid = NULL; // Client PID
|
||||
|
||||
public function __construct(Mode $o)
|
||||
@@ -40,6 +41,9 @@ abstract class Server {
|
||||
define('ACTION_SUBMITRF', 7); // Offer to submit a response frame
|
||||
define('ACTION_STAR', 8);
|
||||
|
||||
define('CONTROL_TELNET', 1); // Telnet session control
|
||||
define('CONTROL_METHOD', 2); // Send input to an external method
|
||||
|
||||
// Keyboard presses
|
||||
define('KEY_DELETE', chr(8));
|
||||
define('KEY_LEFT', chr(136));
|
||||
@@ -114,9 +118,7 @@ abstract class Server {
|
||||
|
||||
// We are now the child.
|
||||
try {
|
||||
$session_init = $session_option = FALSE;
|
||||
$session_note = ''; // TCP Session Notice
|
||||
$session_term = ''; // TCP Terminal Type
|
||||
$session = NULL; // TCP Session Details
|
||||
|
||||
$client->send(TCP_IAC . TCP_DO . TCP_OPT_SUP_GOAHEAD); // DO SUPPRES GO AHEAD
|
||||
$client->send(TCP_IAC . TCP_WONT . TCP_OPT_LINEMODE); // WONT LINEMODE
|
||||
@@ -134,6 +136,8 @@ abstract class Server {
|
||||
$cmd = ''; // Current *command being typed in
|
||||
$mode = FALSE; // Current mode.
|
||||
$user = new User; // The logged in user
|
||||
$control = FALSE; // Logic in control
|
||||
$method = collect(); // Method in control for CONTROL_METHOD
|
||||
|
||||
$current = []; // Attributes about the current page
|
||||
// field/fieldnum indexes are for fields on the active page
|
||||
@@ -161,85 +165,52 @@ abstract class Server {
|
||||
$read = NULL;
|
||||
|
||||
if ($read != '') {
|
||||
// Client initiation input
|
||||
// TELNET http://pcmicro.com/netfoss/telnet.html
|
||||
if ($read == TCP_IAC OR $session_init OR $session_option) {
|
||||
$this->log('debug',sprintf('Session Char (%s)',ord($read)),['init'=>$session_init,'option'=>$session_option]);
|
||||
if ($read == TCP_IAC) {
|
||||
|
||||
switch ($read) {
|
||||
// Command being sent.
|
||||
case TCP_IAC:
|
||||
$session_init = TRUE;
|
||||
$session_note = 'IAC ';
|
||||
// If we are not already in a TELNET LOOP
|
||||
if ($control !== CONTROL_TELNET) {
|
||||
$control = CONTROL_TELNET;
|
||||
|
||||
continue 2;
|
||||
// Remember our Telnet Session Object
|
||||
// @todo We might need to clear out the old mode/action states
|
||||
if (! $session) {
|
||||
$session = Control::factory('telnet',$this);
|
||||
}
|
||||
|
||||
case TCP_SB:
|
||||
$session_option = TRUE;
|
||||
$method->push($session);
|
||||
}
|
||||
}
|
||||
|
||||
continue 2;
|
||||
if ($control AND $method->count()) {
|
||||
printf("= Control going to method: %s\n", get_class($method->last()));
|
||||
|
||||
case TCP_SE:
|
||||
$session_option = $session_init = FALSE;
|
||||
$this->log('debug',sprintf('Session Terminal: %s',$session_term));
|
||||
$read = '';
|
||||
// Capture our state when we enter this method.
|
||||
if (! array_key_exists('control',$method->last()->state)) {
|
||||
$method->last()->state['control'] = $control;
|
||||
$method->last()->state['action'] = $action;
|
||||
}
|
||||
|
||||
break;
|
||||
$method->last()->state['mode'] = $mode;
|
||||
$action = FALSE;
|
||||
|
||||
case TCP_DO:
|
||||
$session_note .= 'DO ';
|
||||
// Pass Control to Method
|
||||
$read = $method->last()->handle($read,$current);
|
||||
$mode = $method->last()->state['mode'];
|
||||
|
||||
continue 2;
|
||||
if ($method->last()->complete()) {
|
||||
printf("- Control complete: %s\n",get_class($method->last()));
|
||||
$save = $method->pop();
|
||||
|
||||
case TCP_WILL:
|
||||
$session_note .= 'WILL ';
|
||||
if ($method->count()) {
|
||||
$control = $method->last()->state['control'];
|
||||
|
||||
continue 2;
|
||||
} else {
|
||||
$mode = $save->state['mode'];
|
||||
$action = $save->state['action'];
|
||||
$control = FALSE;
|
||||
}
|
||||
|
||||
case TCP_WONT:
|
||||
$session_note .= 'WONT ';
|
||||
|
||||
continue 2;
|
||||
|
||||
case TCP_OPT_TERMTYPE:
|
||||
|
||||
continue 2;
|
||||
|
||||
case TCP_OPT_ECHO:
|
||||
$session_note .= 'ECHO';
|
||||
$session_init = FALSE;
|
||||
$read = '';
|
||||
|
||||
$this->log('debug',sprintf('Session Note: %s',$session_note));
|
||||
|
||||
continue;
|
||||
|
||||
case TCP_OPT_SUP_GOAHEAD:
|
||||
$session_note .= 'SUPPRESS GO AHEAD';
|
||||
$session_init = FALSE;
|
||||
$read = '';
|
||||
|
||||
$this->log('debug',sprintf('Session Note: %s',$session_note));
|
||||
|
||||
continue;
|
||||
|
||||
case TCP_OPT_WINDOWSIZE:
|
||||
$session_note .= 'WINDOWSIZE';
|
||||
$session_init = FALSE;
|
||||
$read = '';
|
||||
|
||||
$this->log('debug',sprintf('Session Note: %s',$session_note));
|
||||
|
||||
continue;
|
||||
|
||||
default:
|
||||
if ($session_option AND $read) {
|
||||
$session_term .= $read;
|
||||
$read = '';
|
||||
|
||||
} else {
|
||||
$this->log('debug',sprintf('Unhandled char in session_init: %s (%s)',$read,ord($read)));
|
||||
}
|
||||
dump(sprintf('End: Control is now: %s: Method Count: %s',is_object($control) ? get_class($control) : serialize($control),$method->count()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,6 +232,8 @@ abstract class Server {
|
||||
{
|
||||
$action = ACTION_GOTO;
|
||||
$page = ['frame'=>'981']; // @todo This should be in the DB.
|
||||
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,6 +276,7 @@ abstract class Server {
|
||||
$action = ACTION_STAR;
|
||||
$current['fieldpos'] = 0;
|
||||
$fielddata[$current['fieldnum']] = '';
|
||||
$current['fielddata'][$current['fieldnum']] = '';
|
||||
|
||||
break;
|
||||
|
||||
@@ -312,6 +286,7 @@ abstract class Server {
|
||||
$current['fieldpos']--;
|
||||
$client->send(LEFT.$fo::$if_filler.LEFT);
|
||||
$fielddata[$current['fieldnum']] = substr($fielddata[$current['fieldnum']],0,-1);
|
||||
$current['fielddata'][$current['fieldnum']] = substr($current['fielddata'][$current['fieldnum']],0,-1);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -360,15 +335,19 @@ abstract class Server {
|
||||
break;
|
||||
|
||||
case ESC:
|
||||
break;;
|
||||
break;
|
||||
|
||||
// Record Data Entry
|
||||
default:
|
||||
if (ord($read) > 31 && $current['fieldpos'] < $current['field']->length) {
|
||||
if (! array_get($fielddata,$current['fieldnum']))
|
||||
if (! array_key_exists($current['fieldnum'],$current['fielddata'])) {
|
||||
$current['fielddata'][$current['fieldnum']] = '';
|
||||
$fielddata[$current['fieldnum']] = '';
|
||||
}
|
||||
|
||||
$fielddata[$current['fieldnum']]{$current['fieldpos']} = $read; // @todo delete
|
||||
$current['fielddata'][$current['fieldnum']]{$current['fieldpos']} = $read;
|
||||
|
||||
$fielddata[$current['fieldnum']]{$current['fieldpos']} = $read;
|
||||
$current['fieldpos']++;
|
||||
|
||||
$client->send($fo->isFieldMasked($current['field']->type) ?: $read);
|
||||
@@ -393,7 +372,11 @@ abstract class Server {
|
||||
case '1':
|
||||
$route = $fo->route(1);
|
||||
|
||||
if ($route == '*' OR is_numeric($route)) {
|
||||
// If we are in a control method, complete it
|
||||
if ($control AND $method->count()) {
|
||||
$method->last()->process();
|
||||
|
||||
} elseif ($route == '*' OR is_numeric($route)) {
|
||||
$this->sendBaseline($client,RED.'NO ACTION PERFORMED');
|
||||
$mode = MODE_RFSENT;
|
||||
|
||||
@@ -415,9 +398,13 @@ abstract class Server {
|
||||
break;
|
||||
|
||||
case '2':
|
||||
$this->sendBaseline($client,MSG_NOTSENT);;
|
||||
$this->sendBaseline($client,MSG_NOTSENT);
|
||||
$mode = MODE_RFNOTSENT;
|
||||
|
||||
// If a Control method was rejected, we can clear it
|
||||
if ($control AND $method->count())
|
||||
$method->pop();
|
||||
|
||||
break;
|
||||
|
||||
case STAR:
|
||||
@@ -564,10 +551,11 @@ abstract class Server {
|
||||
}
|
||||
|
||||
// Toggle Timewarp Mode
|
||||
// @todo in forms, the cursor is in the wrong location for ANSI
|
||||
if ($cmd === '01') {
|
||||
$client->send(COFF);
|
||||
$timewarp = !$timewarp;
|
||||
$this->sendBaseline($client,($timewarp ? MSG_TIMEWARP_ON : MSG_TIMEWARP_OFF));
|
||||
$this->sendBaseline($client, ($timewarp ? MSG_TIMEWARP_ON : MSG_TIMEWARP_OFF));
|
||||
$cmd = '';
|
||||
$action = $mode = FALSE;
|
||||
|
||||
@@ -575,6 +563,7 @@ abstract class Server {
|
||||
}
|
||||
|
||||
// Present Timewarp Frames
|
||||
// @todo in forms, the cursor is in the wrong location for ANSI
|
||||
if ($cmd === '02') {
|
||||
$client->send(COFF);
|
||||
$action = ACTION_INFO;
|
||||
@@ -583,6 +572,14 @@ abstract class Server {
|
||||
break;
|
||||
}
|
||||
|
||||
// Report a problem
|
||||
if ($cmd === '08') {
|
||||
$this->sendBaseline($client, RED.'NOT IMPLEMENTED YET?');
|
||||
$read = STAR;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Reload page
|
||||
if ($cmd === '09') {
|
||||
$client->send(COFF);
|
||||
@@ -595,12 +592,14 @@ abstract class Server {
|
||||
// Another star aborts the command.
|
||||
if ($read === STAR) {
|
||||
$action = FALSE;
|
||||
$this->sendBaseline($client,'');
|
||||
$this->sendBaseline($client,array_get($current,'baseline',''));
|
||||
$cmd = '';
|
||||
|
||||
if ($current['prevmode'] == MODE_FIELD) {
|
||||
$mode = $current['prevmode'];
|
||||
$current['prevmode'] = FALSE;
|
||||
|
||||
// @todo The cursor color could be wrong
|
||||
$client->send($this->outputPosition($current['field']->x,$current['field']->y).CON);
|
||||
$client->send(str_repeat($fo::$if_filler, $current['field']->length));
|
||||
$current['fieldreset'] = TRUE;
|
||||
@@ -654,6 +653,10 @@ abstract class Server {
|
||||
case ACTION_STAR:
|
||||
echo "+ Star command...\n";
|
||||
|
||||
// If there is something on the baseline, lets preserve it
|
||||
if ($this->blp)
|
||||
$current['baseline'] = $this->baseline;
|
||||
|
||||
$this->sendBaseline($client,GREEN.STAR,TRUE);
|
||||
$client->send(CON);
|
||||
$action = FALSE;
|
||||
@@ -773,6 +776,8 @@ abstract class Server {
|
||||
$history->push($page);
|
||||
}
|
||||
|
||||
printf("+ Mode is: %s\n",$mode);
|
||||
|
||||
// drop into
|
||||
case ACTION_RELOAD:
|
||||
$this->sendBaseline($client,'');
|
||||
@@ -793,11 +798,25 @@ abstract class Server {
|
||||
|
||||
// Login Frame.
|
||||
case Frame::FRAMETYPE_LOGIN:
|
||||
$client->send($output);
|
||||
$output = '';
|
||||
|
||||
// If this is the registration page
|
||||
// @todo Should be evaluated out of the DB
|
||||
if ($fo->page() == '981a') {
|
||||
$control = CONTROL_METHOD;
|
||||
$method->push(Control::factory('register',$this));
|
||||
$method->last()->state['control'] = $control;
|
||||
$method->last()->state['action'] = $action;
|
||||
$method->last()->state['mode'] = MODE_FIELD;
|
||||
}
|
||||
|
||||
// Active Frame. Prestel uses this for a Response Frame.
|
||||
case Frame::FRAMETYPE_ACTION:
|
||||
$client->send($output);
|
||||
// holds data entered by user.
|
||||
$fielddata = [];
|
||||
$current['fielddata'] = [];
|
||||
|
||||
if (count($fo->fields)) {
|
||||
// Get our first editable field.
|
||||
|
Reference in New Issue
Block a user