Yioop_V9.5_Source_Code_Documentation

RegisterController extends Controller
in package
implements CrawlConstants

Controller used to handle account registration and retrieval for the Yioop website. Also handles data for suggest a url

Tags
author

Mallika Perepa (Creator), Chris Pollett (extensive rewrite)

Interfaces, Classes, Traits and Enums

CrawlConstants
Shared constants and enums used by components that are involved in the crawling process

Table of Contents

HASH_CAPTCHA_LEVEL  = 2
Use to match the leading zero in the sha1 of the string
HASH_TIMESTAMP_TIMEOUT  = 300
Define the number of seconds till hash code is valid
NUM_RECOVERY_QUESTIONS  = 3
Number of recovery questions from the complete set of questions to present someone when register for an account
$activities  : array<string|int, mixed>
Holds a list of the allowed activities. These encompass various stages of the account creation and account recovery processes
$activity_component  : array<string|int, mixed>
Associative array of activity => component activity is on, used by @see Controller::call method to actually invoke a given activity on a given component
$component_activities  : array<string|int, mixed>
Associative array of $components activities for this controller Components are collections of activities (a little like traits) which can be reused.
$component_instances  : array<string|int, mixed>
Array of instances of components used by this controller
$forbidden_usernames  : array<string|int, mixed>
Forbidden username
$model_instances  : array<string|int, mixed>
Array of instances of models used by this controller
$plugin_instances  : array<string|int, mixed>
Array of instances of indexing_plugins used by this controller
$recovery_qa  : array<string|int, mixed>
An array of triples, each triple consisting of a question of the form Which is your favorite..? followed by one of the form Which is your like the least..? followed by a string which is a comma separated choices. The values for these triples are determined via the translate function tl. So can be set under Manage Locales by editing their values for the desired locale.
$register_fields  : array<string|int, mixed>
Non-recovery question fields needed to register a Yioop account.
$view_instances  : array<string|int, mixed>
Array of instances of views used by this controller
$web_site  : WebSite
Stores a reference to the web server when Yioop runs in CLI mode, it acts as request router in non-CLI mode.
__construct()  : mixed
Besides invoking the base controller, sets up in field variables the captcha and recovery question and possible answers.
addDifferentialPrivacy()  : int
Adds to an integer, $actual_value, epsilon-noise taken from an L_1 gaussian source to centered at $actual_value to get a epsilon private, integer value.
call()  : mixed
Used to invoke an activity method of the current controller or one its components
checkCSRFTime()  : bool
Checks if the timestamp in $_REQUEST[$token_name] matches the timestamp of the last CSRF token accessed by this user for the kind of activity for which there might be a conflict.
checkCSRFToken()  : bool
Checks if the form CSRF (cross-site request forgery preventing) token matches the given user and has not expired (1 hour till expires)
checkRecoveryQuestions()  : bool
Checks whether the answers to the account recovery questions match those provided earlier by an account user
checkRequest()  : bool
Checks the request if a request is for a valid activity and if it uses the correct authorization key
clean()  : string
Used to clean strings that might be tainted as originate from the user
component()  : mixed
Dynamic loader for Component objects which might live on the current Component
convertArrayLines()  : string
Converts an array of lines of strings into a single string with proper newlines, each line having been trimmed and potentially cleaned
convertStringCleanArray()  : array<string|int, mixed>
Cleans a string consisting of lines, typically of urls into an array of clean lines. This is used in handling data from the crawl options text areas. # is treated as a comment
createAccount()  : array<string|int, mixed>
Sets up the form variables need to present the initial account creation form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field
dataIntegrityCheck()  : mixed
Add SCRIPT tags for errors to the view $data array if there were any missing fields on a create account or recover account form.
displayView()  : mixed
Send the provided view to output, drawing it with the given data variable, using the current locale for translation, and writing mode
emailVerification()  : array<string|int, mixed>
Used to verify the email sent to a user try to set up an account.
generateCSRFToken()  : string
Generates a cross site request forgery preventing token based on the provided user name, the current time and the hidden AUTH_KEY
getAccessModifiers()  : array<string|int, mixed>
Returns an array of the possible modifiers to the access to the activity in question.
getCleanFields()  : mixed
Used to clean the inputs for form variables for creating/recovering an account. It also puts in blank values for missing fields into a "MISSING" array
getCSRFTime()  : int
Used to return just the timestamp portion of the CSRF token
getIndexingPluginList()  : mixed
Used to get a list of all available indexing plugins for this Yioop instance.
getRecoveryQuestions()  : array<string|int, mixed>
Gets a list of translated recovery questions from the register view.
initializeAdFields()  : mixed
If external source advertisements are present in the output of this controller this function can be used to initialize the field variables used to write the appropriate Javascripts
model()  : mixed
Dynamic loader for Model objects which might live on the current Controller
pagingLogic()  : mixed
When an activity involves displaying tabular data (such as rows of users, groups, etc), this method might be called to set up $data fields for next, prev, and page links, it also makes the call to the model to get the row data sorted and restricted as desired. For some data sources, rather than directly make a call to the model to get the data it might be passed directly to this method.
parsePageHeadVars()  : array<string|int, mixed>
Used to parse head meta variables out of a data string provided either from a wiki page or a static page. Meta data is stored in lines before the first occurrence of END_HEAD_VARS. Head variables are name=value pairs. An example of head variable might be: title = This web page's title Anything after a semi-colon on a line in the head section is treated as a comment
parsePageHeadVarsView()  : mixed
Used to set up the head variables for and page_data of a wiki or static page associated with a view.
plugin()  : mixed
Dynamic loader for Plugin objects which might live on the current Controller
preactivityPrerequisiteCheck()  : mixed
Used to select which activity a controller will do. If the $activity is $activity_success, then this method checks the prereqs for $activity_success. If they are not met then the view $data array is updated with an error message and $activity_fail is set to be the next activity. If the prereq is met then the $activity is left as $activity_success. If $activity was not initially equal to $activity_success then this method does nothing.
processAccountData()  : array<string|int, mixed>
Used to process account data from completely filled in create account forms. Depending on the registration type: no_activation, email registration, or admin activation, either the account is immediately activated or it is created in an active state and an email to the person who could activate it is sent.
processRecoverData()  : array<string|int, mixed>
Called with the data from the initial recover form was completely provided and captcha was correct. This method sends the recover email provided the account had recover questions set otherwise sets up an error message.
processRequest()  : mixed
Main entry method for this controller. Determine which account creation/recovery activity needs to be performed. Calls the appropriate method, then sends the return $data to a view determined by that activity. $this->displayView then renders that view
recordViewSession()  : mixed
Used to store in a session which media list items have been viewed so we can put an indicator by them when the media list is rendered
recoverComplete()  : array<string|int, mixed>
This activity either verifies the recover email and sets up the appropriate data for a change password form or it verifies the change password form data and changes the password. If verifications fail, error messages are set up
recoverPassword()  : array<string|int, mixed>
Sets up the form variables need to present the initial recover account form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field
redirectLocation()  : mixed
Method to perform a 301 redirect to $location in both under web server and CLI setting
redirectWithMessage()  : mixed
Does a 301 redirect to the given location, sets a session variable to display a message when get there.
resendComplete()  : array<string|int, mixed>
This activity either verifies the recover email and sets up the appropriate data for a change password form or it verifies the change password form data and changes the password. If verifications error messages are set up
resendRegistration()  : array<string|int, mixed>
Sets up the form variables need to present the resend registration form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field
selectQuestionsAnswers()  : array<string|int, mixed>
Picks $num_select most/least questions from an array of triplets of the form a string question: Which is the most ..?, a string question: Which is the least ..?, followed by a comma separated list of choices ranked from least to most. For each question pick, $num_choices many items from the last element of the triplet are chosen.
sendActivationMail()  : mixed
Use to send the account activation email
setupGraphicalCaptchaViewData()  : mixed
Sets up the graphical captcha view Draws the string for graphical captcha
setupQuestionViewData()  : array<string|int, mixed>
Sets up the captcha question and or recovery questions in a $data associative array so that they can be drawn by the register or recover views.
suggestUrl()  : array<string|int, mixed>
Used to handle data from the suggest-a-url to crawl form (suggest_view.php). Basically, it saves any data submitted to a file which can then be imported in manageCrawls
validateHashCode()  : bool
Calculates the sha1 of a string consist of a randomString,request_time send by a server and the nonce send by a client.It checks whether the sha1 produces expected number of a leading zeroes
view()  : mixed
Dynamic loader for View objects which might live on the current Controller

