- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
if($_GET)
{
$args = explode("&",$_SERVER['QUERY_STRING']);
foreach($args as $arg)
{
$keyval = explode("=",$arg);
if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
}
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 8
+161
if($_GET)
{
$args = explode("&",$_SERVER['QUERY_STRING']);
foreach($args as $arg)
{
$keyval = explode("=",$arg);
if($keyval[0] != "page" And $keyval[0] != "ipp") $this->querystring .= "&" . $arg;
}
}
Уникальный способ получения get параметров....
+162
$str = strip_tags(htmlentities($str));
простовато, но...
Тэги не пройдут!!!
+178
function verifyQuery($sql, $con) {
if (!mysql_query($sql, $con)) {
echo "Error occured in verifyQuery() in sqlfunctions.php <br>";
echo "SQL sent : ";
echo $sql;
echo "<br>Database report: <br>";
die('Error: ' . mysql_error());
}
return mysql_query($sql, $con);
}
+168
function test_file_for_smells( $filename )
{
global $MAX_FUNCTION_LINE_COUNT, $MAX_INDENTATION_LEVEL;
$function_line_count = 0;
$found_continued_line = 0;
$line_number = 0;
$fp = fopen( $filename, "r" );
if( ! $fp )
return;
while( ! feof( $fp ) )
{
$line = chop( fgets( $fp, 4096 ) );
$line_number++;
while( substr( $line, 0, 9 ) == "function " &&
substr( $line, strlen($line) - 1, 1 ) != ')' )
{
$line = $line . chop( fgets( $fp, 4096 ) )
$found_continued_line++;
}
if( substr( $line, 0, 9 ) == "function " )
{
$function_line_count = 1;
$function_name = substr( $line, 9, strpos($line, '(') - 9 );
}
if( $function_line_count > 0 )
{
if( $line == "\t}" )
{
$function_line_count = $function_line_count - 3;
if( $function_line_count > $MAX_FUNCTION_LINE_COUNT )
print_warning( $filename, $line, $line_number, "$function_name() too long ($function_line_count lines)" );
$function_line_count = 0;
}
else
$function_line_count++;
$result = test_line_for_indentation( $line, $MAX_INDENTATION_LEVEL );
if( ! $result )
print_warning( $filename, $line, $line_number, "Too much nesting." );
$result = test_line_for_function_definition( $line, $MAX_NUM_PARAMETERS );
if( ! $result )
print_warning( $filename, $line, $line_number, "Too many parameters." );
if( $found_continued_line > 0 )
{
$line_number += $found_continued_line;
$found_continued_line = 0;
}
}
}
}
Детектор говнокода!!!!
+168
function IsAlphaNumeric($str)
{
$old = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
$new = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
if (str_replace($str, $old, $new) == "")
{
return (true);
}
else
{
return (false);
}
}
говно + валидация = говнодация
+161
$sec_in_year = 31536000;
$sec_in_lyear = 31622400;
$sec_in_28 = 2419200;
$sec_in_29 = 2505600;
$sec_in_30 = 2592000;
$sec_in_31 = 2678400;
$sec_in_day = 86400;
$sec_in_hour = 3600;
$sec_in_min = 60;
$year_count = 1970;
$month_count = 0;
$day_count = 1;
$hour_count = 0;
$min_count = 0;
$lyear_count = 2; // Make an array of seconds per month for ease of use.
$months = array(2678400, 2419200, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
$lmonths = array(2678400, 2505600, 2678400, 2592000, 2678400, 2592000, 2678400, 2678400, 2592000, 2678400, 2592000, 2678400);
$month_list = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
while($utime >= $sec_in_year) { // Count the year since 1970.
if($lyear_count % 4 == 0) {
$utime -= $sec_in_lyear; // Compensate for leap years.
}
else {
$utime -= $sec_in_year;
}
$year_count++;
$lyear_count++;
}
while($utime >= $months[$month_count]) { // Count the months since Jan.
if($lyear_count % 4 == 0) {
$utime -= $lmonths[$month_count]; // Compensate for leap year Feb.
}
else {
$utime -= $months[$month_count];
}
$month_count++;
}
И еще куча строк кода.
Конвертим никсовый временной штамп, в читаемый для человека формат... aka date()
+156
// To protect MySQL injection
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysqli_real_escape_string($connect, $username);
$password = mysqli_real_escape_string($connect, $password);
$login = mysqli_query($connect, "SELECT * FROM users WHERE username = '$username'");
while ($row = mysqli_fetch_assoc($login))
{
$db_password = $row['password'];
if (sha1($password) == $db_password)
$loginok = TRUE;
else
$loginok = FALSE;
if ($loginok == TRUE)
{
// Register $username, $password
$_SESSION["username"] = $username;
exit();
}
else
die('Feil brukernavn/passord.');
}
pastebin временами радует :)
http://pastebin.com/hW8BbEmt
+168
$Y=date('Y'); $m=date('m'); $d=date('d');$G=date('G');$i=date('i');$s=date('s');
$tdate=mktime($G,$i,$s,$m,$d,$Y);