Beispiel #1
0
    //gestión de codigo de tema
    if ($_POST["edit_tema_id"]) {
        $tema_id = str_replace("edit_tema", "", $_POST["edit_tema_id"]);
        //additional secure check
        $string_term = secure_data($_POST["edit_tema"], "sql");
        if (is_numeric($tema_id) && strlen($string_term) > 0) {
            $task = abm_tema('mod', $string_term, $tema_id);
        }
        $arrayTerm = ARRAYverTerminoBasico($tema_id);
        echo $arrayTerm[tema];
    }
}
$searchq = $_GET['q'];
if (!$searchq) {
    return;
}
if (strlen($searchq) >= CFG_MIN_SEARCH_SIZE) {
    $getRecord_sql = $_GET[t] == 'e' ? SQLSimpleSearchTrueTerms($searchq, "15") : SQLbuscaTerminosSimple($searchq, "15");
    // ---------------------------------------------------------------- //
    // AJAX Response													//
    // ---------------------------------------------------------------- //
    if ($getRecord_sql[cant] > 0) {
        while ($row = mysqli_fetch_array($getRecord_sql[datos])) {
            $tema = $CFG["_CHAR_ENCODE"] == 'utf-8' ? $row[tema] : FixEncoding($row[tema]);
            //$tema=$row[tema];
            if (strpos(strtolower($tema), $searchq) !== false) {
                echo "{$tema}|{$row['tema_id']}\n";
            }
        }
    }
}
/**
 * Retorna los datos, acorde al formato de autocompleter
 */
function getData4Autocompleter($searchq, $type = 1)
{
    $sql = $type == 1 ? SQLstartWith($searchq) : SQLbuscaTerminosSimple($searchq, "15");
    $arrayResponse = array("query" => $searchq, "suggestions" => array(), "data" => array());
    while ($array = $sql->FetchRow()) {
        array_push($arrayResponse["suggestions"], $array["tema"]);
        array_push($arrayResponse["data"], $array["tema_id"]);
    }
    return json_encode($arrayResponse);
}