Constants

HASH_CAPTCHA_LEVEL

Use to match the leading zero in the sha1 of the string

public int HASH_CAPTCHA_LEVEL = 2

HASH_TIMESTAMP_TIMEOUT

Define the number of seconds till hash code is valid

public int HASH_TIMESTAMP_TIMEOUT = 300

NUM_RECOVERY_QUESTIONS

Number of recovery questions from the complete set of questions to present someone when register for an account

public int NUM_RECOVERY_QUESTIONS = 3

Properties

$activities

Holds a list of the allowed activities. These encompass various stages of the account creation and account recovery processes

public array<string|int, mixed> $activities = ["createAccount", "emailVerification", "processAccountData", "processRecoverData", "recoverPassword", "recoverComplete", "resendComplete", "resendRegistration", "suggestUrl"]

$activity_component

Associative array of activity => component activity is on, used by @see Controller::call method to actually invoke a given activity on a given component

public array<string|int, mixed> $activity_component = []

$component_activities

Associative array of $components activities for this controller Components are collections of activities (a little like traits) which can be reused.

public static array<string|int, mixed> $component_activities = []

$component_instances

Array of instances of components used by this controller

public array<string|int, mixed> $component_instances

$forbidden_usernames

Forbidden username

public array<string|int, mixed> $forbidden_usernames = "admin moderator root"

