本文整理汇总了PHP中sanitizeText函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitizeText函数的具体用法?PHP sanitizeText怎么用?PHP sanitizeText使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitizeText函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id = null)
{
$header['title'] = 'Thêm môn học';
$data = array();
if ($this->input->post()) {
$id = $this->input->post('id', 0);
$data['subjects_name'] = sanitizeText($this->input->post('subjects_name'));
$isValid = $this->subjectlib->validate($data);
if ($isValid) {
if (!$id) {
// save into subject table
$this->subject_model->create($data);
} else {
$this->subject_model->update_by_pkey($id, $data);
}
unset($data);
// remove cache after create/update
$this->lphcache->cleanCacheByFunction($this->subject_model->table_name, 'getAll');
redirect(BACKEND_V2_TMPL_PATH . 'subject/lists');
}
}
if ($id) {
$header['title'] = 'Chỉnh sửa môn học';
$data['subject'] = $this->subject_model->find_by_pkey($id);
$data['id'] = $id;
}
$data['title'] = $header['title'];
$content = $this->load->view(BACKEND_V2_TMPL_PATH . 'subject/edit', $data, true);
$this->loadTemnplateBackend($header, $content);
}
示例2: send
/**
* Method to send notification
*
* @param int $toUserid
* @param array $details
* @param int $userid
* @param bool $withPrivacy
* @param string $privacyId
* @param \App\\Models\\User $privacyUser
* @return boolean
*/
public function send($toUserid, $details = [], $userid = null, $withPrivacy = false, $privacyId = null, $privacyUser = null)
{
$userid = empty($userid) ? \Auth::user()->id : $userid;
if ($withPrivacy) {
//check if the notification receiver has disabled receiving from this notification type
if (!$privacyUser->present()->privacy($privacyId, 1)) {
return false;
}
}
$expectedDetails = ['title' => '', 'content' => '', 'seen' => 0, 'data' => []];
/**
* @var $title
* @var $content
* @var $seen
* @var $data
*/
extract($allDetails = array_merge($expectedDetails, $details));
$notification = $this->model->newInstance();
$notification->user_id = $userid;
$notification->to_user_id = $toUserid;
$notification->title = sanitizeText($title);
$notification->content = $content;
$notification->data = empty($details) ? '' : perfectSerialize($details);
$notification->save();
$this->realTimeRepository->add($toUserid, 'notification');
$this->event->fire('notification.send', [$notification, $details]);
return $notification;
}
示例3: edit
public function edit($id = null)
{
$header['title'] = 'Thêm hình thức thi';
$data = array();
if ($this->input->post()) {
$id = intval($this->input->post('id'));
$data['title'] = sanitizeText($this->input->post('title'));
$data['time'] = intval($this->input->post('time'));
$isValid = $this->examlib->validate($data);
if ($isValid) {
if (!$id) {
// save into exam table
$this->exam_model->create_ignore($data);
} else {
$this->exam_model->update_by_pkey($id, $data);
}
unset($data);
// remove cache after create/update
$this->lphcache->cleanCacheByFunction($this->exam_model->table_name, 'getAll');
redirect(BACKEND_V2_TMPL_PATH . 'exam/lists');
}
}
if ($id) {
$header['title'] = 'Chỉnh sửa hình thức thi';
$data['exam'] = $this->exam_model->find_by_pkey($id);
$data['id'] = $id;
}
$data['title'] = $header['title'];
$content = $this->load->view(BACKEND_V2_TMPL_PATH . 'exam/edit', $data, TRUE);
$this->loadTemnplateBackend($header, $content);
}
示例4: edit
public function edit($id = null)
{
$header['title'] = 'Thêm lớp';
$data = array();
if ($this->input->post()) {
$id = $this->input->post('id', 0);
$data['class_name'] = strtoupper(sanitizeText($this->input->post('class_name')));
$data['block_id'] = intval($this->input->post('block_id'));
$isValid = $this->clazzlib->validate($data);
if ($isValid) {
if (!$id) {
// save into academic table
$this->class_model->create($data);
} else {
$this->class_model->update_by_pkey($id, $data);
}
unset($data);
// remove cache after create/update
$this->lphcache->cleanCacheByFunction($this->class_model->table_name, 'getAll');
redirect(BACKEND_V2_TMPL_PATH . 'clazz/lists');
}
}
if ($id) {
$header['title'] = 'Chỉnh sửa lớp';
$data['clazz'] = $this->class_model->find_by_pkey($id);
$data['id'] = $id;
}
$data['title'] = $header['title'];
$data['blocks'] = $this->block_model->getAll();
$content = $this->load->view(BACKEND_V2_TMPL_PATH . 'clazz/edit', $data, true);
$this->loadTemnplateBackend($header, $content);
}
示例5: escape
function escape($item)
{
if (get_magic_quotes_gpc()) {
$item = stripcslashes($item);
}
return sanitizeText($item);
}
示例6: save
public function save($val, $page)
{
$expected = ['title' => '', 'keywords' => '', 'description' => '', 'tags' => '', 'privacy' => 0, 'comments' => 1, 'likes' => 1, 'active' => 1, 'show_menu' => 1, 'content' => ''];
/**
* @var $title
* @var $keywords
* @var $description
* @var $tags
* @var $privacy
* @var $comments
* @var $likes
* @var $active
* @var $show_menu
* @var $content
*/
extract(array_merge($expected, $val));
$page->title = $title;
$page->description = sanitizeText($description);
$page->keywords = sanitizeText($keywords);
$page->tags = $tags;
$page->privacy = $privacy;
$page->show_menu = $show_menu;
$page->content = lawedContent($content);
$page->show_comments = $comments;
$page->show_likes = $likes;
$page->content = $content;
$page->active = $active;
$page->save();
return true;
}
示例7: save
public function save($title, $album)
{
$album->title = sanitizeText($title);
$slug = toAscii($title);
$album->slug = $album->id . (!empty($slug) ? '-' . $slug : '');
$album->save();
return $album;
}
示例8: validate
public function validate($title)
{
$oldTitle = $title;
$title = sanitizeText($title);
$this->CI->form_validation->set_data(array('title' => $title));
$config = array(array('field' => 'title', 'label' => 'Tên kho', 'rules' => 'required|min_length[6]|max_length[255]'));
$this->CI->form_validation->set_message('required', 'Tên kho [' . htmlentities($oldTitle) . '] không hợp lệ');
$this->CI->form_validation->set_message('min_length', 'Tên kho ít nhất phải có {param} ký tự');
$this->CI->form_validation->set_message('max_length', 'Tên kho phải nhỏ hơn {param} ký tự');
$this->CI->form_validation->set_rules($config);
return $this->CI->form_validation->run();
}
示例9: block
public function block($userid, $byUserid)
{
if (!$this->hasBlock($byUserid, $userid)) {
$block = $this->model->newInstance();
$block->user_id = sanitizeText($byUserid);
$block->block_id = sanitizeText($userid);
$block->save();
$this->cache->forget('blocked_users_' . $byUserid);
return true;
}
return false;
}
示例10: add
/**
* Method to add category
*
* @param int $id
* @param string $title
* @return boolean
*/
public function add($id, $title)
{
if (!is_numeric($id)) {
return false;
}
if (!$this->exists($id, $title)) {
$category = $this->model->newInstance();
$category->community_id = $id;
$category->title = sanitizeText($title, 100);
$category->slug = hash('crc32', $title . time());
$category->save();
$this->cache->forget('community-categoies-' . $id);
return $category;
}
return false;
}
示例11: save
public function save($val, $category)
{
$expected = ['title', 'description'];
/**
* @var $title
* @var $description
*/
extract(array_merge($expected, $val));
if (!empty($title) and !$this->seperateExists($title, $category->id)) {
$category->title = sanitizeText($title, 130);
$category->slug = \Str::slug($title);
$category->description = sanitizeText($description);
$category->save();
return true;
}
return true;
}
示例12: add
/**
* Method to add hashtag into database
*
* @param string $hash
* @param boolean $increament
* @return bool
*/
public function add($hash, $increament = true)
{
$hash = trim($hash);
if ($this->exists($hash)) {
/**
* Update the use count for this hashtag
*/
$this->model->where('hash', '=', $hash)->increment('count');
} else {
if ($increament) {
$hashtag = $this->model->newInstance();
$hashtag->hash = sanitizeText($hash);
$hashtag->count = 1;
$hashtag->save();
}
}
return true;
}
示例13: add
/**
* Method to add languages
*
* @param array $val
* @return boolean
*/
public function add($val)
{
$expected = ['var' => '', 'name' => ''];
/**
* @var $var
* @var $name
*/
extract(array_merge($expected, $val));
/**Check for existence**/
if ($this->exists($var)) {
return false;
}
$model = $this->model->newInstance();
$model->var = sanitizeText($var, 10);
$model->name = sanitizeText($name, 100);
$model->save();
$this->cache->forget('languages');
$this->event->fire("language.added", $val);
return true;
}
示例14: add
/**
* Method to add a report
*
* @param array $val
* @return boolean
*/
public function add($val)
{
$expected = ['type' => '', 'url' => '', 'reason' => ''];
/**
* @var $type
* @var $url
* @var $reason
*/
extract($val = array_merge($expected, $val));
if (empty($reason)) {
return false;
}
$report = $this->model->newInstance();
$report->url = sanitizeText($url);
$report->user_id = \Auth::user()->id;
$report->type = sanitizeText($type, 50);
$report->reason = \Hook::fire('filter-text', sanitizeText($reason));
$report->save();
return true;
}
示例15: add
/**
* MEthod to add member to a community
*
* @param int $id
* @param int $userid
* @return boolean
*/
public function add($id, $userid = null)
{
if (!\Auth::check() and empty($userid)) {
return false;
}
$userid = empty($userid) ? \Auth::user()->id : $userid;
if (!$this->exists($id, $userid)) {
$member = $this->model->newInstance();
$member->community_id = sanitizeText($id);
$member->user_id = sanitizeText($userid);
$member->save();
$this->cache->forget('community-members-' . $id);
$this->cache->forget('user-communities' . $userid);
$this->cache->forget('community-suggestions-' . $userid);
//lets send a notification to the owner of this community
$community = app('App\\Repositories\\CommunityRepository')->get($id);
$this->notification->send($community->user_id, ['path' => 'notification.community.join', 'community' => $community], $userid);
return true;
}
return true;
}