"-", 1 => "interesting", 2 => "considering", 3 => "ordering" ); $OPU_TYPES_S = array( 1 => "interesting", 2 => "considering", 3 => "ordering", 4 => "ordered" ); $OP_CURRENCIES = array( "CHF" => "CHF", "EUR" => "EUR", "USD" => "USD" ); $db_conn = null; function db_connect() { global $db_conn, $db_url; $db_conn = pg_pconnect( $db_url ); } function db_begin() { global $db_conn; return pg_exec( $db_conn, "begin work" ); } function db_commit() { global $db_conn; return pg_exec( $db_conn, "commit work" ); } function db_rollback() { global $db_conn; return pg_exec( $db_conn, "rollback work" ); } function db_escape_str( $str ) { return "'" . pg_escape_string( $str ) . "'"; } function db_escape_str_like( $str, $pfx=true, $sfx=true ) { if( $pfx ) { $pfx = "'%"; } else { $pfx = "'"; } if( $sfx ) { $sfx = "%'"; } else { $sfx = "'"; } return $pfx . pg_escape_string( $str ) . $sfx; } function db_query( $sql ) { global $db_conn; return pg_exec( $db_conn, $sql ); } function db_next( $ress ) { return pg_fetch_array( $ress ); } function db_update( $sql ) { global $db_conn; $ress = pg_exec( $db_conn, $sql ); if( $ress ) { return pg_affected_rows( $ress ); } return -1; } function db_next_nr( $table, $field, $where="" ) { $sql = "select max($field)+1 as NRNEXT, count(*) as NRCNT from $table"; if( $where != "" ) { $sql .= " where " . $where; } $ress = db_query( $sql ); if( $ress ) { $row = db_next( $ress ); if( $row ) { if( $row["nrcnt"] > 0 ) { return $row["nrnext"]; } else { return 1; } } } return 0; } function get_GET_var( $name, $dfl="", $trim=true ) { if( isset( $_GET[$name] ) ) { $dfl = ereg_replace( "\\([\\\"'])", "\\1", $_GET[$name] ); if( $trim ) { $dfl = trim( $dfl ); } } return $dfl; } function get_POST_var( $name, $dfl="", $trim=true ) { if( isset( $_POST[$name] ) ) { $dfl = ereg_replace( "\\\\([\\\\\"'])", "\\1", $_POST[$name] ); if( $trim ) { $dfl = trim( $dfl ); } } return $dfl; } function get_FORM_var( $name, $dfl="", $trim=true ) { if( isset( $_POST[$name] ) ) { $dfl = ereg_replace( "\\([\\\"'])", "\\1", $_POST[$name] ); if( $trim ) { $dfl = trim( $dfl ); } } else if( isset( $_GET[$name] ) ) { $dfl = ereg_replace( "\\([\\\"'])", "\\1", $_GET[$name] ); if( $trim ) { $dfl = trim( $dfl ); } } return $dfl; } function make_price_str( $price, $zerostr="" ) { if( $price ) { $neg = ""; if( $price < 0 ) { $neg = "-"; $price = -$price; } $i = $price / 100; $f = $price % 100; return sprintf( "%s%d.%02d", $neg, $i, $f ); } return $zerostr; } function print_select( $name, $array, $selected=null, $addarray=null, $onchange="" ) { if( $onchange != "" ) { $onchange = " onChange=\"" . $onchange . "\""; } echo ""; } function print_tab_select( $label, $name, $array, $selected=null, $addarray=null, $onchange="" ) { echo "
" . htmlentities($text) . "
\n"; } function debug_print_array( $array ) { $pfx = "";
foreach( $array as $key => $value )
{
echo $pfx."'".htmlentities($key)."'='".htmlentities($value)."'";
$pfx = "
";
}
echo "