$model_instances

Array of instances of models used by this controller

public array<string|int, mixed> $model_instances

$plugin_instances

Array of instances of indexing_plugins used by this controller

public array<string|int, mixed> $plugin_instances

$recovery_qa

An array of triples, each triple consisting of a question of the form Which is your favorite..? followed by one of the form Which is your like the least..? followed by a string which is a comma separated choices. The values for these triples are determined via the translate function tl. So can be set under Manage Locales by editing their values for the desired locale.

public array<string|int, mixed> $recovery_qa

$register_fields

Non-recovery question fields needed to register a Yioop account.

public array<string|int, mixed> $register_fields = ["first", "last", "user", "email", "password", "repassword"]

$view_instances

Array of instances of views used by this controller

public array<string|int, mixed> $view_instances = []

$web_site

Stores a reference to the web server when Yioop runs in CLI mode, it acts as request router in non-CLI mode.

public WebSite $web_site

In CLI, mode it is useful for caching files in RAM as they are read

Methods

__construct()

Besides invoking the base controller, sets up in field variables the captcha and recovery question and possible answers.

public __construct([WebSite $web_site = null ]) : mixed
Parameters
$web_site : WebSite = null

is the web server when Yioop runs in CLI mode, it acts as request router in non-CLI mode. In CLI, mode it is useful for caching files in RAM as they are read

Return values
mixed

addDifferentialPrivacy()

Adds to an integer, $actual_value, epsilon-noise taken from an L_1 gaussian source to centered at $actual_value to get a epsilon private, integer value.

public addDifferentialPrivacy(int $actual_value) : int
Parameters
$actual_value : int

number want to make private

Return values
int

$fuzzy_value number after noise added

call()

Used to invoke an activity method of the current controller or one its components

public call(string $activity[, string $modifiers = [] ]) : mixed
Parameters
$activity : string

method to invoke

