'Inactive', '1'=> 'Active', '2'=> 'Pending'); $map_status_news_color = array('0'=> 'red', '1'=> 'green', '2'=> 'blue'); $map_status_artists = array('0'=> 'Inactive', '1'=> 'Active', '2'=> 'Pending'); $map_status_artists_color = array('0'=> 'red', '1'=> 'green', '2'=> 'blue'); $map_artwork_medium = array( '0'=> 'Select a medium', '1'=> 'Acrylic on canvas', '2'=> 'Acrylic on paper', '3'=> 'Oil on canvas', '4'=> 'Oil on board', '5'=> 'Digital Photograph', '6'=> 'Ink on paper', '7'=> 'Watercolour on Paper', '8'=> 'Charcoal on canvas', '9'=> 'Charcoal on paper' ); ?> $characters) { $characters = $characters - 3; $str = substr($str, 0, $characters); $str = preg_replace("/\s+$/i", '', $str); $str = $str . "..."; } return $str; } # Check Plurals function plural ($number, $singular, $plural) { if ($number != 1) return $plural; else return $singular; } # Determine if checkbox is checked function chCheck($value) { return (($value == 1) ? 'CHECKED' : ''); } # Generate list from map function generate_map_list ($fieldname, $def_val, $show_any, $data, $max_element) { $i = 0; $xlist = "\n"; return $xlist; } # Generate list from array function generate_array_list ($fieldname, $def_val, $show_any, $arraymap) { $i = 0; #@data = @{$arraymap}; $data = $arraymap; $xlist = "\n"; return $xlist; } # Generate list from array map function generate_arraymap_list ($fieldname, $def_val, $arraymap, $show_any=0) { $xlist = "\n"; return $xlist; } ######################################################################## # PAGE FUNCTIONS ######################################################################## # Output normal contents with header/footer function output ($msg) { global $site_templates; $header=file_get_contents("$site_templates/header.tpl"); $footer=file_get_contents("$site_templates/footer.tpl"); echo $header; echo "
$msg

"; echo $footer; exit; } # Output error using error template function output_error () { global $template_error; $values = func_get_args(); $goback = $values[0]; $err_msg = $values[1]; $err_title = $values[2]; $err_width = $values[3]; if ($err_width == '') { $err_width = '85%'; } if ($goback == 1) { $err_msg .= "

"; } if ($err_title == '') { $err_title = 'Invalid Field Entry'; } $values = array('ERR_TITLE' => $err_title, 'ERR_MSG' => $err_msg, 'ERR_WIDTH' => $err_width); output("$err_title
$err_msg"); } # Makes use of output_error's template function output_notify () { $values = func_get_args(); $msg = $values[0]; $title = $values[1]; $width = $values[2]; if ($title == '') { $title = ' '; } output_error(0, $msg, $title, $width); } ######################################################################## # DATABASE FUNCTIONS ######################################################################## # Load database function loaddb($dbname) { global $database_server, $database_user, $database_pass; $db = mysql_connect($database_server, $database_user, $database_pass); mysql_select_db($dbname); return $db; } # Obtain values directly for single result query function sqlget($db, $query) { $ref = sqlrun($db, $query); $result = mysql_fetch_array($ref, MYSQL_BOTH); return $result; } # Directly return first value from query function sqlget_direct($db, $query) { $ref = sqlrun($db, $query); $result = mysql_fetch_array($ref, MYSQL_BOTH); return $result[0]; } # Run SQL query with error wrapper function sqlrun($db, $query) { global $default_admin_mail; $ref = mysql_query($query, $db); if (!$ref) { # Log error //$handle = fopen("/site/system/logs/sqlerror.txt", "a"); //fwrite($handle, $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " [". date("r") . "]:\n$query\n" . mysql_error() . "\n\n"); //fclose($handle); //output_error(0, "$query:
" . mysql_error() . "


", 'Database Access Error' ); echo "Database Access Error
$query:
" . mysql_error() . "


"; } return $ref; } # Replace \ and ' for SQL Insertion function replace_sql_values ($arr) { $count = 0; while ($count < count($arr)) { $arr[$count] = str_replace('\\', '\\\\', $arr[$count]); $arr[$count] = str_replace('\'', '\'\'', $arr[$count]); $count++; } } # Revert \ and ' from SQL Insertion function revert_sql_values ($arr) { $count = 0; while ($count < count($arr)) { $arr[$count] = str_replace('\\\\', '\\', $arr[$count]); $arr[$count] = str_replace('\'\'', '\'', $arr[$count]); $count++; } } ?>