1. PHP / Говнокод #4700

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    echo "<body>";
    echo "<h1>Картинки</h1>";
    //$num =$_GET[num];
    $start = 0 ;
    $start=$_GET['start'];
    $ls_dir = $_GET ['ls_dir'];
    if (!isset($ls_dir ))
    {
        $ls_dir ="./pictures" ;
    }
    $num =10;
    if (!isset($start))
    {
        $start =0 ;
    }
    echo "$ls_dir";
    $dir = `ls $ls_dir | awk '/\.[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]?$/ {print "&&&" $1}'`;
    $fold_dir = `ls -l $ls_dir | awk '/^d/ {print "&&&" $9}'`;
    $pic_list = explode("&&&",$dir);
    $dir_list =explode("&&&",$fold_dir);
     
    echo "$fold_dir";
     
     
    ?>
     
    <h3>Доступные папки</h3>
    <ul>
    <?php
    for ($i=1;$i< count($dir_list);$i++)
    {
        $cur_val=$ls_dir."/".$dir_list[$i];
        echo "<li>";
     
    	 echo "<a href=pictures.php?start=0&ls_dir=$cur_val>";
        //echo $cur_val;
        echo "<img src=fold_im.JPG width=34 height=49 />";
    //    echo "&start=";
    //    echo $start;
    //    echo ">"; 
        echo $dir_list[$i];
        echo "</a>";
        echo "</li>";
    }
     
     
    ?>
     
     
    </ul>
     
     
    <table width="100%" border="1">
     
    <tr>
    <td width="10%">
    </td>
    <td><h1>Картинки из папки <?php echo $ls_dir ?></h1>
    </td>
    </tr>
    <?php
     
    for ($i = $start +1;($i<$start +1+ $num)&&($i<count($pic_list));$i++)
    {
        echo "<tr>";
        echo "<td width =10% >&nbsp</td>";
        $pic = $ls_dir."/".$pic_list[$i];
        echo "<td>";
        echo "<a href = $pic><img src=$pic/><a/>";
        echo "</td>";
        echo "</tr>";
    }
     
    ?>

    alexrp, 21 Ноября 2010

    Комментарии (27)
  2. PHP / Говнокод #4698

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?$APPLICATION->IncludeComponent("bitrix:system.auth.form","",Array(
         "REGISTER_URL" => "register.php",
         "PROFILE_URL" => "profile.php"
         "SHOW_ERRORS" => "Y" 
         )
    );?>

    Этот код из официальной документации Битрикса.
    Обратите внимание перечисление в массиве.

    Ох уж этот удивительный Битрискс... xD

    banji, 21 Ноября 2010

    Комментарии (38)
  3. PHP / Говнокод #4697

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (count($arResult[$j]["DATA"])!=1) $btw_max = count($arResult[$j]); else $btw_max = 0;
    
    				if ($btw_max ==2) $btw_max =1;
    
    
    
    				for ($k=0;$k<$btw_max;$k++){...}

    Суть проблемы, есть массив $arResult[$j]["DATA"], последний элемент которого лишний, его выводить не надо, для этого чувак сделал следующее
    Вместо того, чтобы это значения не добавлять в массив при его заполнении, либо исключив последний элемент при выводе. В общем труЪ говнокод :D

    minnigaliev-r, 21 Ноября 2010

    Комментарии (4)
  4. PHP / Говнокод #4695

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    elseif($_POST['step']=="step5"){
    	foreach($_POST['metric_checked'] as $key=>$value){
    		foreach($metrics as $key1=>$v1){
    			foreach($v1 as $key2)		    
    				foreach($value as $metric) 
    					if($key2==$_POST['metric'][$metric])
    						$_SESSION['metrics'][$key1][]=$_POST['metric'][$metric];
    		}
    	}
    }

    1_and_0, 21 Ноября 2010

    Комментарии (6)
  5. PHP / Говнокод #4694

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    // the next few lines do the fiddling required to make sure the data 
    // looks right, whether it's viewed via the RSS feed or via the database
    $longpost=str_replace("<br />", "\n", $post);
    $shortpost=substr($post,0,600);
    $shortpost=str_replace("<br />", "\n", $shortpost);
    $pass=$_POST["pass"];
    if ($pass == $password) {
    	include "db.inc";
    	// this line actually inserts the data
    	mysql_query("INSERT INTO entries VALUES (NULL, '$title', '$post')");
    	$getid=mysql_query("SELECT id FROM entries WHERE title='$title'");
    	$myrow=mysql_fetch_array($getid);
    	$postid=$myrow["id"];
    	// from here on in, we're building the RSS feed.
    	$arrFp = file("rss/feed.xml");
    	$lines = count($arrFp);
    	$insertat = $lines-2;
    	for ($i=0; $i<$insertat; $i++) {
    		$rsstext=$rsstext.$arrFp[$i];
    	}
    	$rsstext=$rsstext."<item>\n";
    	$rsstext=$rsstext."<title>".stripslashes($title)."</title>\n";
    	$rsstext=$rsstext."<description>".stripslashes($shortpost);
    	if (strlen($shortpost)<strlen($longpost)) {
    		$rsstext=$rsstext."...";
    	}
    	$rsstext=$rsstext."</description>\n";
    	$rsstext=$rsstext."<link>$url/comment.php?post=$postid</link>\n";
    	$rsstext=$rsstext."</item>\n";
    	$rsstext=$rsstext."</channel>\n";
    	$rsstext=$rsstext."</rss>";
    	$fp=fopen("rss/feed.xml", "w");
    	fwrite( $fp, $rsstext );
    	fclose($fp);
    	echo "Post successfully submitted!";
    } else {
    	echo "You are not authorised to post to this server!";
    }

    Создаём RSS-ленту.

    Yurik, 20 Ноября 2010

    Комментарии (10)
  6. PHP / Говнокод #4693

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    if (count ( $tag_array )) {
    
    				$tag_array = "(" . implode ( ",", $tag_array ) . ")";
    
    			} else {
    
    				$tag_array = "('undefined')";
    
    			}
    
    			$db->free ();
    
    			$sql_select = "SELECT id, autor, date, short_story, SUBSTRING(full_story, 1, 15) as full_story, xfields, title, category, alt_name, comm_num, allow_comm, allow_rate, rating, vote_num, news_read, approve, flag, editdate, editor, reason, view_edit, tags FROM " . PREFIX . "_post where {$stop_list} AND approve" . $where_date . " ORDER BY " . $news_sort_by . " " . $news_direction_by . " LIMIT " . $cstart . "," . $config['news_number'];
    			$sql_count = "SELECT COUNT(*) as count FROM " . PREFIX . "_post where {$stop_list} AND approve" . $where_date;
    			$allow_active_news = true;
    
    			$tag_array = array ();
    			unset ( $tag_array );

    Все классно... а что в конце.. убило..

    Aios, 20 Ноября 2010

    Комментарии (98)
  7. PHP / Говнокод #4692

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    if (isset($_GET["url"])) {
    	$nombre_archivo = $_GET["url"];
    	
    	$consulta = "SELECT * FROM descargas_archivos WHERE nombre_archivo LIKE '".$nombre_archivo."' ";
    	$resultado = mysql_query($consulta);
    	
    	if (mysql_num_rows($resultado)>0) {
        	$actualiza = "UPDATE descargas_archivos SET num_descargas = num_descargas + 1 WHERE nombre_archivo LIKE '".$nombre_archivo."' ";
        	mysql_query($actualiza);
    	}
    	else {
    		$inserta_nuevo = "INSERT INTO descargas_archivos (nombre_archivo) VALUES ('".$nombre_archivo."')";
    		mysql_query($inserta_nuevo);
    	}
    	
    }

    Классика.

    Yurik, 19 Ноября 2010

    Комментарии (15)
  8. PHP / Говнокод #4691

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    <?php
    
    include "connect.inc";
    
    if($_POST["save"] == "yes")
    {
    /* все классы */
      for($i = 5; $i <= 11; $i++)
      {
         foreach($dayslt as $day)
         {
           for($lesson_num = 1; $lesson_num <= 6; $lesson_num++)
           {
              $str_lesson .= $_POST["lesson"]["$i"."$letter"][$lesson_num].",";
           }
           if(!mysql_query("UPDATE `schedule` SET `$day`='".$str_lesson."' WHERE `class`='$i'")) die("fuck..");
           $str_lesson = "";
         }
      }
    }
    ?>

    Причина последствий, описанных ранее. Value там не прописано, т.к. в базу почему-то ещё нихуя не пишется, ололо.

    varg242, 19 Ноября 2010

    Комментарии (29)
  9. PHP / Говнокод #4690

    +148

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    for($i = 5; $i <= 11; $i++)
    {
        echo "<tr>\n";
        echo "<td valign=\"top\">\n<b>$i</b>\n</td>\n\n";
        /* для каждого дня */
        foreach($dayslt as $day)
        {
          echo "<td>\n";
          for($lesson_num = 1; $lesson_num <= 6; $lesson_num++)
          {
           echo "<input type=\"text\" name=\"lesson[$i][$day][$lesson_num]\"><br/>\n";
          }
          echo "</td>\n\n";
        }
        echo "</tr>\n\n";
    }

    какая-то хуйня по вводу расписания, хз

    varg242, 19 Ноября 2010

    Комментарии (71)
  10. PHP / Говнокод #4689

    +168

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    <?php
    include "func.php";
    if (not_installed()) {
    	include "install.php";
    	exit();
    }
    include "config.php";
    mysql_connect($dbpt,$dbus,$dbps);
    mysql_select_db($dbdb);
    $title=get_forum_param("title");
    $name=get_forum_param("nm");
    $about=get_forum_param("about");
    echo "<html>
    <head>
    <title>$title</title>
    <meta http-equiv='content-type' content='text/html; charset=utf-8' />
    <link rel='stylesheet' type='text/css' href='style.css' />
    <script language='Javascript' src='js.js'></script>
    <script language='Javascript' src='wn.js'></script>
    </head>
    <body id='addf'>
    <table width='100%' id='top_table'><tr valign='top'><td id='ab_for' width='80%'><p id='header'>$name</p><p id='title'>$about</p></td>
    <td id='us_zn'>";
    $pd=check_cookie();
    if ($pd) {
    	write_last_visit();
    	$login=$_COOKIE['usrn'];
    	$inf=mysql_fetch_assoc(mysql_query("select * from {$dbpr}users where id='$login'"));
    	$lastvisit=$inf['lastvisit'];
    	$login=$inf['login'];
    	echo "Добро пожаловать, $login.<br />Ваш последний визит: $lastvisit<br /><a href='do.php?mode=exit'>Выход</a>";
    } else {
    	echo "<form action='javascript: log_in()'><table><tr><td>Логин:</td><td><input type='text' id='login' /></td></tr><tr><td>Пароль:</td><td><input type='password' id='pass' /></td></tr><tr><td><input type='submit' value='Войти' /><td id='w'></td></tr></table></form>";
    }
    echo "</td></tr>
    </table>";
    echo "<div id='menubar'><ul id='cssmenu'>";
    if (!$pd) {
    	echo "<li><a href='#' onclick='register_w(\"Регистрация\",\"register\")'>Регистрация</a></li>
    <li><a href='#' onclick='register_w(\"Забыли пароль?\",\"remember\")'>Забыли пароль?</a></li>";
    }
    echo "</ul></div><br /><br />
    Здесь будет список форумов
    <hr><div class='wrab'>Powered by Golden Horde<br />Created by <a href='http://vladiator.biz/' target='_blank'>Vladiator</a> and <a href='http://proggear.org/'>ProgGear</a><br>2010</div>
    </body>
    </html>";
    ?>

    qbasic, 19 Ноября 2010

    Комментарии (28)