public function execute() { if (isset($_SERVER["hide_ss"]) == false) { $_SERVER["hide_ss"] = true; } if ($_SERVER["REQUEST_METHOD"] == "POST" && $_POST["submit_button"] == "hidess") { $_SERVER["hide_ss"] = is_true($_POST["hide_ss"]); } $this->output->add_css("banshee/filter.css"); $filter = new filter($this->db, $this->output, $this->user); $filter->to_output($this->model->table, false); if (($count = $this->model->count_events($filter->webserver, $_SERVER["hide_ss"])) === false) { $this->output->add_tag("result", "Database error."); return; } $paging = new pagination($this->output, "events", $this->settings->event_page_size, $count); if ($_SERVER["REQUEST_METHOD"] == "POST") { $paging->reset(); } if (($events = $this->model->get_events($paging->offset, $paging->size, $filter->webserver, $_SERVER["hide_ss"])) === false) { $this->output->add_tag("result", "Database error."); return; } $this->output->open_tag("events", array("hide_ss" => show_boolean($_SERVER["hide_ss"]))); foreach ($events as $event) { $event["timestamp"] = date("j F Y, H:i:s", $event["timestamp"]); $event["event"] = $this->output->secure_string($event["event"], "_"); $this->output->record($event, "event"); } $paging->show_browse_links(); $this->output->close_tag(); }
private function show_day_information($type, $date) { $filter = new filter($this->db, $this->output, $this->user); $filter->to_output($this->model->table, $this->model->hostnames); if (($stats = $this->model->get_day_statistics($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $graph = new graph($this->output); $graph->title = $this->graphs[$type] . " for " . date("l j F Y", strtotime($date)); $graph->width = 960; $graph->height = GRAPH_HEIGHT; foreach ($stats as $hour => $count) { $graph->add_bar("Hour " . $hour, $count, "hour"); } $graph->to_output(); if (($stats = $this->model->get_day_information($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $this->output->open_tag("day", array("hostnames" => show_boolean($this->model->hostnames), "label" => $this->graphs[$type])); foreach ($stats as $stat) { if ($type == "requests" || $type == "bytes_sent") { $stat["count"] = $this->model->readable_number($stat["count"]); } $this->output->record($stat, "stat"); } $this->output->close_tag(); }
/** * Test the get/set methods */ public function testGetSetMethods() { $filter = array('2' => "test", "4" => "xyz"); $this->filter->setEnum($filter); $this->assertEquals($filter, $this->filter->getEnum()); $default = 'Z1'; $this->filter->setDefault($default); $this->assertEquals($default, $this->filter->getDefault()); }
public function code($code) { if (!isset($this->error_list[$code])) { $code = 500; } $filter = new filter(); header($filter->server('SERVER_PROTOCOL') . ' ' . $code . ' ' . $this->error_list[$code]); header('Status: ' . $code . ' ' . $this->error_list[$code]); return $code . ' ' . $this->error_list[$code]; }
public function doGetUniqueIdentifiersToFilter(Collection $list) { $idsToKeep = $this->filter->doGetUniqueIdentifiersToFilter($list); $ids = []; foreach ($list as $item) { if (!in_array($item->UniqueIdentifier, $idsToKeep)) { $ids[] = $item->UniqueIdentifier; } } return $ids; }
function ProcessLogin($user, $dblink) { $login = filter::filter_email($user); if ($login != FALSE) { if ($stm = $dblink->prepare("SELECT email, pass FROM users WHERE email=?")) { $stm->execute(array($login)); $row = $stm->fetch(); $stm = NULL; $uname = $row['email']; $hash = $row['pass']; } if ($uname == $login) { if (password_verify($_POST['password'], $hash)) { $_SESSION['email'] = $login; //login::log_enter($dblink); } else { $mesg = "Wrong password"; } } else { $mesg = "Wrong login"; } } else { $mesg = "Login is not valid"; } return $mesg; }
function event_ExecuteEditor(&$data) { global $lang, $manager, $user; if (isset($manager->types[$data['type']]['content']['story']) && $data['sheet'] == 'contents') { // Retrieve story $res = sql::query("\n\t\t\t\t\tSELECT \n\t\t\t\t\t\t*\n\t\t\t\t\tFROM \n\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\tWHERE \n\t\t\t\t\t\t`ID` = '" . $data['params']['id'] . "' AND\n\t\t\t\t\t\t`revision` = '" . $data['params']['revision'] . "'\n\t\t\t\t"); if ($row = sql::fetch_array($res, MYSQL_ASSOC)) { $story = $row; } else { $story = array('text' => ''); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $_POST['text'] = filter::images($_POST['text']); $_POST['text'] = filter::html($_POST['text']); $res = sql::query("\n\t\t\t\t\t\tREPLACE INTO \n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents_story \n\t\t\t\t\t\tSET \n\t\t\t\t\t\t\tID='" . $data['params']['id'] . "', \n\t\t\t\t\t\t\trevision='" . $data['params']['revision'] . "',\n\t\t\t\t\t\t\ttext='" . addslashes($_POST['text']) . "'\n\t\t\t\t\t"); // Mark this action as a modification revisions::updateModificationDate($data['params']['id'], $data['params']['revision']); header("Location: " . url::item($data['params']['id'], 'edit') . "/contents?revision=" . $data['params']['revision']); exit; } $tpl = new Template($this->getTemplate('editor.template')); $tpl->set('story', $story); $tpl->set('id', $data['params']['id']); $tpl->set('revision', $data['params']['revision']); $data['template']->append('content', $tpl->fetch()); } }
/** * finder constructor. * @param $file_name */ function __construct($file_name) { $filter = new filter(); $this->arr_filter_day = $filter->getFilterDay(); $this->arr_filter_groups = $filter->getFilterGroup(); $y = $filter->getFilterDay(); $this->objPHPExcel = PHPExcel_IOFactory::load($file_name); $this->getAllMergedCells($this->objPHPExcel); //забираем все страницы $this->arr_Work_Sheet = $this->objPHPExcel->getAllSheets(); $this->getAllMergedCells($this->objPHPExcel); $this->objPHPExcel->setActiveSheetIndex(0); $r = $this->objPHPExcel->getActiveSheet(); // $this->arr_merged_allCells=$r->getMergeCells(); // echo "sheet->".$this->objPHPExcel->getSheetCount(); /*for ($i=0; $i<=9; $i++){ echo $r->getTitle(); }*/ $t = $r->getCell('B17'); $q = $this->findTime($r); $w = $this->findGroups($r, 1); $this->arr_schedule = $this->findLessonS($r, $q, $w); // $this->testEcho($arr); // echo $this->getDay($this->objPHPExcel, $r, $t,$y); //foreach ($this->arr_Work_Sheet as $sheet){ // $this->testEcho($this->findTime($sheet)); // } // $this->arrFindTime = null; // $this->arrFindGroup = null; // $this->filterDay = $filter->getFilterDay(); // $this->filterGroup = $filter->getFilterGroup(); // $this->findSchedule($this->arr_Work_Sheet); // echo $this->getValueMergedCell($this->objPHPExcel, 0, $this->arr_merged_allCells,'A',54); // $this->get(); // $objPHPExcel1->setActiveSheetIndex(0); //забираем активную страницу // $sheet = $objPHPExcel1->getActiveSheet(); // $this->sheet=$sheet; // $this->arrMerge= $sheet->getMergeCells(); // echo "<pre>"; // echo print_r( $this->arrMerge); // echo "</pre>"; //проходимся по строкам // $this->findGroups($sheet); }
public function __construct($option) { parent::__construct($option); if (!isset($this->option['length'])) { $this->option['length'] = 20; } $this->option['prefix'] = @$this->option['prefix']; }
function view() { db::table('catalog_items'); db::join('catalog_sections', 'catalog_items', 'section_id'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $a = filter::get('item_pub', array('unpub', 'pub'), $a); s::roll('items', $a); } }
/** * Overloaded Function From Filter * * Calls the parent function and then adds the new site element to the form. * @param Viewer $viewer the current viewer that's being used * @return void */ function grab_fields($viewer) { parent::grab_fields($viewer); $sites = $this->get_sites_with_available_associations(); $this->add_element('search_site', 'select', array('options' => $sites)); $this->set_display_name('search_site', 'site'); $this->add_element('search_exact_site', 'hidden'); if (!empty($this->page->request['search_site'])) { $this->set_value('search_site', $this->page->request['search_site']); } }
function view() { db::table('news'); db::order('news_date', 'DESC'); $res = db::select(); while ($row = mysql_fetch_assoc($res)) { $row = filter::get('news_pub', array('unpub', 'pub'), $row); $row['news_title'] = strip_tags($row['news_title']); $row['news_date'] = dt::date2print('%d %F %Y, %H:%i', $row['news_date']); s::roll('news', $row); } }
public function testSlowEquals() { $this->assertTrue(filter::slow_equals('foo', 'foo'), 'same string'); $this->assertFalse(filter::slow_equals('foo', true), 'string and boolean'); $this->assertFalse(filter::slow_equals('foo', 0), 'string and integer'); $this->assertFalse(filter::slow_equals('123foo', 123), 'string and integer'); $this->assertFalse(filter::slow_equals('123foo', '123'), 'different strings'); $this->assertFalse(filter::slow_equals('6', ' 6'), 'strings with space'); $this->assertFalse(filter::slow_equals('4.2', '4.20'), 'floats as strings'); $this->assertFalse(filter::slow_equals('1e3', '1000'), 'integers as strings'); $this->assertFalse(filter::slow_equals('9223372036854775807', '9223372036854775808'), 'large integers as strings'); $this->assertFalse(filter::slow_equals('61529519452809720693702583126814', '61529519452809720000000000000000'), 'larger integers as strings'); }
function view() { events::observe('upload', 'index'); events::observer(); $dir = IMAGES_PATH . 'index/'; db::table('images'); $r = db::select(); while ($a = mysql_fetch_assoc($r)) { $a = filter::get('img_set', array('unpub', 'pub'), $a); $a['thumb'] = $dir . $a['img_id'] . '_m.jpg'; s::roll('images', $a); } }
public function getInfo($user, $dblink) { if (!isset($user)) { header("location: index.php"); exit; } $uiname = filter::filter_email($user); if ($stm = $dblink->prepare("SELECT * FROM users WHERE email = ?")) { $stm->execute(array($uiname)); $out = $stm->fetch(); $stm = NULL; } if ($out['id'] == '') { session_destroy(); header("location: index.php"); exit; } return $out; }
function makeSearchQuery() { $searchAuthor = filter_input(INPUT_COOKIE, 'searchAuthor', FILTER_VALIDATE_INT); $searchName = filter_input(INPUT_COOKIE, 'searchName', FILTER_SANITIZE_SPECIAL_CHARS); $searchFrom = filter::date($_COOKIE['searchFrom']); $searchTo = filter::date($_COOKIE['searchTo']); if ($searchFrom == FALSE) { $searchFrom = '0000-00-00'; } if ($searchTo == FALSE) { $searchTo = date('Y-m-d'); } if ($searchAuthor == FALSE) { $query = "SELECT * FROM books WHERE date>'{$searchFrom}' AND date<'{$searchTo}' AND name LIKE '%{$searchName}%' ORDER BY id ASC"; } else { $query = "SELECT * FROM books WHERE date>'{$searchFrom}' AND date<'{$searchTo}' AND author_id='{$searchAuthor}'\n\t\t\t\tAND name LIKE '%{$searchName}%' ORDER BY id ASC"; } //$query = "SELECT * FROM books WHERE name LIKE '%$searchName%' ORDER BY id ASC"; return $query; }
/** * @param string $name 键值 * @param string $func filter的类型 * @param string $extra filter的额外参数 * @param string $msg 不正确时报错信息,以null|开头时表示非必需 * @param string $type 获取方法 */ public static function get($name, $func, $msg, $extra, $type = self::REQUEST) { $value = null; while ($type && $value === null) { if ($type & self::GET) { $value = isset($_GET[$name]) ? $_GET[$name] : $value; $type ^= self::GET; continue; } if ($type & self::POST) { $value = isset($_POST[$name]) ? $_POST[$name] : $value; $type ^= self::POST; continue; } if ($type & self::PARAMS) { $value = \yk::app()->getDispatcher()->getRequest()->getParam($name); $type ^= self::PARAMS; continue; } if ($type & self::COOKIE) { $tvalue = cookie($name); $value = $tvalue !== null ? $tvalue : $value; $type ^= self::COOKIE; continue; } break; } $ignore = $msg === false; $need = $ignore || $msg == null || strpos($msg, 'null|') === 0 ? false : true; $msg = !$need && is_string($msg) ? substr($msg, 5) : $msg; if (!$need && $value === null || $value !== null && filter::verify($value, $func, $extra)) { return $value; } else { if (!$ignore) { throw new error(!is_null($msg) ? $msg : "you post {$name} variable's value is wrong"); } else { return null; } } }
public function update($title, $plugin = 'app', $app_id = null, $app_action = 'index', $icon = null, $post_app_params = null, $location = null, $id) { if (is_array($post_app_params)) { $c = count($post_app_params); if ($c != 0) { $app_params = array(); foreach ($post_app_params as $key => $value) { $app_params[] = $key . ':' . $value; } $db_app_params = implode(',', $app_params); } } global $my_user; if ($icon == 'null') { $icon = ''; } $items = array('file_title' => filter::utf($title), 'id_user' => $my_user->get_id_user(), 'plugin_id' => filter::alfas($plugin), 'app_id' => filter::alfas($app_id), 'app_action' => filter::alfas($app_action), 'modified_at' => time(), 'app_params' => $db_app_params, 'icon' => filter::fname($icon)); global $sql; $sql->cond('id_file', $id); if ($sql->update($this->db_shortcuts, $items)) { return true; } }
function editbook($bid, $okdomains, $dblink) { $authorid = filter_input(INPUT_POST, 'authorid', FILTER_SANITIZE_NUMBER_INT); $name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_SPECIAL_CHARS); $dateto = filter::date($_POST['dateto']); $preview = filter::allowedURL($_POST['preview'], $okdomains); if ($authorid == FALSE) { $message = "Не выбран автор."; } if ($name == FALSE) { $message = "Не указано название книги."; } if ($dateto == FALSE) { $message = "Не указана дата издания."; } if ($preview == FALSE) { $message = "Укажите полный путь к превью (с http://)."; } if ($authorid != FALSE && $name != FALSE && $dateto != FALSE && $preview != FALSE) { if ($stm = $dblink->prepare("SELECT COUNT(id) AS cnt FROM authors WHERE id=?")) { $stm->execute(array($authorid)); $row = $stm->fetch(); $stm = NULL; $countAuthors = $row['cnt']; } if ($countAuthors > 0) { if ($stm = $dblink->prepare("UPDATE books SET date_update=NOW(), name=?, author_id=?, preview=?, date=? WHERE id=?")) { $stm->execute(array($name, $authorid, $preview, $dateto, $bid)); $message = "Книга отредактирована "; $stm = NULL; } } else { $message = "Такого автора не существует"; } } return $message; }
$_GET['id'] = filter::num($_POST['id']); } /* ************************** */ $apiWindow = new api_wintask(); $apiWindow->setID(filter::num($_GET['id'])); // set ID of my window $apiWindow->getWindow(); // get Window data define("WIN_ID", $apiWindow->getID()); // Get APP ID $app = $apiWindow->getAPPID(); $app_name = $apiWindow->get_app_name(); if (!empty($_GET['action'])) { $apiWindow->setAPPID($app_name . '@' . filter::alfas($_GET['action'])); $apiWindow->updateWindow(); } $app_action = $apiWindow->get_app_action(); define("APP_ID", $app_name); define("APP_ACTION", $app_action); define("WIN_TYPE", $apiWindow->getParam('wintype')); /* ************************** */ if (file_exists(PHPOS_DIR . 'plugins/window.' . $apiWindow->getParam('wintype') . 'Plugin.php')) { define('PHPOS_PLUGIN', true); if (!empty($app_name)) { $my_app = new phpos_app(); $my_app->set_app_id($app_name); $my_app->set_app_action($app_action);
<?php require_once $_SERVER['DOCUMENT_ROOT'] . 'tz/controller/post.php'; //Сразу фильтруем данные require_once $_SERVER['DOCUMENT_ROOT'] . 'tz/controller/saveBD.php'; require_once $_SERVER['DOCUMENT_ROOT'] . 'tz/model/stop.php'; if ($post->filtersPost == true) { class filter extends Stop { public function filtersStop() { $stop = $this->searchStop($_POST['val']); if ($stop == false) { $save = new saveBD(); $save->comments($_POST['val']); } else { echo $stop; } } } $flStop = new filter(); $flStop->filtersStop(); }
<?php require_once '../init.php'; if ($_SERVER['REQUEST_METHOD'] != 'POST') { header('location:../404.php'); } $user = new user(new dbc($config)); $filter = new filter(); extract($_POST); extract($_GET); if (isset($delete)) { header('location:../users.php?tab=tab1&confirm=delete&id=' . $id); } if (isset($yes)) { if ($user->delete_user($id)) { header('location:../users.php?tab=tab1&message=user has been deleted!'); } else { header('location:../users.php?tab=tab1&message=Failed to delete!'); } } if (isset($no)) { header('location:../users.php?tab=tab1&message=deletion has been cancled!'); } if (isset($adduser)) { if (empty($username)) { $err = 'usernamerr=please enter a user name'; } if (empty($email)) { $err1 = 'emailerr=please enter user email'; } if (empty($password)) {
?> href="<?php echo isset($_GET['id']) ? general::link('filter/id/' . $_GET['id'] . '/type_sort/2') : general::link('filter/type_sort/2'); ?> ">Я>А</a> </div> </div><!-- .srt_block--> <div class="tovar_list_3"> <?php foreach ($result as $obj) { ?> <?php echo system::show_tpl(array('obj' => $obj, 'level' => ''), '/frontend/catalog/list_index.php'); ?> <?php } ?> </div><!-- .tovar_list_3--> <?php // pager if (isset($_GET['id'])) { echo filter::get_count() > CATALOG_AT_PAGE ? pager::pager_J("filter/id/" . $_GET['id'], CATALOG_AT_PAGE, filter::get_count(), intval($_GET['page'])) : ''; } else { echo filter::get_count() > CATALOG_AT_PAGE ? pager::pager_J("filter", CATALOG_AT_PAGE, filter::get_count(), intval($_GET['page'])) : ''; }
/** * Read an existing paste or comment * * @access private * @param string $dataid * @return void */ private function _read($dataid) { // Is this a valid paste identifier? if (!filter::is_valid_paste_id($dataid)) { $this->_error = 'Invalid paste ID.'; return; } // Check that paste exists. if ($this->_model()->exists($dataid)) { // Get the paste itself. $paste = $this->_model()->read($dataid); // See if paste has expired. if (isset($paste->meta->expire_date) && $paste->meta->expire_date < time()) { // Delete the paste $this->_model()->delete($dataid); $this->_error = 'Paste does not exist, has expired or has been deleted.'; } else { // We kindly provide the remaining time before expiration (in seconds) if (property_exists($paste->meta, 'expire_date')) { $paste->meta->remaining_time = $paste->meta->expire_date - time(); } // The paste itself is the first in the list of encrypted messages. $messages = array($paste); // If it's a discussion, get all comments. if (property_exists($paste->meta, 'opendiscussion') && $paste->meta->opendiscussion) { $messages = array_merge($messages, $this->_model()->readComments($dataid)); } $this->_data = json_encode($messages); // If the paste was meant to be read only once, delete it. if (property_exists($paste->meta, 'burnafterreading') && $paste->meta->burnafterreading) { $this->_model()->delete($dataid); } } } else { $this->_error = 'Paste does not exist or has expired.'; } }
msg::ok($txt('updated')); } } else { $my_app->set_param('action_status', 'error'); $my_app->set_param('action_status_msg', txt('access_denied')); cache_param('action_status'); cache_param('action_status_msg'); msg::error($txt('access_denied')); } } /* ************************** */ if (form_submit('new_folder')) { if ($readonly != 1) { if ($phposFS->new_dir(strip_tags(filter::fname($_POST['new_folder_name'])))) { $my_app->set_param('action_status', 'ok'); $my_app->set_param('action_status_msg', txt('folder_created')); cache_param('action_status'); cache_param('action_status_msg'); msg::ok($txt('created')); } else { $my_app->set_param('action_status', 'error'); $my_app->set_param('action_status_msg', txt('folder_create_error')); cache_param('action_status'); cache_param('action_status_msg'); msg::ok($txt('created')); } } else { $my_app->set_param('action_status', 'error'); $my_app->set_param('action_status_msg', txt('access_denied'));
define('PHPOS_IN_LOADER', true); require_once PHPOS_DIR . 'config/core.php'; require_once PHPOS_DIR . 'config/database.php'; // Load all classes and functions require_once PHPOS_DIR . 'controllers/databaseController.php'; require_once PHPOS_DIR . 'classes/class.users.php'; require_once PHPOS_DIR . 'classes/class.phpos_config.php'; $config = new phpos_config(); //$config->get_logged_user(); $config->set_id_user(); require_once PHPOS_DIR . 'classes/class.helpers.php'; define("PHPOS_SYSTEM_LANG", cfg::get('lang')); define("PHPOS_USER_LANG", cfg::uget('lang')); require_once PHPOS_DIR . 'classes/class.api_wintask.php'; require_once PHPOS_DIR . 'classes/class.api_processes.php'; require_once PHPOS_DIR . 'classes/class.languages.php'; require_once PHPOS_DIR . 'controllers/languageController.php'; require_once PHPOS_DIR . 'controllers/helpersController.php'; require_once PHPOS_DIR . 'classes/class.phpos_tasks.php'; if (!empty($_GET['action'])) { switch (filter::alfas($_GET['action'])) { case 'update': if (globalconfig('demo_mode') != 1 || is_root()) { $config->update_user('wallpaper', filter::fname($_GET['wallpaper'])); $config->update_user('wallpaper_type', filter::fname($_GET['wallpaper_type'])); } break; default: break; } }
foreach ($_SESSION['tasks'] as $key => $value) { if ($key != 1) { $win_task = new api_wintask(); $win_task->setID($_SESSION['tasks'][$key]['id']); $win_task->getWindow(); $win_task->generateJavaScript('notags'); $js_code .= $win_task->getJavaScript(); } unset($win_task); } } break; case 'update': if (isset($_GET['id'])) { $win_task = new api_wintask(); $win_task->setID(filter::num($_GET['id'])); $win_task->getWindow(); $win_task->setParams($_GET['parameters_parsed']); $win_task->updateWindow(); unset($win_task); } break; default: break; } } // if !action if ($_GET['action'] != 'update') { $t = new phpos_tasks(); echo $t->render_tasks(); $js_context_menu = $t->get_jquery();
<?php require_once $_SERVER['DOCUMENT_ROOT'] . 'tz/model/stop.php'; class filter extends Stop { public function filtersStop() { $this->scanDirStop(); $str = ''; if (is_array($this->listStop)) { foreach ($this->listStop as $value) { $str .= $value; } echo $str; } else { echo $this->listStop; } } } $flListStop = new filter(); $flListStop->filtersStop();
$_SESSION['login_lang'] = $reqested_lang; } } $lang->lang_load($login_language); } else { $usr = new phpos_users(); $config = new phpos_config(); if ($usr->user_is_logged()) { $config->set_id_user($usr->get_logged_user()); } $usr->get_logged_user(); $access_level = $usr->get_access_level(); if (!empty($_GET['lang'])) { //$PHPOS_GLOBALCONFIG['lang'] = strtolower($_GET['lang']); //$PHPOS_USERCONFIG['lang'] = strtolower($_GET['lang']); $requested_lang = trim(filter::alfas(strtolower($_GET['lang']))); if ($langs->lang_exists($requested_lang)) { if ($config->get_global('demo_mode') != 1 || $access_level == 3) { $config->update_user('lang', $requested_lang); } else { $demo_lang = trim($requested_lang); $_SESSION['demo_lang'] = $demo_lang; } } } $txt = array(); if ($config->get_global('demo_mode') != 1 || $access_level == 3) { $langs->lang_load($config->get_user('lang')); } else { $langs->lang_load($_SESSION['demo_lang']); }
/** * Fills filter table by existing data */ public static function resetFilters() { /** @var \samson\activerecord\materialfield $filters Array of materialfield objects to fill filter table */ $filters = null; // TODO: add filter generation by filter type // check if such data exists in materialfield table if (dbQuery('materialfield')->join('field')->cond('filtered', 1)->group_by('Value')->exec($filters)) { // if yes - generate `filter` table db()->simple_query('TRUNCATE TABLE `' . dbMySQLConnector::$prefix . 'filter`'); foreach ($filters as $filter) { /** @var \samson\activerecord\filter $newFilter */ $newFilter = new filter(); $newFilter->field_id = $filter->FieldID; $newFilter->value = $filter->Value; $newFilter->save(); } } }