".$sql."
"; } } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { $GLOBALS["oracle_statement"] = OCIParse ( $GLOBALS["oracle_connection"], $sql ); return OCIExecute ( $GLOBALS["oracle_statement"], OCI_COMMIT_ON_SUCCESS ); } else if ( strcmp ( DB_SERVER_TYPE, "postgresql" ) == 0 ) { $GLOBALS["postgresql_row"] = 0; $GLOBALS["postgresql_row"] = 0; $res = pg_exec ( $GLOBALS["postgresql_connection"], $sql ); if ( ! $res ) { bx_db_fatal_error ( "Error executing SQL" ); } $GLOBALS["postgresql_numrows"] = pg_numrows ( $res ); return $res; } else if ( strcmp ( DB_SERVER_TYPE, "odbc" ) == 0 ) { $GLOBALS["odbc_row"] = 0; return odbc_exec ( $GLOBALS["odbc_connection"], $sql ); } else { bx_db_fatal_error ( "dbi_query(): db_type not defined." ); } } // Close a database connection // Not necessary for any database that uses pooled connections // such as MySQL function bx_db_close () { global $db_link; if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { return @mysql_close ( $db_link ); } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { return OCILogOff ( $db_link ); } else if ( strcmp ( DB_SERVER_TYPE, "postgresql" ) == 0 ) { return pg_close ( $GLOBALS["postgresql_connection"] ); } else if ( strcmp ( DB_SERVER_TYPE, "odbc" ) == 0 ) { return odbc_close ( $GLOBALS["odbc_connection"] ); } else { bx_db_fatal_error ( "dbi_close(): db_type not defined." ); } } // Select the database that all queries should use //function dbi_select_db ( DB_DATABASE ) { // if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { // return mysql_select_db ( DB_DATABASE ); // } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { // // Not supported. Must sent up a tnsname and user that uses // // the correct tablesapce. // return true; // } else { // bx_db_fatal_error ( "dbi_select_db(): db_type not defined." ); // } //} /* function bx_db_num_rows($db_query) { $result = mysql_num_rows($db_query); return $result; } */ // Determine the number of rows from a result function bx_db_num_rows ( $res ) { if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { return @mysql_num_rows ( $res ); } else { bx_db_fatal_error ( "dbi_num_rows(): db_type not defined." ); } } /* function bx_db_fetch_array($db_query) { $result = mysql_fetch_array($db_query); return $result; } */ // Retrieve a single row from the database and return it // as an array. // Note: we don't use the more useful xxx_fetch_array because not all // databases support this function. function bx_db_fetch_array ( $res ) { if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { return @mysql_fetch_array ( $res ); } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { if ( OCIFetchInto ( $GLOBALS["oracle_statement"], $row, OCI_NUM + OCI_RETURN_NULLS ) ) return $row; return 0; } else if ( strcmp ( DB_SERVER_TYPE, "postgresql" ) == 0 ) { if ( $GLOBALS["postgresql_numrows"] > $GLOBALS["postgresql_row"] ) { $r = pg_fetch_array ( $res, $GLOBALS["postgresql_row"]++ ); if ( ! $r ) { echo "Unable to fetch row\n"; return ''; } } else { $r = ''; } return $r; } else if ( strcmp ( DB_SERVER_TYPE, "odbc" ) == 0 ) { $num_fields = odbc_num_fields ( $res ); if ( ! odbc_fetch_into ( $res, $GLOBALS["odbc_row"], $ret ) ) return false; return $ret; } else { bx_db_fatal_error ( "dbi_fetch_row(): db_type not defined." ); } } /* function bx_db_free_result($db_query) { $result = mysql_free_result($db_query); return $result; } */ // Free a result set. // This isn't really necessary for PHP4 since this is done automatically, // but it's a good habit for PHP3. function bx_db_free_result ( $res ) { if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { return @mysql_free_result ( $res ); } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { // Not supported. Ingore. if ( $GLOBALS["oracle_statement"] >= 0 ) { OCIFreeStatement ( $GLOBALS["oracle_statement"] ); $GLOBALS["oracle_statement"] = -1; } } else if ( strcmp ( DB_SERVER_TYPE, "postgresql" ) == 0 ) { return pg_freeresult ( $res ); } else if ( strcmp ( DB_SERVER_TYPE, "odbc" ) == 0 ) { return odbc_free_result ( $res ); } else { bx_db_fatal_error ( "dbi_free_result(): db_type not defined." ); } } // Get the latest db error message. function bx_db_error () { if ( strcmp ( DB_SERVER_TYPE, "mysql" ) == 0 ) { $ret = @mysql_error (); } else if ( strcmp ( DB_SERVER_TYPE, "oracle" ) == 0 ) { $ret = OCIError ( $GLOBALS["oracle_connection"] ); } else if ( strcmp ( DB_SERVER_TYPE, "postgresql" ) == 0 ) { $ret = pg_errormessage ( $GLOBALS["postgresql_connection"] ); } else if ( strcmp ( DB_SERVER_TYPE, "odbc" ) == 0 ) { // no way to get error from ODBC API $ret = "Unknown ODBC error"; } else { $ret = "bx_db_error(): db_type not defined."; } if ( strlen ( $ret ) ) { return $ret; } else { return "Unknown error"; } } // display an error message and exit function bx_db_fatal_error ( $msg ) { echo "

