/** * Create Filtering form and return SQL condition * @param filters: (array) filtering input names starting with (# <=> equal , % <=> like) * @param fields: (array) db fields * @param op: AND/OR * @param with_hidden: 1/0 show url variables in SQL condition. * @return SQL condition */ function createFilter($filters, $fields, $op = "AND", $extention = "", $with_hidden = 1, $black_list = null) { //create filter fields: $params = getUrlParameters(); if (is_array($black_list)) { array_push($black_list, 'action'); array_push($black_list, 'id'); } else { $black_list = array("action", "id"); } foreach ($fields as $f) { } foreach ($fields as $field) { $name = $param[0]; $value = $param[1]; if ($name == "pn") { $value = 0; } if ($name == "") { continue; } $field = substr($field, 1); if (!in_array($name, $field) && !in_array($name, $black_list)) { $hidden_input .= "<input type='hidden1' id='{$name}' name='{$name}' value='{$value}'/>"; } } $result = "<form method='get' action='" . $_SERVER['SCRIPT_NAME'] . "'><u>" . filteringBy . ":</u> "; $i = 0; foreach ($filters as $filter) { $filter_name = ucfirst(str_replace("_", " ", $filter)) . ":"; $filter_type = "type='text'"; if ($fields[$i][0] == '^') { continue; } $filde_name = str_replace('^', '', $fields[$i]); $filde_name = str_replace('%', '', $fields[$i]); $result .= "{$filter_name} <input {$filter_type} id='{$filter}' name='{$filde_name}' value='" . $_REQUEST[$filde_name] . "'/> "; $i++; } $result .= $extention; if ($with_hidden) { $result .= $hidden_input; } $result .= "<input type='submit' value='" . _go . "' style='width:35px' class='go' /> <a href='" . $_SERVER['PHP_SELF'] . "' >" . clear_fillter . "</a></form>"; echo "<div class='filtering fl'>" . $result . "</div>"; //create filter query stmt: $num = count($fields); $cond = ""; for ($i = 0; $i < $num; $i++) { $filde_name = str_replace('^', '', $fields[$i]); $filde_name = str_replace('%', '', $fields[$i]); $value = $_REQUEST[$filde_name]; if ($value == "") { continue; } $fieldGrp = trim($fields[$i]); $fieldArr = explode('|', $fieldGrp); $cond .= "("; foreach ($fieldArr as $field) { if (strlen($field) <= 1) { continue; } $compare_type = $field[0]; $field = substr($field, 1); switch ($compare_type) { case "#": case "^": $cond .= $field . "='" . $value . "' "; break; case "%": $cond .= $field . " LIKE '%" . $value . "%'"; break; } $cond .= " OR "; } $cond = trim(trim($cond), "OR"); $cond .= ") {$op} "; } $cond = trim(trim($cond), $op); return $cond; }
?> </div> <div class="logo"><img src="themes/<?php echo "{$theme}/logo.png"; ?> "></div> </div> </div> <!-- MAIN --> <div id="main"> <div class="content"> <?php $urlParameters = getUrlParameters(); if ($urlParameters["namedpage"]) { showPage($urlParameters["namedpage"]); } elseif ($urlParameters["blogentry"]) { showEntry($urlParameters["blogentry"], FALSE); } else { $numEntriesPrinted = showOverview($urlParameters["blogpage"], $entriesPerPage); } ?> </div> <div class="pagelink"> <?php if (!$urlParameters["blogentry"] and !$urlParameters["namedpage"] and $numEntriesPrinted != 0 and $blogpage > 1 | $showNextPage) { if ($blogpage > 1) { echo "<a href=\"index.php?blogpage=" . ($blogpage - 1) . "\"><<</a>";