public function combine(Filter $filter) { $filters = $filter->getFilters(); foreach ($filters as $filter) { $this->filters[] = $filter; } }
protected function PerformTest() { // Create the filter $filter = new Filter(); // We want to include something that wouldn't be included by default // for answers - link and exclude something that's included by default - score $filter->SetIncludeItems('answer.link')->SetExcludeItems('answer.score'); // Get the filter's ID $filter_id = $filter->GetID(); // Now make a request for an answer $answer = API::Site('stackoverflow')->Answers()->Filter($filter_id)->Exec()->Fetch(); // Make sure the answer contains / excludes what we specified if (!isset($answer['link'])) { throw new Exception('"link" missing from response.'); } if (isset($answer['score'])) { throw new Exception('"score" included in response but should not be present.'); } // Now lookup the filter by ID $filter = new Filter($filter_id); $included_items = $filter->GetIncludeItems(); // Make sure that the included items match what we describe if (!in_array('answer.link', $included_items)) { throw new Exception('"link" missing from filter description.'); } if (in_array('answer.score', $included_items)) { throw new Exception('"score" included in filter description but should not be present.'); } }
public function run() { include_once SANWEN_LIB . '/Common/functions.php'; include_used_file(); //include the file that used Log::write('begin initApp'); $this->initApp(); //use the filter $filter = new Filter(); //filter all url Log::write('begin to filter url'); if ($filter->filter_all_url()) { $include_file = get_include_file(); if (file_exists($include_file)) { Log::write('get_include_file:' . $include_file); include_once $include_file; execute(null, null); } else { //对应地址的类不存在的时候,执行默认首页 if (file_exists(APP . '/Index/Action/Index.action.php')) { include_once APP . '/Index/Action/Index.action.php'; execute("Index", "Index"); } else { //默认首页不存在的时候,抛出错误信息 echo get_langage_message('system.lang.php', 'DEFAULT_INDEX_NOT_FOUND'); } } } else { echo get_langage_message('system.lang.php', 'CAN_NOT_ACCESS'); } }
function save($package) { $Filter = new Filter(); $name = $this->getName($Filter->get($package, 'name', null)); if ($Filter->get($package, 'error', false)) { // An HTTP error occurred return false; } else { if (empty($name)) { // An empty file name was posted return false; } else { if ($this->exists($name)) { return false; } } } $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR)); list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR); if (intval($result) != 1) { // The file was not uploaded return false; } if ($this->unzip($tmpfile, $this->directory)) { return true; } unlink($tmpfile); return false; }
function save($package) { $Filter = new Filter(); $name = $this->getName($Filter->get($package, 'name', null)); if ($Filter->get($package, 'error', false)) { // An HTTP error occurred return false; } else { if (empty($name)) { // An empty file name was posted return false; } else { if ($this->exists($name)) { return false; } } } $Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR)); list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR); if (intval($result) != 1) { // The file was not uploaded return false; } // handle the file move to the managers dir if (!FileSystem::make_dir($this->directory . $name)) { // The target directory could not be created return false; } return $this->unzip($tmpfile, $this->directory . $name); }
public function testShortcutFilter() { $config = ['coverage' => ['include' => ['tests/*'], 'exclude' => ['tests/unit/CodeGuy.php']]]; $this->filter->whiteList($config); $fileFilter = $this->filter->getFilter(); $this->assertFalse($fileFilter->isFiltered(codecept_root_dir('tests/unit/c3Test.php'))); $this->assertTrue($fileFilter->isFiltered(codecept_root_dir('tests/unit/CodeGuy.php'))); }
/** * Должен пропускать разрешенные уровни. */ public function testLog_shouldWriteGoodLevels() { $log = $this->getMock('Psr\\Log\\LoggerInterface'); $log->expects($this->once())->method('log'); $filter = new Filter($log); $filter->closeAll(); $filter->open(['error']); $filter->error('test'); }
/** * Tests setting the filter impact via the collection helper method * * @covers \Expose\FilterCollection::setFilterImpact */ public function testGetSetFilterImpact() { $filter = new Filter(); $filter->setId(1234); $filter->setImpact(3); $this->collection->addFilter($filter); $this->collection->setFilterImpact(1234, 27); $this->assertEquals(27, $filter->getImpact()); }
private function doTest($initial, $filters, $expected) { $test = $initial; foreach ($filters as $filter) { $filter = new Filter($filter); $filter->filter($test); } $this->assertEquals($expected, $test); }
public function postSaveFilter($p, $z) { $filterId = $_POST['id'] ? $_POST['id'] : null; $filter = new Filter($filterId); if (isset($_POST['name'])) { $filter->name = $_POST['name']; } $filter->content = json_encode(json_decode($_POST['content'])->subs[0]); $filter->save(); echo json_encode(array('id' => $filter->id)); }
function Populate() { $filters = getDirectory(PATH_FILTER, false, true); foreach ($filters as $file) { if (stristr($file, FILE_EXTENSION_FILTER)) { $filter = new Filter(str_replace(FILE_EXTENSION_FILTER, "", $file)); $filter->Load(); $this->Filters[$filter->FilterId] = $filter; } } }
/** * @param $array * * @return Filter * * @deprecated won't be part of the CMDL 1.0 specification */ public static function createFromArray($array) { $filter = new Filter(); foreach ($array as $block) { $filter->nextConditionsBlock(); foreach ($block as $condition) { $filter->addCondition($condition[0], $condition[1], $condition[2]); } } return $filter; }
/** * Filter scope * * @param $query * @param $request * @return mixed */ public function scopeFilter($query, $request) { // Create ne filter object $this->filter = new Filter($query, $request); // Set the filters if any defined $this->setFilters(); // Call order always after the all filters and if there are no custom filters applied $this->filter->order(); // Object are always passed by reference // http://php.net/manual/en/language.oop5.references.php return $query; }
function doSave($Request) { $Filter = new Filter(); $package = @$_FILES['package']; $item = $Filter->get($package, 'name', null); if ($this->model->save($package)) { $this->_setMessage('success', 'Success!', $item . " Skin was successfully installed."); } else { $this->_setMessage('error', 'Oops!', $item . " Skin could not be installed."); } Core::SBRedirect(INSTALLER_URL . "&com=skin"); }
/** * @param string|Filter $filter * @param array $params * @param string $relation */ public function addChunk($filter, $params = null, $relation = 'AND') { if ($filter instanceof Filter) { $this->addChunk($filter->getFilterString(), $filter->getParams()); } elseif ($filter) { if ($this->filterString) { $this->filterString .= " {$relation} "; } $this->filterString .= $filter; if (!is_null($params) && is_array($params)) { $this->params = array_merge($this->params, $params); } } }
public function executeSave() { $arr = array(); $fid = (int) mfwRequest::get('id'); if ($fid) { $arr['id'] = $fid; } $arr['enable'] = (bool) mfwRequest::get('enable', true); $arr['name'] = mfwRequest::get('name'); $arr['target'] = mfwRequest::get('target'); $arr['pattern'] = mfwRequest::get('pattern'); $filter = new Filter($arr); $filter->save(); return $this->redirect('/filters/index'); }
/** save field in database, if field is valid */ function cdbr_register_verify_field() { $reponse = array(); $filter = new Filter(); $validator = new Validator(); foreach ($_POST as $stepfield => $value) { $field = $stepfield; $filter->apply('register', $field, $value); $result = $validator->validate_field('register', $field, $value, $type_user); $response[$field] = $result; } print json_encode($response); die; // or wordpress will print 0 }
function doDefault() { /* {{{ 导入过滤模块,并初始化 */ importModule("Filter.Filter"); $fl = new Filter(); /* }}} */ /* {{{ 过滤测试测试文本 */ $content = "大家好.有人认识李洪志吗? 学过法轮功的吗?"; echo "<b>原语句:</b> ", $content, "<br />"; /* }}} */ /* {{{ 检测是否含有非法关键字 */ $show = $fl->isForbidden($content); if ($show) { echo "<br />含有非法关键字!<br /><br />"; } else { echo "<br />没有有非法关键字!<br /><br />"; } /* }}} */ /* {{{ 过滤文本 */ $start = xdebug_time_index(); $show = $fl->clean($content); echo "<b>过滤后的:</b>", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 过滤文本, 指定替换的格式 */ $start = xdebug_time_index(); $show = $fl->clean($content, "×"); echo "<br /><b>指定替换内容过滤:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 并手工指定关键字再过滤文本 */ $start = xdebug_time_index(); $fl->setKey(array('大家好')); $show = $fl->clean($content); echo "<br /><b>手工指定关键字过滤:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ /* {{{ 模糊过滤文本 */ $start = xdebug_time_index(); $ff = new Filter(); $content = "start:李 洪 志-测-试- f-!u-c=k, f**k:end"; echo "<br /><b>原语句:</b> ", $content, "<br />"; $show = $ff->fuzzyClean($content, "*", 2); //其中2为深度,默认值,值越大清理越干净,误杀越多,消耗资源越多. echo "<b>模糊过滤后:</b> ", $show, "<br />"; echo "用时: ", xdebug_time_index() - $start, "<br />"; /* }}} */ }
private function filter() { $input = Filter::run(strip_tags(parent::getVar('input'))); $find = array(' ', '#', '?', '&', '.', '!', '"', '§', '$', '%', '(', ')', '=', '*', '+', '~', '-', ':', ';', '>'); $input = str_replace($find, '', $input); echo $input; }
/** * Constructor * * @param callable $callback * @return void */ public function __construct($callback) { parent::__construct($callback); // Set the default signature $this->resetParameters(); $this->addParameterByName('attrValue'); }
public function getNeighborhood() { $images = FilterImage::all(); $filter = Filter::take(1)->get()[0]; $filters = Filter::all(); return View::make('site.neighborhood', array('images' => $images, 'text' => $filter->text, 'paragraph_title' => $filter->paragraph_title, 'filters' => $filters)); }
/** * Método para ver la información de una sucursal * @param int|string $id * @return Sucursal */ public function getInformacionTiposolicitud($id, $isSlug = false) { $id = $isSlug ? Filter::get($id, 'string') : Filter::get($id, 'numeric'); $columnas = 'tiposolicitud.* '; $condicion = "tiposolicitud.id = '{$id}'"; return $this->find_first("columns: {$columnas}", "conditions: {$condicion}"); }
public function listen() { foreach ((array) $this->bindEv as $on => $class) { if (!count($this->bindEv[$on])) { unset($this->bindEv[$on]); $this->change(); continue; } $this->O->event()->bind($on, function ($ev) { $e = $ev['bind'][0]; $O = clone $e->O; foreach ((array) $e->bindEv[$ev['bind'][1]] as $k => $action) { try { if (!class_exists($action['class'])) { return; } $class = new $action['class']($O); $class = $class->json(); $class->rpc_data = Filter::array_($action); $class->rpc_method = Filter::id('method', $class->rpc_data); $class->rpc_id = Filter::id('id', $class->rpc_data); $class->rpc_params = Filter::array_('params', $class->rpc_data); $r = json_decode($class->renderReturn(), 1); } catch (\Exception $e) { Debug::report($e); } unset($e->bindEv[$ev['bind'][1]][$k]); $e->change(); } }, array($this, $on)); } }
static function createDirectory($name, $owner) { require_once "common.php"; $name = Filter::filterText($name); $dir = new MailDirectory($name, $owner); return $dir->save(); }
public function parsePorm($prom) { $type = $prom['type']; $expr = $prom['expression']; $result = array('total_amount' => $this->total_amount, 'value' => 0.0); switch ($type) { case '0': $result['total_amount'] = $this->total_amount * $expr / 100; $result['note'] = "省" . $this->total_amount * (100 - $expr) / 100 . "(" . $expr / 10 . "折)"; $result['value'] = floatval($this->total_amount * (100 - $expr) / 100); break; case '1': $result['total_amount'] = $this->total_amount - $expr; $result['note'] = "省" . $expr . "(立减" . $expr . ")"; $result['value'] = floatval($expr); break; case '2': $result['value'] = intval($expr); $result['note'] = "送" . $expr . "倍积分"; break; case '3': $model = new Model("voucher_template"); $voucher = $model->where("id=" . Filter::int($expr))->find(); if ($voucher) { $result['note'] = "面值" . $voucher['value'] . "优惠券"; } else { $result['note'] = "所送的优惠券已不存在"; } break; case '4': $result['note'] = "免运费"; break; } return $result; }
public function build() { $info = $this->getParams(); if (!isset($info['url_arguments'][0])) { $sessio = Session::getInstance()->get('my_name'); if (!empty($sessio)) { $this->setLayout('error/errorlogin.tpl'); } else { $this->setLayout('project/main.tpl'); $s = FALSE; Session::getInstance()->set('login', $s); if (Filter::getString('usernamelogin') && Filter::getString('passwordlogin')) { $var = $this->validator(Filter::getString('usernamelogin'), Filter::getString('passwordlogin')); if ($var == true) { $userName = Filter::getString('usernamelogin'); Session::getInstance()->set('my_name', $userName); $s = TRUE; Session::getInstance()->set('login', $s); $this->assign('loguejat', $s); header('Location: http://g4.local/home'); } else { $this->assign('errorMessage', "The username or/and password were incorrect, try again"); $this->setLayout('project/main.tpl'); } } } } else { $this->setLayout('error/error404.tpl'); } }
/** * 详请 * * @author mrmsl <*****@*****.**> * @date 2013-02-21 13:47:40 * @lastmodify 2013-04-26 23:13:01 * * @return void 无返回值 */ public function detailAction() { $blog_id = Filter::int('id', 'get'); $date = Filter::int('date', 'get'); if (!$blog_id || !$date) { //非法参数 $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . "date=({$date}),id=({$blog_id})"; trigger_error($log); $this->_showMessage('error' . $blog_id . $date, null, 404); } if ($blog_info = $this->_model->find($blog_id)) { if (date('Ymd', $blog_info['add_time']) != $date) { //日期与id不匹配 $log = get_method_line(__METHOD__, __LINE__, LOG_INVALID_PARAM) . "date=({$date}),id=({$blog_id})"; trigger_error($log); $this->_showMessage('error' . $blog_id . ',' . $date, null, 404); } $filename = str_replace(BASE_SITE_URL, WWWROOT, $blog_info['link_url']); new_mkdir(dirname($filename)); $o = $this->getViewTemplate('build_html')->assign('blog_info', $blog_info)->assign(array('web_title' => L('MINIBLOG,DETAIL') . TITLE_SEPARATOR . L('MINIBLOG'), 'comments_html' => $this->_getBlogComments($blog_id))); $content = $o->fetch(CONTROLLER_NAME, 'detail', $blog_id); //file_put_contents($filename, $content); echo $content; } else { //微博不存在 $this->_showMessage(L('MINIBLOG,NOT_EXIST'), null, 404); } }
/** * Create new genesis document * @param OCA\Documents\File $file * */ public function __construct(\OCA\Documents\File $file) { list($view, $path) = $file->getOwnerViewAndPath(); $owner = $file->getOwner(); $this->view = new View('/' . $owner); if (!$this->view->file_exists(self::DOCUMENTS_DIRNAME)) { $this->view->mkdir(self::DOCUMENTS_DIRNAME); } $this->hash = $this->getDocumentHash($view, $path); $this->path = self::DOCUMENTS_DIRNAME . '/' . $this->hash . '.odt'; if (!$this->view->file_exists($this->path)) { //copy new genesis to /user/documents/{hash}.odt // get decrypted content $content = $view->file_get_contents($path); $mimetype = $view->getMimeType($path); $data = Filter::read($content, $mimetype); $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false; $this->view->file_put_contents($this->path, $data['content']); \OC_FileProxy::$enabled = $proxyStatus; } try { $this->validate($this->view, $this->path); } catch (\Exception $e) { throw new \Exception('Failed to copy genesis'); } }
/** * Remove configuration record */ public function deleteAction() { $this->_checkCanDelete(); $data = Request::post('data', 'raw', false); if ($data === false) { Response::jsonSuccess(); } $dataType = json_decode($data); if (!is_array($dataType)) { $data = array(json_decode($data, true)); } else { $data = json_decode($data, true); } $media = Model::factory('Medialib'); $configImage = $media->getConfig()->get('image'); foreach ($data as $item) { $code = Filter::filterValue('pagecode', $item['code']); unset($configImage['sizes'][$code]); unset($configImage['thumb_types'][$code]); } $config = $media->getConfig(); $config->set('image', $configImage); if (!$config->save()) { Response::jsonError($this->_lang->CANT_WRITE_FS); } Response::jsonSuccess(); }
static function editContest($contest, $data) { require_once "common.php"; $data = Filter::filterArray($data); if (isset($data["title"])) { $contest->setTitle($data["title"]); } if (isset($data["description"])) { $contest->setDescription($data["description"]); } if (isset($data["rules"])) { $contest->setRules($data["rules"]); } if (isset($data["prizes"])) { $contest->setPrizes($data["prizes"]); } if (isset($data["start"])) { $contest->setStart($data["start"]); } if (isset($data["end"])) { $contest->setEnd($data["end"]); } $contest->update(); return $contest; }