<commit_before><?php
/**
    QGIS-WEB-CLIENT - PHP HELPERS

    Get search geometry

    @copyright: 2013 by <NAME> - ItOpen (http://www.itopen.it) <<EMAIL>>
    @license: GNU AGPL, see COPYING for details.
*/


require_once(dirname(__FILE__). '/config.php');
require_once(dirname(__FILE__). '/helpers.php');


// Params
$map = get_map_path(@$_REQUEST['map']);
$layername = trim(@$_REQUEST['searchtable']);

if(array_key_exists($layername, $searchlayers_config)){
   $layer_config =  $searchlayers_config[$layername];
} else {
    err500('layer not found or not searchable');
}

$displaytext = trim(@$_REQUEST['displaytext']);

// Get project
$project = get_project($map);

// Sanitize
$displaytext = preg_replace('/[^A-z0-9_-]\s/', '', $displaytext);

// Get layer
$layer = get_layer($layername, $project);

$ds_params = get_layer_info($layer, $project);

$sql = "SELECT ST_AsText(${ds_params['geom_column']}) AS geom FROM " . $ds_params['table'] . " WHERE ${layer_config['search_column']} = ?";
$dbh = get_connection($layer, $project);
$stmt = $dbh->prepare($sql);
$stmt->bindValue(1, $displaytext, PDO::PARAM_STR);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_NUM);
if(count($row)){
    $result = $row[0];
    header('Content-type: application/json');<commit_msg>Fixed bug with wrong params count<commit_after><?php
/**
    QGIS-WEB-CLIENT - PHP HELPERS

    Get search geometry

    @copyright: 2013 by <NAME> - ItOpen (http://www.itopen.it) <<EMAIL>>
    @license: GNU AGPL, see COPYING for details.
*/


require_once(dirname(__FILE__). '/config.php');
require_once(dirname(__FILE__). '/helpers.php');


// Params
$map = get_map_path(@$_REQUEST['map']);
$layername = trim(@$_REQUEST['searchtable']);

if(array_key_exists($layername, $searchlayers_config)){
   $layer_config =  $searchlayers_config[$layername];
} else {
    err500('layer not found or not searchable');
}

$displaytext = trim(@$_REQUEST['displaytext']);

// Get project
$project = get_project($map);

// Sanitize
$displaytext = preg_replace('/[^A-z0-9_-]\s/', '', $displaytext);

// Get layer
$layer = get_layer($layername, $project);

$ds_params = get_layer_info($layer, $project);

$sql = "SELECT ST_AsText(${ds_params['geom_column']}) AS geom FROM " . $ds_params['table'] . " WHERE ${layer_config['search_column']} = ?";
$dbh = get_connection($layer, $project, $map);
$stmt = $dbh->prepare($sql);
$stmt->bindValue(1, $displaytext, PDO::PARAM_STR);
$stmt->execute();

$row = $stmt->fetch(PDO::FETCH_NUM);
if(count($row)){
    $result = $row[0];
    header('Content-type: application/json');
{'fraction_non_alphanumeric': 0.20015576323987538, 'fraction_numerical': 0.008566978193146417, 'mean_word_length': 5.3432098765432094, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '191024', 'n_tokens_mistral': 921, 'n_tokens_neox': 896, 'n_words': 173}