$modifiers : string = []

access modifiers to executing this method

Return values
mixed

checkCSRFTime()

Checks if the timestamp in $_REQUEST[$token_name] matches the timestamp of the last CSRF token accessed by this user for the kind of activity for which there might be a conflict.

public checkCSRFTime(string $token_name[, string $action = "" ]) : bool

This is to avoid accidental replays of postings etc if the back button used.

Parameters
$token_name : string

name of a $_REQUEST field used to hold a CSRF_TOKEN

$action : string = ""

name of current action to check for conflicts

Return values
bool

whether a conflicting action has occurred.

checkCSRFToken()

Checks if the form CSRF (cross-site request forgery preventing) token matches the given user and has not expired (1 hour till expires)

public checkCSRFToken(string $token_name, string $user_id[, bool $use_name_as_passed = false ]) : bool
Parameters
$token_name : string

attribute of $_REQUEST containing CSRFToken

$user_id : string

user id of the user to check the token for

$use_name_as_passed : bool = false

whether to use $token_name as the token (if true) or to use $_REQUEST[$token_name]

Return values
bool

whether the CSRF token was valid

checkRecoveryQuestions()

Checks whether the answers to the account recovery questions match those provided earlier by an account user

public checkRecoveryQuestions(array<string|int, mixed> $user) : bool
Parameters
$user : array<string|int, mixed>

who to check recovery answers for

Return values
bool

true if only if all were correct

checkRequest()

Checks the request if a request is for a valid activity and if it uses the correct authorization key

public checkRequest() : bool
Return values
bool

whether the request was valid or not

clean()

Used to clean strings that might be tainted as originate from the user

public clean(mixed $value, mixed $type[, mixed $default = null ]) : string
Parameters
$value : mixed

tainted data

$type : mixed

type of data in value can be one of the following strings: bool, color, double, float, int, hash, or string, web-url; or it can be an array listing allowed values. If the latter, then if the value is not in the array the cleaned value will be first element of the array if $default is null

$default : mixed = null

if $value is not set default value is returned, this isn't used much since if the error_reporting is E_ALL or -1 you would still get a Notice.

Return values
string

the clean input matching the type provided

component()

Dynamic loader for Component objects which might live on the current Component

public component(string $component) : mixed
Parameters
$component : string

name of model to return

Return values
mixed

convertArrayLines()

Converts an array of lines of strings into a single string with proper newlines, each line having been trimmed and potentially cleaned

public convertArrayLines(array<string|int, mixed> $arr[, string $endline_string = " " ][, bool $clean = false ]) : string
Parameters
$arr : array<string|int, mixed>

the array of lines to be process

$endline_string : string = " "

what string should be used to indicate the end of a line

$clean : bool = false

whether to clean each line

Return values
string

a concatenated string of cleaned lines

convertStringCleanArray()

Cleans a string consisting of lines, typically of urls into an array of clean lines. This is used in handling data from the crawl options text areas. # is treated as a comment

public convertStringCleanArray(string $str[, string $line_type = "url" ]) : array<string|int, mixed>
Parameters
$str : string

contains the url data

$line_type : string = "url"

does additional cleaning depending on the type of the lines. For instance, if is "url" then a line not beginning with a url scheme will have http:// prepended.

Return values
array<string|int, mixed>

$lines an array of clean lines

createAccount()

Sets up the form variables need to present the initial account creation form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field

public createAccount() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data field correspond to values needed for account creation form

dataIntegrityCheck()

Add SCRIPT tags for errors to the view $data array if there were any missing fields on a create account or recover account form.

public dataIntegrityCheck(array<string|int, mixed> &$data) : mixed

also adds error info if try to create an existing using.

Parameters
$data : array<string|int, mixed>

contains info for the view on which the above forms are to be drawn.

Return values
mixed

displayView()

Send the provided view to output, drawing it with the given data variable, using the current locale for translation, and writing mode

public displayView(string $view, array<string|int, mixed> $data) : mixed
Parameters
$view : string

