with file basename as text. */ function bbftp($file) { return sprintf('%s', $_SERVER['USER'], $_SERVER['HTTP_HOST'], SITE_BASE, $file, $file, basename($file)); } /** * Prints an image tag for image specified in $src. * * @param string $src File name of the image, including dir and file extension. * @param string $alt Alt tag text. * @param string $extra Additional attributes. */ function oImg($src, $alt='', $extra='') { $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; if (false === ($gis = @getimagesize($filepath)) || preg_match('/width|height/', $extra)) { $image_size = ''; } else { $image_size = $gis[3]; } return sprintf('%s', $src, $image_size, oTxt($alt), $extra ); } function printImg($src, $alt='', $extra='') { echo oImg($src, $alt, $extra); } /** * Finds the values of an enumeration or set column of a MySQL database, returning them in an array. * Use this to generate a pull-down menu of options or to validate the existance * of options. (Quinn 10 Feb 2001) * * @param string $db_table database table to lookup * @param string $db_col database column to lookup * * @return array Array of the set/enum values on success, false on failure. */ function getSetEnumFieldValues($db_table, $db_col) { $qid = dbQuery("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false); $row = mysql_fetch_row($qid); if (isset($row[1]) && preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { natsort($enum[1]); return $enum[1]; } else { return false; } } /** * Prints option fields for a select form. Works only with enum or set * data types in table columns. * * @param string $db_table database table to lookup * @param string $db_col database column to lookup */ function printSetSelectForm($db_table, $db_col, $preselected, $blank=false) { $values = getSetEnumFieldValues($db_table, $db_col); if ($values === false) { ?> val pair. if (is_array($blank)) { foreach ($blank as $key=>$val) { $selected = ($preselected == $val) ? ' selected="selected"' : ''; ?>
     
   
val pair. if (is_array($blank)) { foreach ($blank as $key=>$val) { $selected = in_array($val, $preselected) ? ' selected="selected"' : ''; ?> $v) { // $pos = $curr_row * $columns + $curr_col; // if ($curr_row <= $per_col) { // $curr_row++; // } else { // $curr_row = 0; // $curr_col++; // } // // echo '
  • ' . $pos . '-' . $v[$key_column]; // $new_values[$pos] = $v; // } // $values = $new_values; // ksort($values); // } if (empty($values)) { return false; } // Initialize the HTML table generation vars. $num_cells = sizeof($values) - 1; $num_rows = floor($num_cells / $columns); $cols_lastrow = $num_cells % $columns; $row_cnt = 0; $col_cnt = 0; ?>
    />