<?php
namespace entities\evr\security\display\forms;
use entities\html as html;
use entities\evr\security as security;
class Register extends html\Form
{
public function __construct()
{
parent::__construct("register");
}
protected function build_content()
{
$key = security\Security::get_post_parameter("key");
$username = security\Security::get_post_parameter("username");
$email = security\Security::get_post_parameter("email_address");
$join = security\Security::get_post_parameter("join");
$markup = new html\Div("heading", null, $GLOBALS["REGISTRATION_HEADING"]);
$markup .= $this->build_prompt($GLOBALS["NEW_USER_NAME_PROMPT"]);
$markup .= new html\Input("username", "text", $username);
$markup .= $this->build_prompt($GLOBALS["NEW_PASSWORD_PROMPT"]);
$markup .= new html\Input("password[]", "password");
$markup .= $this->build_prompt($GLOBALS["REENTER_PASSWORD_PROMPT"]);
$markup .= new html\Input("password[]", "password");
$markup .= $this->build_prompt($GLOBALS["EMAIL_ADDRESS_PROMPT"]);
$markup .= new html\Input("email_address", "text", $email);
$markup .= new html\Checkbox("join", 1, "join", $join);
$markup .= $this->build_prompt($GLOBALS["MAILING_LIST_PROMPT"], "join");
$markup .= new html\Input(
"action", "submit", $GLOBALS["REGISTER_BUTTON_TEXT"]);
$markup .= new html\Input("key", "hidden", $key);
return $markup;
}
private function build_prompt($content, $id=null)
{
return new html\Div($id, "prompt", $content);
}
}
<?php
namespace entities\evr\security\display\forms;
use entities\html as html;
use entities\evr\security as security;
class Activate extends html\Form
{
public function __construct()
{
parent::__construct("activate");
}
protected function build_content()
{
$text = $GLOBALS["ACTIVATE_BUTTON_TEXT"];
$markup = new html\Input("key", "text", "key", "field", true);
$markup .= new html\Input("action", "submit", $text, "button");
$markup .= $this->build_hidden_fields();
return $markup;
}
private function build_hidden_fields()
{
$username = security\Security::get_post_parameter("username");
$email = security\Security::get_post_parameter("email_address");
$join = security\Security::get_post_parameter("join");
$markup = new html\Input("username", "hidden", $username);
$markup .= new html\Input("email", "hidden", $email);
$markup .= new html\Input("join", "hidden", $join);
return $markup;
}
}
<?php
namespace entities\evr\security\display\forms;
use entities\html as html;
use entities\evr\security as security;
class Reset extends html\Form
{
public function __construct()
{
parent::__construct("reset");
}
protected function build_content()
{
$markup = new html\Div("heading", null, $GLOBALS["RESET_HEADING"]);
$markup .= new html\Div(null, "prompt", $GLOBALS["RESET_PROMPT"]);
$markup .= new html\Input("username", "text");
$markup .= new html\Input(
"action", "submit", $GLOBALS["RESET_BUTTON_TEXT"]);
return $markup;
}
}
<?php
namespace entities\evr\security\display\forms;
use entities\html as html;
class Login extends \entities\html\Form
{
public function __construct()
{
parent::__construct("login");
}
protected function build_content()
{
$button_text = $GLOBALS["LOGIN_BUTTON_TEXT"];
$remember_text = $GLOBALS["REMEMBER_ME_PROMPT"];
$markup = new html\Input("username", "text", "username", "field", true);
$markup .= new html\Input(
"password", "password", "XZV897aa", "field", true);
$markup .= new html\Div("remember", null, $remember_text);
$markup .= new html\Input("remember", "checkbox", null, "remember");
$markup .= new html\Input("action", "submit", $button_text, "button");
return $markup;
}
}
<?php
namespace entities\evr\security\display\forms;
use entities\html as html;
use entities\evr\security as security;
class Change extends html\Form
{
public function __construct()
{
parent::__construct("change");
}
protected function build_content()
{
$markup = new html\Div("heading", null, $GLOBALS["CHANGE_HEADING"]);
$markup .= $this->build_prompt($GLOBALS["EXISTING_USER_NAME_PROMPT"]);
$markup .= new html\Input("username", "text");
$markup .= $this->build_prompt($GLOBALS["EXISTING_PASSWORD_PROMPT"]);
$markup .= new html\Input("old_password", "password");
$markup .= $this->build_prompt($GLOBALS["NEW_PASSWORD_PROMPT"]);
$markup .= new html\Input("password[]", "password");
$markup .= $this->build_prompt($GLOBALS["REENTER_PASSWORD_PROMPT"]);
$markup .= new html\Input("password[]", "password");
$markup .= new html\Input(
"action", "submit", $GLOBALS["CHANGE_BUTTON_TEXT"]);
return $markup;
}
private function build_prompt($content, $id=null)
{
return new html\Div($id, "prompt", $content);
}
}
<?php
namespace entities\security\operators;
class Activator
{
public function __construct($key)
{
$this->key = $key;
$this->hashes = file($GLOBALS["HASHES_PATH"], FILE_IGNORE_NEW_LINES);
$this->verify_key();
}
private function verify_key()
{
foreach ($this->hashes as $hash)
{
if ($hash == crypt($this->key, $hash))
{
echo "FOUND $this->key as $hash";
return;
}
}
echo "DIDN'T FIND $this->key";
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include "pattern.h"
#include "read.h"
char* parse_pattern(FILE* input_file, char* character)
{
char* raw_pattern = read_next_line(input_file, character);
sequence* pattern = malloc(sizeof(struct sequence));
int* ii = malloc(sizeof(int));
*ii = 0;
build_sequence(pattern, raw_pattern, ii);
print_pattern(pattern, 0);
char* sequence_array = build_array_from_sequence(pattern);
printf("%s\n\n", sequence_array);
return sequence_array;
}
void build_sequence(sequence* sequence, char* raw_pattern, int* ii)
{
int jj = 0;
char* color_order = malloc(sizeof(char));
while (raw_pattern[*ii])
{
if (isalnum(raw_pattern[*ii]))
{
if (raw_pattern[(*ii)-1] == OPEN_BRACKET || *ii == 0)
{
char* number_string = extract_word_from_string(raw_pattern, ii);
sequence->iterations = atoi(number_string);
}
else
{
color_order = append_character(color_order, raw_pattern[*ii]);
}
}
else if (raw_pattern[*ii] == CLOSE_BRACKET)
{
if (strlen(color_order) > 0) sequence->sequence = color_order;
if (raw_pattern[(*ii)+1] != CLOSE_BRACKET && raw_pattern[(*ii)+1])
{
initiate_next_sequence(sequence, raw_pattern, ii);
}
return;
}
else if (raw_pattern[*ii] == OPEN_BRACKET)
{
initiate_next_sequence(sequence, raw_pattern, ii);
}
(*ii)++;
}
if (strlen(color_order) > 0) sequence->sequence = color_order;
}
void initiate_next_sequence(sequence* sequence, char* raw_pattern, int* ii)
{
(*ii)++;
if (raw_pattern[(*ii)-1] == CLOSE_BRACKET)
{
(*ii)++;
sequence->next = malloc(sizeof(struct sequence));
build_sequence(sequence->next, raw_pattern, ii);
}
else
{
sequence->child = malloc(sizeof(struct sequence));
build_sequence(sequence->child, raw_pattern, ii);
}
}
char* extract_word_from_string(char* string, int* ii)
{
int jj;
char* word = malloc(sizeof(char));
for (jj = 0; isdigit(string[*ii]); jj++)
{
word[jj] = string[(*ii)++];
word = realloc(word, sizeof(char) * (jj+2));
}
word[jj] = '\0';
return word;
}
char* build_array_from_sequence(sequence* sequence)
{
char* sequence_array = malloc(sizeof(char));
sequence_array = add_sequence_to_array(sequence_array, sequence);
return sequence_array;
}
char* add_sequence_to_array(char* array, sequence* sequence)
{
if (sequence == NULL) return;
int ii;
for (ii = 0; ii < sequence->iterations; ii++)
{
if (sequence->sequence)
{
int new_length = strlen(array) + strlen(sequence->sequence);
array = realloc(array, sizeof(char) * (new_length+1));
strcat(array, sequence->sequence);
array[new_length] = '\0';
}
else
{
array = add_sequence_to_array(array, sequence->child);
}
}
array = add_sequence_to_array(array, sequence->next);
return array;
}
char* append_character(char* string, char character)
{
int length = strlen(string);
string = realloc(string, sizeof(char) * (length+2));
string[length] = character;
string[length+1] = '\0';
return string;
}
void print_pattern(sequence* sequence, int level)
{
if (sequence == NULL) return;
printf("%*d: ", level*3, sequence->iterations);
if (sequence->sequence)
{
printf("%s", sequence->sequence);
}
printf("\n");
print_pattern(sequence->child, level+1);
print_pattern(sequence->next, level);
}