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

    +141.5

    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
    class cDBEngineWrapper
    	{
    	private $dbprefix;
    	
    	public function __construct($prefix)
    		{
    		$this->dbprefix = $prefix;
    		}
    		
    	public function __call($func, $args)
    		{
    		return call_user_func_array("{$dbprefix}_{$func}", $args);
    		}
    	}

    Вот такая вот оберточка для быстрой смены БД...

    guest, 30 Июня 2009

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

    +135.9

    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
    <HTML>
        <HEAD>
        <title>
        </HEAD>
    <BODY>
    <?php
    include("connect.php");
    /* вводим переменную которая соединяется с бд */
            $db = @mysql_connect ($host, $user, $psw);
    /* выбираем бд с использованием предыдущей */
    /*переменной для соединения с бд*/
            $sdb = @mysql_select_db("zforum", $db);
    /* для наглядности показываем месагу результата выполнения скрипта */
    if(empty($sdb)) {
                    echo "mysql_error()";
            };
    echo($info);
    if($query_string=='go_reg') {$ins_new_usr="insert into users usrnick=$_POST[nick], usrpsw=$_POST[pass], usrmail=$_POST[email], usrabout=$_POST[about]";
    if(isset($_POST['nick']) && isset($_POST['pass']) && isset($_POST['pass2']) && isset($_POST['email']) && $_POST['pass2']=$_POST['pass']) {
     mysql_query($ins_new_usr);
            $info="Account created"; } else {
            $info="Input data error please correct";
          }} else { $info="Please input this form";
     }
    ?>
    <form action="reg.php?go_reg" method=post target="_self">
    <Table border="5">
    <tr><th COLSPAN=2>Registration form</th></tr>
    <tr><td>Nickname</td><td><input type="text" size=26 name="nick" maxlegth="16" size="16" value=""></td></tr>
    <tr><td>Password</td><td><input type="password" name="pass" size=26 maxlength=24 size="16" value=""></td></tr>
    <tr><td>Password again</td><td><input type="password" name="pass2" size=26 maxlength="24" size="16" value=""></td></tr>
    <tr><td>E-mail</td><td><input type="text" name="email" maxlength="50" size=26 value=""></td></tr>
    <tr><td>About</td><td><textarea name="about" maxlength="100" wrap="virtual" rows=4></textarea></tr>
    <tr><th colspan=2><input type="submit" value="enter"></th></tr>
    </table>
    </body>

    guest, 30 Июня 2009

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

    +158.8

    1. 1
    $col=array('red','blue','green','black','yellow','magenta','blue','gray','red','blue','green','black','yellow','blue','gray','red','blue','green','black','yellow','blue','gray');

    А какие ты знаешь цвета?

    guest, 30 Июня 2009

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

    +165

    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
    <?
    
    function q($q){
        return mysql_query($q);
    }
    
    function fa($q){
        return mysql_fetch_array($q);
    }
    
    function nr($q){
        return mysql_num_rows($q);
    }
    
    function gr($t,$f,$w,$wf,$def){
        $r = ($a = mysql_fetch_array(mysql_query("SELECT $f FROM $t WHERE $wf = '$w' LIMIT 1"))) ? $a[$f] : $def ;
        return $r;
    }
    
    ?>

    лень творит чудеса

    guest, 30 Июня 2009

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

    +155.9

    1. 1
    substr($row[3],8,2)."-".substr($row[3],5,2)."-".substr($row[3],0,4)

    Тот же кодер писал что и 1246 и 1281. С одного скрипта выкладываю все :)
    тут выводится дата в формате d-m-Y

    guest, 30 Июня 2009

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $to = date("m.d.Y");
    $to=explode('.',$to);
    $k = $to[0];
    $to[0]=$to[1];
    $to[1]=$k;
    $to = array_reverse($to);
    $to = implode('-', $to);

    делаем дату в формате sql

    guest, 30 Июня 2009

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

    +146.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    /**
         * @see Connection::applyLimit()
         */
        public function applyLimit(&$sql, $offset, $limit)
        {
            if ( $limit > 0 ) {
                $sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit;
            } else if ( $offset > 0 ) {
                $sql .= " LIMIT " . $offset . ", 18446744073709551615";
            }
        }

    Propel Connection - жёсткий хардкод (если лимит не указан, выбираем записи от $offset до произвольно большого числа)

    guest, 30 Июня 2009

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

    +144

    1. 1
    2. 2
    3. 3
    // функция для возвращения всякой хрени
    function hren($table, $id)
    {

    guest, 29 Июня 2009

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

    +196.4

    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
    <?$all_p= array('<a href=catalog.php?page=1&filtr=>1</a>',
    				'<a href=catalog.php?page=2&filtr=>2</a>',
    				'<a href=catalog.php?page=3&filtr=>3</a>',
    				'<a href=catalog.php?page=4&filtr=>4</a>',
    				'<a href=catalog.php?page=5&filtr=>5</a>',
    				'<a href=catalog.php?page=6&filtr=>6</a>',
    	...
    				'<a href=catalog.php?page=267&filtr=>267</a>',
    				'<a href=catalog.php?page=268&filtr=>268</a>',
    				'<a href=catalog.php?page=269&filtr=>269</a>',
    				'<a href=catalog.php?page=270&filtr=>270</a>',
    				'<a href=catalog.php?page=271&filtr=>271</a>',
    				'<a href=catalog.php?page=272&filtr=>272</a>',
    				'<a href=catalog.php?page=273&filtr=>273</a>',
    				'<a href=catalog.php?page=274&filtr=>274</a>',
    				'<a href=catalog.php?page=275&filtr=>275</a>',
    				'<a href=catalog.php?page=276&filtr=>276</a>',
    				'<a href=catalog.php?page=277&filtr=>277</a>',
    				'<a href=catalog.php?page=278&filtr=>278</a>',
    				'<a href=catalog.php?page=279&filtr=>279</a>'
    	);?>

    без комментариев

    guest, 29 Июня 2009

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

    +142.3

    1. 1
    "x_address"			=> $postData['address1']. trim( ' ' . $postData['address2']),

    гениально =)

    guest, 29 Июня 2009

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