the name of the view to draw

$data : array<string|int, mixed>

an array of values to use in drawing the view

Return values
mixed

emailVerification()

Used to verify the email sent to a user try to set up an account.

public emailVerification() : array<string|int, mixed>

If the email is legit the account is activated

Return values
array<string|int, mixed>

$data will contain a SCRIPT field with the Javascript doMessage call saying whether verification was successful or not

generateCSRFToken()

Generates a cross site request forgery preventing token based on the provided user name, the current time and the hidden AUTH_KEY

public generateCSRFToken(string $user) : string
Parameters
$user : string

username to use to generate token

Return values
string

a csrf token

getAccessModifiers()

Returns an array of the possible modifiers to the access to the activity in question.

public getAccessModifiers(string $activity) : array<string|int, mixed>
Parameters
$activity : string

method to get access modifier list for

Return values
array<string|int, mixed>

of string names => translated names of the access modifiers for the method in question (if any exist).

getCleanFields()

Used to clean the inputs for form variables for creating/recovering an account. It also puts in blank values for missing fields into a "MISSING" array

public getCleanFields(array<string|int, mixed> &$data) : mixed
Parameters
$data : array<string|int, mixed>

an array of data to be sent to the view After this method is done it will have cleaned versions of the $_REQUEST variables from create or recover account forms as well as a "MISSING" field which is an array of those items which did not have values on the create/recover account form

Return values
mixed

getCSRFTime()

Used to return just the timestamp portion of the CSRF token

public getCSRFTime(string $token_name) : int
Parameters
$token_name : string

name of a $_REQUEST field used to hold a CSRF_TOKEN

Return values
int

the timestamp portion of the CSRF_TOKEN

getIndexingPluginList()

Used to get a list of all available indexing plugins for this Yioop instance.

public getIndexingPluginList() : mixed
Return values
mixed

getRecoveryQuestions()

Gets a list of translated recovery questions from the register view.

public static getRecoveryQuestions(string $register_view, string $locale) : array<string|int, mixed>

If insufficiently many questions have been translated for the current locale backfill with default locale

Parameters
$register_view : string

view with register for an account form since auto checked for string to translate, have but a list of translated recovery string there.

$locale : string

which locale to get the recovery questions for

Return values
array<string|int, mixed>

of translated recovery questions

initializeAdFields()

If external source advertisements are present in the output of this controller this function can be used to initialize the field variables used to write the appropriate Javascripts

public initializeAdFields(array<string|int, mixed> &$data[, bool $ads_off = false ]) : mixed
Parameters
$data : array<string|int, mixed>

data to be used in drawing the view

$ads_off : bool = false

whether or not ads are turned off so that this method should do nothing

Return values
mixed

model()

Dynamic loader for Model objects which might live on the current Controller

public model(string $model) : mixed
Parameters
$model : string

name of model to return

Return values
mixed

pagingLogic()

When an activity involves displaying tabular data (such as rows of users, groups, etc), this method might be called to set up $data fields for next, prev, and page links, it also makes the call to the model to get the row data sorted and restricted as desired. For some data sources, rather than directly make a call to the model to get the data it might be passed directly to this method.

public pagingLogic(array<string|int, mixed> &$data, mixed $field_or_model, string $output_field, int $default_show[, array<string|int, mixed> $search_array = [] ][, string $var_prefix = "" ][, array<string|int, mixed> $args = null ]) : mixed
Parameters
$data : array<string|int, mixed>

used to send data to the view will be updated by this method with row and paging data

$field_or_model : mixed

if an object, this is assumed to be a model and so the getRows method of this model is called to get row data, sorted and restricted according to $search_array; if a string then the row data is assumed to be in $data[$field_or_model] and pagingLogic itself does the sorting and restricting.

$output_field : string

output rows for the view will be stored in $data[$output_field]

$default_show : int

if not specified by $_REQUEST, then this will be used to determine the maximum number of rows that will be written to $data[$output_field]

