/** * */ public function action_index() { Assets::js('datatable_jquery', base_UI . 'js/plugins/datatables/jquery.dataTables.js'); Assets::js('datatable', base_UI . 'js/plugins/datatables/dataTables.bootstrap.js'); Assets::js('icheck', base_UI . 'js/plugins/iCheck/icheck.min.js'); if ($boot_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) { $this->template->assign(['code' => $boot_id]); } $this->response->body($this->template->fetch('admin/boot/Index.tpl')); }
public function action_delete() { if (false !== ($id = Protect::Validate($_POST['id'], 'int'))) { $status = false; $User = \Model\User::model()->findByPk($id); //$this->delete_credit( $id ); if ($User->delete()) { $status = 0; } $this->response->body(json_encode(['code' => $status])); return true; } }
public function action_display() { $user_id = \Registry::getCurrentUser()->iduser; if ($item_id = \Utils\Protect::Validate($this->request->param('id'), 'int')) { \Assets::js('page1', base_UI . 'js/pages/page.js'); $page = \Model\Pages::model()->findByPk($item_id); $this->template->assign(['page' => $page]); $this->response->body($this->template->fetch('pages.tpl')); } else { if ($alias = \Utils\Protect::Validate($this->request->param('alias'), 'string')) { /**@var \Model\Item $data*/ \Assets::js('page1', base_UI . 'js/pages/page.js'); $page = \Model\Pages::model()->findByAttributes(['alias' => $alias]); $this->template->assign(['page' => $page]); $this->response->body($this->template->fetch('pages.tpl')); } } }
public function action_index() { $user_id = \Registry::getCurrentUser()->iduser; $category = $this->request->post('category'); if (!($search = \Utils\Protect::Validate($this->request->post('search'), 'string'))) { $search = \Utils\Protect::Validate($this->request->query('search'), 'string'); } if (!empty($search)) { switch ($category) { case '1': $this->findAll($search); break; default: $this->findAll($search); $category = 1; } } $this->template->assign(['category' => $category, 'search' => $search]); $this->response->body($this->template->fetch('search/results.tpl')); }
/** * */ public function action_changeConfig() { $user = \Session::instance()->get('UloginData'); $user_id = \Registry::getCurrentUser()->id; if (Request::current()->is_ajax()) { if ($item_value = \Utils\Protect::Validate($this->request->post('config'), 'int')) { $param = $this->request->post('param'); $config = userConfig::model()->findByAttributes(['user_id' => $user_id]); $config->{$param} = $item_value; $this->response->body(json_encode([])); } } }
public function action_delete() { if (false !== ($id = Protect::Validate($_POST['id'], 'int'))) { $status = false; $User = \Model\UserPayment::model()->findByPk($id); if (\Model\UserPayment::model()->deleteAllByAttributes(['idpages' => $id])) { $status = 0; } $this->response->body(json_encode(['code' => $status])); return true; } }
/** * Validate * @param $var * @param $type * @param null $flag * @return mixed */ public static function Validate($var, $type, $flag = null) { if (is_array($var)) { $tmp_arr = []; foreach ($var as $key => $val) { $tmp_arr[$key] = Protect::Validate($val, $type); } return $tmp_arr; } else { switch ($type) { default: $type = FILTER_DEFAULT; break; case 'bool': $type = FILTER_VALIDATE_BOOLEAN; break; case 'float': $type = FILTER_VALIDATE_FLOAT; break; case 'int': $type = FILTER_VALIDATE_INT; break; case 'ip': $type = FILTER_VALIDATE_IP; break; case 'email': $type = FILTER_VALIDATE_EMAIL; break; case 'url': $type = FILTER_VALIDATE_URL; break; case 'regexp': $type = FILTER_VALIDATE_REGEXP; break; case 'double': return is_double($var) ? $var : false; case 'array': return is_array($var) ? $var : false; case 'dir': return is_dir($var) ? $var : false; case 'upload': return is_uploaded_file($var) ? $var : false; case 'exec': return is_executable($var) ? $var : false; case 'file': return is_file($var) ? $var : false; case 'link': return is_link($var) ? $var : false; case 'read': return is_readable($var) ? $var : false; case 'write': return is_writable($var) ? $var : false; case 'null': return is_null($var) ? true : false; case 'resource': return is_resource($var) ? $var : false; case 'login': return preg_match("/^[a-zA-Z0-9_\\.-]+\$/", $var) && strlen($var) >= self::DEFAULT_USERNAME_MIN_LEN && strlen($var) <= self::DEFAULT_USERNAME_MAX_LEN ? $var : false; } switch ($flag) { default: $flag = null; break; case 'ipv4': $flag = $type == 'ip' ? FILTER_FLAG_IPV4 : null; break; case 'ipv6': $flag = $type == 'ip' ? FILTER_FLAG_IPV6 : null; break; case 'ip_p': $flag = $type == 'ip' ? FILTER_FLAG_NO_PRIV_RANGE : null; break; case 'ip_r': $flag = $type == 'ip' ? FILTER_FLAG_NO_RES_RANGE : null; break; case 'thousand': $flag = $type == 'float' ? FILTER_FLAG_ALLOW_THOUSAND : null; break; case 'octal': $flag = $type == 'int' ? FILTER_FLAG_ALLOW_OCTAL : null; break; case 'hex': $flag = $type == 'int' ? FILTER_FLAG_ALLOW_HEX : null; break; case 'bool_null': $flag = $type == 'bool' ? FILTER_NULL_ON_FAILURE : null; break; } } return filter_var($var, $type, $flag); }