public function cookie_var($var) { if (isset($_COOKIE[CX_SES . $var])) { $c = $_COOKIE[CX_SES . $var]; if (main_fn::is_base64_encoded($c) === true) { $decoded = base64_decode($c, true); if (main_fn::is_serialized($decoded) === true) { return main_fn::safe_unserialize($decoded); // returns array } return $decoded; // return decoded cookie } else { return $c; // my cookie } } else { return false; // No cookie, found } }
/** * Purpose: To generate a group of checkboxes. * @param type $name - The name for the group of checkboxes. * @param $htmlOptions - <options> - Array of checkbox data. */ private function frm_checkboxes($name, $htmlOptions) { $checkboxes = isset($htmlOptions['options']) ? $htmlOptions['options'] : array(); $c = count($checkboxes); $input_name = $c > 1 ? $name . '[]' : $name; foreach ($checkboxes as $value => $label) { $selected = array(''); if (isset($this->model[$name])) { if (is_array($this->model[$name])) { $selected = $this->model[$name]; } elseif (main_fn::is_serialized($this->model[$name]) === true) { $selected = main_fn::safe_unserialize($this->model[$name]); } elseif (!empty($this->model[$name])) { $selected = array($this->model[$name]); } } if ($c == 1) { $checkit = isset($htmlOptions['checked']) && main_fn::get_bool_value($htmlOptions['checked']) === true ? ' checked="checked"' : ''; } else { $checkit = isset($htmlOptions['checked'][$value]) && main_fn::get_bool_value($htmlOptions['checked'][$value]) === true ? ' checked="checked"' : ''; } $req = $this->get_request($name, $selected, $this->method); if (is_array($req)) { $select = in_array($value, $req) ? ' checked="checked"' : $checkit; } else { $select = $value == $req ? ' checked="checked"' : $checkit; } $this->input('checkbox', $input_name, $value, $label, $select, $htmlOptions); } // end foreach if ($c == '0') { $err = "Form Command - checkboxes - Named: {$name} - Missing Options!"; $this->report_form_error($err); } }
/** * Getter for class members * * @return void */ public function get_member($name, $allow_html = false) { if (is_array($this->members) && !array_key_exists($name, $this->members)) { return; } $value = $this->members[$name]; if (main_fn::is_serialized($value)) { return $value; } if (is_string($value)) { // Prevent XSS return $this->safe_html($name, $value, $allow_html); } if (count($value) == 0) { return; } $my_array = array(); foreach ($value as $key => $content) { $my_array[$key] = is_string($content) ? $this->safe_html($key, $content, $allow_html) : $content; } return $my_array; }