$search_array : array<string|int, mixed> = []

used to sort and restrict in the getRows call or the data from $data[$field_or_model]. Each element of this is a quadruple name of a field, what comparison to perform, a value to check, and an order (ascending/descending) to sort by

$var_prefix : string = ""

if there are multiple uses of pagingLogic presented on the same view then $var_prefix can be prepended to to the $data field variables like num_show, start_row, end_row to distinguish between them

$args : array<string|int, mixed> = null

additional arguments that are passed to getRows and in turn to selectCallback, fromCallback, and whereCallback that might provide user_id, etc to further control which rows are returned

Return values
mixed

parsePageHeadVars()

Used to parse head meta variables out of a data string provided either from a wiki page or a static page. Meta data is stored in lines before the first occurrence of END_HEAD_VARS. Head variables are name=value pairs. An example of head variable might be: title = This web page's title Anything after a semi-colon on a line in the head section is treated as a comment

public parsePageHeadVars(string $page_data[, mixed $with_body = false ]) : array<string|int, mixed>
Parameters
$page_data : string

this is the actual content of a wiki or static page

$with_body : mixed = false
Return values
array<string|int, mixed>

the associative array of head variables or pair [head vars, page body]

parsePageHeadVarsView()

Used to set up the head variables for and page_data of a wiki or static page associated with a view.

public parsePageHeadVarsView(object $view, string $page_name, string $page_data) : mixed
Parameters
$view : object

View on which page data will be rendered

$page_name : string

a string name/id to associate with page. For example, might have 404 for a page about 404 errors

$page_data : string

this is the actual content of a wiki or static page

Return values
mixed

plugin()

Dynamic loader for Plugin objects which might live on the current Controller

public plugin(string $plugin) : mixed
Parameters
$plugin : string

name of Plugin to return

Return values
mixed

preactivityPrerequisiteCheck()

Used to select which activity a controller will do. If the $activity is $activity_success, then this method checks the prereqs for $activity_success. If they are not met then the view $data array is updated with an error message and $activity_fail is set to be the next activity. If the prereq is met then the $activity is left as $activity_success. If $activity was not initially equal to $activity_success then this method does nothing.

public preactivityPrerequisiteCheck(string &$activity, string $activity_success, string $activity_fail, array<string|int, mixed> &$data) : mixed
Parameters
$activity : string

current tentative activity

$activity_success : string

activity to test for and to test prereqs for.

$activity_fail : string

if prereqs not met which activity to switch to

$data : array<string|int, mixed>

data to help render the view this controller draws

Return values
mixed

processAccountData()

Used to process account data from completely filled in create account forms. Depending on the registration type: no_activation, email registration, or admin activation, either the account is immediately activated or it is created in an active state and an email to the person who could activate it is sent.

public processAccountData() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data will contain a SCRIPT field with the Javascript doMessage call saying whether this step was successful or not

processRecoverData()

Called with the data from the initial recover form was completely provided and captcha was correct. This method sends the recover email provided the account had recover questions set otherwise sets up an error message.

public processRecoverData() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data will contain a SCRIPT field with the Javascript doMessage call saying whether email sent or if there was a problem

processRequest()

Main entry method for this controller. Determine which account creation/recovery activity needs to be performed. Calls the appropriate method, then sends the return $data to a view determined by that activity. $this->displayView then renders that view

public processRequest() : mixed
Return values
mixed

recordViewSession()

Used to store in a session which media list items have been viewed so we can put an indicator by them when the media list is rendered

public recordViewSession(int $page_id, string $sub_path, string $media_name) : mixed
Parameters
$page_id : int

the id of page with media list

$sub_path : string

the resource folder on that page

$media_name : string

item to store indiicator into session for

Return values
mixed

recoverComplete()

This activity either verifies the recover email and sets up the appropriate data for a change password form or it verifies the change password form data and changes the password. If verifications fail, error messages are set up

public recoverComplete() : array<string|int, mixed>
Return values
array<string|int, mixed>

