NUM_RECOVERY_QUESTIONS
NUM_RECOVERY_QUESTIONS
Number of recovery questions from the complete set of questions to present someone when register for an account
Controller used to handle account registration and retrieval for the Yioop website. Also handles data for suggest a url
$web_site : \seekquarry\yioop\controllers\seekquarry\yioop\library\WebSite
Stores a reference to 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
$recovery_qa : array
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.
__construct(\seekquarry\yioop\controllers\seekquarry\yioop\library\WebSite $web_site = null)
Besides invoking the base controller, sets up in field variables the captcha and recovery question and possible answers.
\seekquarry\yioop\controllers\seekquarry\yioop\library\WebSite | $web_site | 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 |
redirectWithMessage(string $message, string $copy_fields = false, boolean $restart = false)
Does a 301 redirect to the given location, sets a session variable to display a message when get there.
string | $message | message to write |
string | $copy_fields | $_REQUEST fields to copy for redirect |
boolean | $restart | if yioop is being run as its own server rather than under apache whether to restart this server. |
pagingLogic(\seekquarry\yioop\controllers\array& $data, mixed $field_or_model, string $output_field, integer $default_show, array $search_array = array(), string $var_prefix = "", array $args = null)
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.
\seekquarry\yioop\controllers\array& | $data | used to send data to the view will be updated by this method with row and paging data |
mixed | $field_or_model | 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. |
string | $output_field | output rows for the view will be stored in $data[$output_field] |
integer | $default_show | 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] |
array | $search_array | 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 |
string | $var_prefix | 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 |
array | $args | 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 |
checkCSRFToken(string $token_name, string $user) : boolean
Checks if the form CSRF (cross-site request forgery preventing) token matches the given user and has not expired (1 hour till expires)
string | $token_name | attribute of $_REQUEST containing CSRFToken |
string | $user | user id |
whether the CSRF token was valid
checkCSRFTime(string $token_name, string $action = "") : boolean
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.
This is to avoid accidental replays of postings etc if the back button used.
string | $token_name | name of a $_REQUEST field used to hold a CSRF_TOKEN |
string | $action | name of current action to check for conflicts |
whether a conflicting action has occurred.
clean(mixed $value, mixed $type, mixed $default = null) : string
Used to clean strings that might be tainted as originate from the user
mixed | $value | tainted data |
mixed | $type | 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 |
mixed | $default | 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. |
the clean input matching the type provided
convertArrayLines(array $arr, string $endline_string = "\n", boolean $clean = false) : string
Converts an array of lines of strings into a single string with proper newlines, each line having been trimmed and potentially cleaned
array | $arr | the array of lines to be process |
string | $endline_string | what string should be used to indicate the end of a line |
boolean | $clean | whether to clean each line |
a concatenated string of cleaned lines
convertStringCleanArray(string $str, string $line_type = "url") : \seekquarry\yioop\controllers\$lines
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
string | $str | contains the url data |
string | $line_type | 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. |
an array of clean lines
parsePageHeadVarsView(object $view, string $page_name, string $page_data)
Used to set up the head variables for and page_data of a wiki or static page associated with a view.
object | $view | View on which page data will be rendered |
string | $page_name | a string name/id to associate with page. For example, might have 404 for a page about 404 errors |
string | $page_data | this is the actual content of a wiki or static page |
parsePageHeadVars(string $page_data, $with_body = false) : array
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
string | $page_data | this is the actual content of a wiki or static page |
$with_body |
the associative array of head variables or pair [head vars, page body]
initializeAdFields(\seekquarry\yioop\controllers\array& $data, boolean $ads_off = false)
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
\seekquarry\yioop\controllers\array& | $data | data to be used in drawing the view |
boolean | $ads_off | whether or not ads are turned off so that this method should do nothing |
addDifferentialPrivacy(integer $actual_value) : integer
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.
integer | $actual_value | number want to make private |
$fuzzy_value number after noise added
recordViewSession(integer $page_id, string $sub_path, string $media_name)
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
integer | $page_id | the id of page with media list |
string | $sub_path | the resource folder on that page |
string | $media_name | item to store indiicator into session for |
createAccount() : array
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
$data field correspond to values needed for account creation form
processAccountData() : array
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.
$data will contain a SCRIPT field with the Javascript doMessage call saying whether this step was successful or not
recoverPassword() : array
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
$data field correspond to values needed for account recovery form
processRecoverData() : array
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.
$data will contain a SCRIPT field with the Javascript doMessage call saying whether email sent or if there was a problem
recoverComplete() : array
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
form data to be used by recover or signin views
resendRegistration() : array
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
$data field correspond to values needed for account creation form
resendComplete() : array
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
form data to be used by recover or signin views
suggestUrl() : array
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
$data contains fields with the current value for the url (if set but not submitted) as well as for a captcha
setupQuestionViewData() : array
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.
$data associate array with field to help the register and recover view draw themselves
setupGraphicalCaptchaViewData(\seekquarry\yioop\controllers\array& $data)
Sets up the graphical captcha view Draws the string for graphical captcha
\seekquarry\yioop\controllers\array& | $data | 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. |
getRecoveryQuestions(string $register_view, string $locale) : array
Gets a list of translated recovery questions from the register view.
If insufficiently many questions have been translated for the current locale backfill with default locale
string | $register_view | view with register for an account form since auto checked for string to translate, have but a list of translated recovery string there. |
string | $locale | which locale to get the recovery questions for |
of translated recovery questions
selectQuestionsAnswers(array $question_answers, integer $num_select, integer $num_choices = -1) : array
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.
array | $question_answers | 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 |
integer | $num_select | number of triples from the list to pick for each triple pick either the most question or the least question |
integer | $num_choices | from the list component of a triplet we we pick this many elements |
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.
preactivityPrerequisiteCheck(\seekquarry\yioop\controllers\string& $activity, string $activity_success, string $activity_fail, \seekquarry\yioop\controllers\array& $data)
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.
\seekquarry\yioop\controllers\string& | $activity | current tentative activity |
string | $activity_success | activity to test for and to test prereqs for. |
string | $activity_fail | if prereqs not met which acitivity to switch to |
\seekquarry\yioop\controllers\array& | $data | data to help render the view this controller draws |
dataIntegrityCheck(\seekquarry\yioop\controllers\array& $data)
Add SCRIPT tags for errors to the view $data array if there were any missing fields on a create account or recover account form.
also adds error info if try to create an existing using.
\seekquarry\yioop\controllers\array& | $data | contains info for the view on which the above forms are to be drawn. |
getCleanFields(\seekquarry\yioop\controllers\array& $data)
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
\seekquarry\yioop\controllers\array& | $data | 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 |
validateHashCode() : boolean
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
true if the sha1 produces expected number of a leading zeroes.