|
Holy poo poo. I've seen some awful code on my job... but THIS has to be the worst thing I've ever seen. The function is used to create a series of dropdown boxes to select month, day, year, hour, and minute. php:<? function displayHTMLMenu( $type, $name, $class, $value_digits, $value_selected, $value_top_name, $value_top_value, $on_change_function_name, $return_or_echo_content = "echo" ) { //global $CM_app_system_path; // get menu data START if ($type == "month_names") { if( $_SESSION["sessionStat"]["lowresolution"] ) { $nxtFile = LIST_DATA_FILES_PATH . "list_date_month_names_abbrv.txt"; } else { $nxtFile = LIST_DATA_FILES_PATH . "list_date_month_names.txt"; } } else if ($type == "day_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_day_numbers.txt"; } else if ($type == "year_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_year_numbers.txt"; } else if ($type == "year_numbers_current_and_previous_in_january") { // no file for year_numbers_current_and_previous_in_january, generate dynamically $all_data_array[] = array (date("Y"), date("Y"), date("Y")); if (date("M") == "Jan") { $all_data_array[] = array (date("Y")-1, date("Y")-1, date("Y")-1); } } else if ($type == "hour_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_hour_numbers.txt"; } else if ($type == "minute_numbers") { $nxtFile = LIST_DATA_FILES_PATH . "list_date_minute_numbers.txt"; } else // default { $nxtFile = LIST_DATA_FILES_PATH . "list_date_minute_numbers.txt"; } if( isset( $nxtFile ) && file_exists( $nxtFile ) ) { $fd = fopen ($nxtFile, "r") or die ("Could not open file"); flock ($fd, 2); while (!feof($fd)) { $buffer = fgets ($fd, 4096); $next_line_array = split("\|", $buffer); $all_data_array[] = $next_line_array; //echo $all_data_array[0]; } flock ($fd, 3); fclose($fd); } else { // file not found //echo "<h1>file not found</h1>"; } // get menu data END $content_to_return = "<select name=\"$name\" class=\"$class\" onchange=\"$on_change_function_name(this);\">"; if (!empty ($value_top_name) || !empty ($value_top_value)) { $content_to_return .= "<option value=\"$value_top_value\">$value_top_name"; } foreach ($all_data_array as $next_data_array) { //echo $next_data_array[0]; if ($next_data_array[0] != "") { // get next value START if ($value_digits == 1) // no leading zeros { $next_value = $next_data_array[1]; } else if ($value_digits == 2) // leading zeros { $next_value = $next_data_array[2]; } else { $next_value = $next_data_array[2]; // leading zeros, default } // get next value END if ($next_value == $value_selected) { $content_to_return .= "<option value=\"$next_value\" selected>$next_data_array[0]"; } else { $content_to_return .= "<option value=\"$next_value\">$next_data_array[0]"; } } } $content_to_return .= "</select>"; if( $return_or_echo_content == "return" ) { return $content_to_return; } else { echo $content_to_return; } ?>
|
# ¿ Apr 4, 2008 21:57 |
|
|
# ¿ May 5, 2024 02:10 |
|
shopvac4christ posted:An enumeration I found, the values of which are used in a database table. Everyone remember this when they hear CS students complaining about CPU logic and close-to-the-metal programming classes!
|
# ¿ Apr 23, 2008 20:48 |
|
My boss found this today in our app.code:
Randomosity fucked around with this message at 16:11 on Jun 13, 2008 |
# ¿ Jun 13, 2008 14:31 |
|
Error handlers are just another form of control structure!code:
|
# ¿ Jun 17, 2008 21:31 |
|
I have discovered an unholy trifecta brewing in a project I will likely be working on soon. Javascript YUI HUNGARIAN NOTATION Pray for me.
|
# ¿ Jan 5, 2009 23:56 |
|
Can anyone explain why PHP is like this?php:<? if($undefined_var){ //Evaluates to false. ... } define('DEFINED', true); if(DEFINED){ //Evaluates to true ... } if(NOT_DEFINED){ //Evaluates to true } ?>
|
# ¿ Jun 10, 2010 22:14 |
|
ToxicFrog posted:Who the gently caress uses floats to store monetary amounts At the risk of sounding stupid, what's that preferred way? VVV hah, I understand how floats are stored and their implicit fuzziness. I meant which variable type or some other method. Randomosity fucked around with this message at 19:57 on Feb 24, 2011 |
# ¿ Feb 24, 2011 19:50 |
|
My co-worker is a really smart programmer and a great guy, but he is convinced empty lines make code ugly and hard to read.
|
# ¿ May 10, 2011 16:03 |
|
|
# ¿ May 5, 2024 02:10 |
|
Found a bug in some inventory code today that was way, way old. It's bad programming, but it's bad because it expected PHP not to be quirky.code:
|
# ¿ Jun 17, 2011 04:35 |