with file basename as text. */ function bbftp($file) { return sprintf('%s', $_SERVER['USER'], $_SERVER['HTTP_HOST'], $_SERVER['DOCUMENT_ROOT'], $file, $file, basename($file)); } /** * Returns an image tag for image specified in $src. * * @param string $src File name of the image, including path 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 (true === ($gis = @getimagesize($filepath)) && !preg_match('/width|height/', $extra)) { $image_size = $gis[3]; } else { $image_size = ''; } return sprintf('%s', $src, $image_size, oTxt($alt), $extra ); } /** * Prints an image tag for image specified in $src. * * @param string $src File name of the image, including path and file extension. * @param string $alt Alt tag text. * @param string $extra Additional attributes. */ 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) { $app =& App::getInstance(); $db =& DB::getInstance(); $qid = $db->query("SHOW COLUMNS FROM " . $db->escapeString($db_table) . " LIKE '" . $db->escapeString($db_col) . "'",false); $row = mysql_fetch_row($qid); if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) { natsort($enum[1]); return $enum[1]; } else { $app->logMsg(sprintf('No set or enum fields found.', null), LOG_ERR, __FILE__, __LINE__); 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"' : ''; ?> query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false); while ($row = mysql_fetch_assoc($qid)) { $selected = in_array($row[$val_column], $preselected) ? ' selected="selected"' : ''; ?>query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false); while ($row = mysql_fetch_assoc($qid)) { $values[] = $row; } // Rearrange array so sort is in vertical columns. FIXME: doesn't work. // if ($vert_columns) { // $per_col = ceil(sizeof($values) / $columns); // $columns = ceil(sizeof($values) / $per_col); // $curr_row = 0; // $curr_col = 0; // $pos = 0; // foreach ($values as $k=>$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; ?>
    />  
    * @version 1.0 * @since 15 Jun 2005 13:42:21 */ function printSubmitButtons($submit_buttons) { if (is_array($submit_buttons) && !empty($submit_buttons)) { foreach ($submit_buttons as $i => $b) { if (is_array($b)) { ?>