form data to be used by recover or signin views

recoverPassword()

Sets up the form variables need to present the initial recover account form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field

public recoverPassword() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data field correspond to values needed for account recovery form

redirectLocation()

Method to perform a 301 redirect to $location in both under web server and CLI setting

public redirectLocation(string $location) : mixed
Parameters
$location : string

url to redirect to

Return values
mixed

redirectWithMessage()

Does a 301 redirect to the given location, sets a session variable to display a message when get there.

public redirectWithMessage(string $message[, string $copy_fields = false ][, bool $restart = false ][, bool $use_base_url = false ]) : mixed
Parameters
$message : string

message to write

$copy_fields : string = false

$_REQUEST fields to copy for redirect

$restart : bool = false

if yioop is being run as its own server rather than under apache whether to restart this server.

$use_base_url : bool = false

set true if the base_url be included in the redirect

Return values
mixed

resendComplete()

This activity either verifies the recover email and sets up the appropriate data for a change password form or it verifies the change password form data and changes the password. If verifications error messages are set up

public resendComplete() : array<string|int, mixed>
Return values
array<string|int, mixed>

form data to be used by recover or signin views

resendRegistration()

Sets up the form variables need to present the resend registration form. If this form is submitted with missing fields, this method would also be called to set up an appropriate MISSING field

public resendRegistration() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data field correspond to values needed for account creation form

selectQuestionsAnswers()

Picks $num_select most/least questions from an array of triplets of the form a string question: Which is the most ..?, a string question: Which is the least ..?, followed by a comma separated list of choices ranked from least to most. For each question pick, $num_choices many items from the last element of the triplet are chosen.

public static selectQuestionsAnswers(array<string|int, mixed> $question_answers, int $num_select[, int $num_choices = -1 ]) : array<string|int, mixed>
Parameters
$question_answers : array<string|int, mixed>

an array t_1, t_2, t_3, t_4, where each t_i is an associative array containing the most and least arrays as described above

$num_select : int

number of triples from the list to pick for each triple pick either the most question or the least question

$num_choices : int = -1

from the list component of a triplet we we pick this many elements

Return values
array<string|int, mixed>

a pair consisting of an array of questions and possible choice for least/most, and another array of the correct answers to the least/most problem.

sendActivationMail()

Use to send the account activation email

public sendActivationMail(array<string|int, mixed> $user, array<string|int, mixed> &$data) : mixed
Parameters
$user : array<string|int, mixed>

associative array of user

$data : array<string|int, mixed>

field to be sent to view so can set sent mail interface message

Return values
mixed

setupGraphicalCaptchaViewData()

Sets up the graphical captcha view Draws the string for graphical captcha

public setupGraphicalCaptchaViewData(array<string|int, mixed> &$data) : mixed
Parameters
$data : array<string|int, mixed>

used by view to draw any dynamic content in this case we append a field "CAPTCHA_IMAGE" with a data url of the captcha to draw.

Return values
mixed

setupQuestionViewData()

Sets up the captcha question and or recovery questions in a $data associative array so that they can be drawn by the register or recover views.

public setupQuestionViewData() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data associate array with field to help the register and recover view draw themselves

suggestUrl()

Used to handle data from the suggest-a-url to crawl form (suggest_view.php). Basically, it saves any data submitted to a file which can then be imported in manageCrawls

public suggestUrl() : array<string|int, mixed>
Return values
array<string|int, mixed>

$data contains fields with the current value for the url (if set but not submitted) as well as for a captcha

validateHashCode()

Calculates the sha1 of a string consist of a randomString,request_time send by a server and the nonce send by a client.It checks whether the sha1 produces expected number of a leading zeroes

public validateHashCode() : bool
Return values
bool

true if the sha1 produces expected number of a leading zeroes.

view()

Dynamic loader for View objects which might live on the current Controller

public view(string $view) : mixed
Parameters
$view : string

name of view to return

Return values
mixed

        

Search results