<?php
function collega_db() {
global $ADODB_COUNTRECS,$ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$ADODB_COUNTRECS = false;
$db = ADONewConnection('mysql');
if(isset($_GET['debug'])) {
$db->debug = true;
} else {
$db->debug = false;
}
$db->Connect(DB_SERVER,DB_SERVER_USERNAME,DB_SERVER_PASSWORD, DB_DATABASE);
return $db;
}
function xQuery($query) {
global $db;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
return($db->Execute($query));
}
function xQuery_db($query) {
global $db;
$db->Execute($query);
return $db;
}
function errQuery($query,$errno,$error) {
die('<font color="#000000"><b>' . $errno . ' - ' . $error . '<br /><br />' . $query . '<br /><br /><small><font color="#ff0000">[TEP STOP]</font></small><br /><br /></b></font>');
}
function draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
$field = '<select name="' . ($name) . '"';
if ($parameters) $field .= ' ' . $parameters;
$field .= '>';
if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . ($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' SELECTED';
}
$field .= '>' . $values[$i]['text'] . '</option>';
}
$field .= '</select>';
if ($required == true) $field .= '';
return $field;
}
/*getCommunitySelector
id it willbe the number of the id
it createts a slection box and then an input box both together. Sometimes it's usefull to build'em separetly
passing select=true, or input=true it will creates just that section
*/
function getCommunitySelector($id='0',$select=true,$input=true,$prmCountry='',$prmCommunity='') {
require('geozonesearch.php');
if($select) {
$countryList=geozoneSearch::getCountries();
if($countryList) {
echo draw_pull_down_menu('country_'.$id,$countryList,'','id="country_'.$id.'" '.$prmCountry,'0_0');
} else {
return false;
}
}
if($input) {
echo '<input type="text" "'.$prmCommunity.'" autocomplete="off" disabled="true" name="community_'.$id.'" id="community_'.$id.'" value="Seleziona uno stato" /><input type="hidden" name="communityID_'.$id.'" id="communityID_'.$id.'" value="" />';
echo '<div id="commSuggest_'.$id.'"></div>';
}
}
function loadCommunitySelector($id='0') {
return '$("#country_'.$id.'").loadCommunitySelector({"index":"'.$id.'"});';
}
function loadJSCommunitySelector($id='0') {
return 'loadJSCommunitySelector('.$id.');';
}
function clean_get__recursive($get_var)
{
if (!is_array($get_var))
return preg_replace("/[^ {}%a-zA-Z0-9_.-]/i", "", $get_var);
// Add the preg_replace to every element.
return array_map('clean_get__recursive', $get_var);
}
function clean_global($get_var) {
foreach ($get_var as $key => $value)
( isset($GLOBALS[$key]) ? $GLOBALS[$key] = $get_var[$key] : NULL );
}
?>
|