Error

\n"; echo "\n"; echo "$msg\n"; echo "\n"; exit; } //database conection functions function bx_db_data_seek($db_query, $row_number) { $result = @mysql_data_seek($db_query, $row_number); return $result; } function bx_db_insert_id() { $result = @mysql_insert_id(); return $result; } function bx_db_insert($db_table,$db_fields,$db_values) { return bx_db_query("insert into ".$db_table." ($db_fields)"." values ($db_values)"); } ?>\n"; } function bx_mail($sitename,$sitemail,$emailaddress,$subject,$message,$html="no") { $sitename=preg_replace("/\n|\r|(\015\012)|(\015)|(\012)|,|;|to:|cc:|bcc:/si","",$sitename); $sitemail=preg_replace("/\n|\r|(\015\012)|(\015)|(\012)|to:|cc:|bcc:/si","",$sitemail); $emailaddress=preg_replace("/\n|\r|(\015\012)|(\015)|(\012)|to:|cc:|bcc:/si","",$emailaddress); $subject=preg_replace("/\n|\r|(\015\012)|(\015)|(\012)|to:|cc:|bcc:/si","",$subject); $headers .= "From: $sitename <$sitemail>\n"; $headers .= "X-Sender: <$sitemail>\n"; $headers .= "X-Mailer: PHP/" . phpversion()."\n"; // mailer $headers .= "X-Priority: 3\n"; // 1 for Urgent message! $headers .= "Return-Path: <$sitemail>\n"; // Return path for errors if ($html=="yes") { $headers .= "Content-Type: text/html; charset=iso-8859-1\n"; } @mail($emailaddress, $subject, $message, $headers); } //exiting with closing the database function bx_exit(){ bx_db_close(); exit; } function bx_format_date($date, $format) { if ($format=="YYYY-mm-dd") { return $date; } elseif ($date=="0000-00-00") { return "N/A"; } else { if (preg_match("/YYYY/i",$format)) { $format = eregi_replace("YYYY","Y", $format); } elseif (preg_match("/YY/i",$format)) { $format = eregi_replace("YY","y", $format); } if (preg_match("/mm/i",$format)) { $format = eregi_replace("mm","m", $format); } elseif (preg_match("/m/i",$format)) { $format = eregi_replace("m","n", $format); } if (preg_match("/dd/i",$format)) { $format = eregi_replace("dd","d", $format); } elseif (preg_match("/d/i",$format)) { $format = eregi_replace("d","j", $format); } return date($format, mktime (0,0,0,substr($date,5,2),substr($date,8),substr($date,0,4))); } } function bx_format_price($price, $currency, $isprice=1) { if($isprice == 1) { if(eregi("1(.?)234(.?)(5|6|56)?$",trim(PRICE_FORMAT),$p_regs)) { $price = number_format($price,strlen($p_regs[3]),$p_regs[2],$p_regs[1]); } else { $price = number_format($price,2); } } if (CURRENCY_POSITION=="left") { return $currency.$price; } else { return $price." ".$currency; } } function bx_js_stripslashes($str) { $str = stripslashes($str); $str = str_replace('"',""",$str); $str = str_replace("'","'",$str); return $str; } function bx_addslashes($str){ if (get_magic_quotes_gpc()) { return $str; } else { return addslashes($str); } } function bx_stripslashes($str){ if (get_magic_quotes_gpc()) { return stripslashes($str); } else { return $str; } } function bx_dirty_words($str) { if(USE_DIRTY_WORDS == "yes") { $patterns = array(); $replacement = array(); $wordlist = split(",",trim(DIRTY_WORDS)); for ($i=0;$i'; return $image; } function bx_image($src, $border, $alt) { global $image; $image = '' . $alt . ''; return $image; } function bx_image_submit($src, $width, $height, $border, $alt) { global $image_submit; $image_submit = ''; return $image_submit; } function bx_image_submit_nowidth($src, $border, $alt) { global $image_submit; $image_submit = ''; return $image_submit; } function bx_table_header($title,$color="red") { $fontface="Verdana, Arial"; $fontcolor="white"; $fontsize="2"; return '
'.$title.'
'; } //error_reporting(0); // SQL_CHECK function // parameter: $NO_ROWS // if ($NO_ROWS==0) - NO_ROWS case if not error // if ($NO_ROWS!=0) - NO_ROWS case is ERROR function SQL_CHECK ( $NO_ROWS=1, $errmsg="An error occured" ) { global $bx_temp_query, $_SERVER, $_POST; $res = mysql_errno(); $error = mysql_error(); $error_flag = 0; $subtype = 0; if ($res==0) { // query successfully executed - so check NO_ROWS case if (($NO_ROWS) && (mysql_affected_rows()==0)) { // error: no rows returned $error_flag = 1; $subtype = 1; } } else { // an error occured $error_flag = 1; $post=""; while (list($header, $value) = each($_POST)) { $post.="\nPOST: ".$header." - ".((is_array($value))?implode(",",$value):$value).""; } } if ($error_flag && DEBUG_MODE=="no") { echo "
"; echo "
"; echo "Sorry....
An error occured during this request. An detailed error report was sent to admin,
so the error will be solved soon.
Please come back later. Thank you.
"; // sending the email @mail ( SITE_MAIL, SITE_TITLE.": An SQL error occured", // Message SITE_TITLE.": An SQL error occured:\n". "$errmsg\n\n". "MySQL error code: $res\n". "MySQL error text: $error\n". "Query: $bx_temp_query\n". "Date: ".date('Y-m-d H:i:s')."\n". "IP: ".$_SERVER['REMOTE_ADDR']."\n". "Page: http://".(getenv('HTTP_HOST')?getenv('HTTP_HOST'):$_SERVER['HTTP_HOST']).(getenv(REQUEST_URI)?getenv(REQUEST_URI):$_SERVER['REQUEST_URI'])."\n". "".$post."\n", "From: ".SITE_MAIL."\n". "Content-type: text/plain\n" ); } elseif($error_flag && DEBUG_MODE=="yes"){ ?> "; echo "
"; echo "Sorry....
An error occured during this request. An detailed error report was sent to admin,
so the error will be solved soon.
Please come back later. Thank you.

"; } elseif($NO_ROWS==4){ ?> read()) { if ($entry != "." && $entry != "..") { if (is_dir($dirname."/".$entry)) { $names[] = $entry; } } } $d->close(); return $names; } function getFiles($dirname=".") { $d = dir($dirname); while($entry = $d->read()) { if ($entry != "." && $entry != "..") { if (is_dir($dirname."/".$entry)) { } else { $names[] = $entry; } } } $d->close(); return $names; } function short_string($text, $length, $symbol = "...") { $length_text = strlen($text); $length_symbol = strlen($symbol); $sub_str = substr($text, 0, $length - $length_symbol); if ($length_text <= $length || $length_text <= $length_symbol || $length <= $length_symbol) { return($text); } else { $pos_space = strrpos($sub_str," "); $pos['comma'] = strrpos($sub_str,","); $pos['point'] = strrpos($sub_str,"."); $pos['pontveszo'] = strrpos($sub_str,";"); $pos['rbracket'] = strrpos($sub_str,")"); $pos['kettospont'] = strrpos($sub_str,":"); $pos['line'] = strrpos($sub_str,"-"); $pos['backslash'] = strrpos($sub_str,"/"); $pos['slash'] = strrpos($sub_str,"\\"); arsort($pos); $max_pos = current($pos); if ($max_pos && $max_pos > $pos_space) { return substr($text, 0, $max_pos).$symbol; } else { if ($pos_space) { if ((!$max_pos) || (($pos_space - $max_pos) > ($length/4))) { return substr($text, 0, $pos_space).$symbol; } else { return substr($text, 0, $max_pos).$symbol; } } else { return $sub_str.$symbol; } } } } function bx_make_url($url, $var, $replace) { if (eregi($var, $url)) { $url = eregi_replace("(\?|&){1,}$","",$url); $url.= "&"; $url = preg_replace("/".$var."=([^&]*)[&(.*)|$]/",$var."=".$replace."&\\2",$url); $url = eregi_replace("(\?|&){1,}$","",$url); } else { $url = eregi_replace("(\?|&){1,}$","",$url); if (eregi("\?", $url)) { $url .= "&".$var."=".$replace; } else { $url .= "?".$var."=".$replace; } } if($var!="ref") { $url=bx_make_url($url,"ref",substr(md5(time()),0,25)); } return $url; } function bx_unhtmlspecialchars($str) { return str_replace(array(">", "<", """, "&"), array(">", "<", "\"", "&"), $str); } function mogrifyIMageMagick($sourcefile, $dest_x, $dest_y) { $im = "/usr"; $mogrify = $im."/bin/mogrify"; @putenv("LD_LIBRARY_PATH=$im"."/lib"); @putenv("MAGICK_HOME=$im"); $local_size=getimagesize($sourcefile); if ($local_size[2]!=1) { switch ($local_size[2]) { case 2: $new_source = eregi_replace("\.gif$",".jpg", trim($sourcefile)); rename($sourcefile,$new_source); @exec($mogrify." -resize ".$dest_x."x".$dest_y." ".$new_source); rename($new_source,$sourcefile); break; case 3: $new_source = eregi_replace("\.gif$",".png", trim($sourcefile)); rename($sourcefile,$new_source); @exec($mogrify." -resize ".$dest_x."x".$dest_y." ".$new_source); rename($new_source,$sourcefile); break; default: break; }//end switch ($logo_size[2]) } else { @exec($mogrify." -resize ".$dest_x."x".$dest_y." ".$sourcefile); } } function convertIMageMagick($sourcefile, $dest_x, $dest_y, $targetfile) { $im = "/usr"; $convert = $im."/bin/convert"; @putenv("LD_LIBRARY_PATH=$im"); @putenv("MAGICK_HOME=$im"); @exec($convert." ".$sourcefile." -resize ".$dest_x."x".$dest_y." +profile \'*\' -quality 80 ".$targetfile); } function resizeToFile ($sourcefile, $dest_x, $dest_y, $targetfile, $jpegqual, $gd_type) { /* Get the dimensions of the source picture */ $picsize=getimagesize("$sourcefile"); $source_x = $picsize[0]; $source_y = $picsize[1]; $w = $source_x; // width $h = $source_y; // height $maxsize = $dest_x; // maximum size in one direction // prevent division by zero if (($h ==0) || ($w==0)) { $new_h = $dest_x; $new_w = $dest_y; } if ($h>$w) { $new_h = $maxsize; // new height $new_w = (int) (($maxsize * $w) / $h); // casting to int ! } else { $new_w = $maxsize; // new width $new_h = (int) (($maxsize * $h) / $w); // casting to int ! } $source_id = imageCreateFromJPEG("$sourcefile"); /* Create a new image object (not neccessarily true colour) */ if ($gd_type=="2") { if(function_exists(imagecreatetruecolor)){ if (!$target_id = imagecreatetruecolor($new_w, $new_h)) { return false; } }else{ if (!$target_id = imagecreate($new_w, $new_h)) { return false; } } } else { if (!$target_id = imagecreate($new_w, $new_h)) { return false; } } /* Resize the original picture and copy it into the just created image object. Because of the lack of space I had to wrap the parameters to several lines. I recommend putting them in one line in order keep your code clean and readable */ if ($gd_type=="2") { if (function_exists(imagecopyresampled)){ if(!imagecopyresampled($target_id,$source_id,0,0,0,0,$new_w, $new_h,$source_x,$source_y)) { return false; } } else{ if(!imagecopyresized($target_id,$source_id,0,0,0,0,$new_w, $new_h,$source_x,$source_y)) { return false; } } } else { if(!imagecopyresized($target_id,$source_id,0,0,0,0,$new_w, $new_h,$source_x,$source_y)) { return false; } } /* Create a jpeg with the quality of "$jpegqual" out of the image object "$target_pic". This will be saved as $targetfile */ imagejpeg ($target_id,"$targetfile",$jpegqual); return true; } function bx_hide_email($l_email, $subject="", $type="none"){ $pos = array(); if($type != "view") { $str= "mailto:".$l_email."?subject=".eregi_replace("'","\'",$subject); } else{ $str= $l_email; } $len = strlen($l_email); srand((double)microtime()*1000000); for ($i=0;$i