calendar.php {Parte 2}
Código PHP:
$output = "<div id=\"response\"></div>".$output;
}
return $output;
}
function database($querydb) {
global $global;
global $field;
if (isset($global['queries'])) {
$global['queries']++;
} else {
$global['queries'] = "1";
}
$field['queries'] = $global['queries'];
if (isset($global['query_log'])) {
$global['query_log'] .= "\n<br>$querydb";
} else {
$global['query_log'] = "$querydb";
}
mysql_connect($global['dbhost'], $global['dbuser'], $global['dbpass']) or return_error("Unable to connect to host $global[dbhost]");
mysql_select_db($global['dbname']) or return_error("Unable to select database $global[dbname]");
$global['dbresult'] = mysql_query($querydb) or return_error("Query Error: $querydb");
if ((substr($querydb,0,6)!="INSERT") && (substr($querydb,0,6)!="UPDATE") && (substr($querydb,0,6)!="DELETE")) {
$global['dbnumber'] = mysql_numrows($global['dbresult']);
}
return;
}
function return_error($error) {
print $error;
exit;
}
function date_status($date, $username) {
global $global;
global $field;
global $input;
global $text;
$status = "0";
if ($username!="") {
$query = "SELECT id, start_date, end_date FROM oc_calendar WHERE username = '$username' AND (date_format(start_date,'%Y-%m-%d') <= date_format('$date','%Y-%m-%d') AND date_format(end_date,'%Y-%m-%d') >= date_format('$date','%Y-%m-%d'))";
database($query);
for ($i = 0; $i < $global['dbnumber']; $i++) {
$status = "1";
$event_id = mysql_result($global['dbresult'],$i,"id");
$event_start_date = mysql_result($global['dbresult'],$i,"start_date");
$event_end_date = mysql_result($global['dbresult'],$i,"end_date");
}
}
return $status;
}
?>