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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    //в посте кроме этих ключей больше быть ничего не может
    if ($_POST['x'])unlink('/x.png');
    if ($_POST['y'])unlink('/y.png');
    if ($_POST['z'])unlink('/z.png');
    if ($_POST['a'])unlink('/a.png');
    if ($_POST['b'])unlink('/b.png');
    //etc
    ?>

    Ну не знал я, что можно было сделать так:
    <?php
    foreach ($_POST as $key => $value)
    {
    unlink('/'.$key.'.png');
    }
    ?>

    QarezZ, 01 Октября 2011

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

    +166

    1. 1
    2. 2
    3. 3
    <?php
    $q=mysql_num_rows(mysql_query("SELECT * FROM `users`"));
    >

    Печально, но так поступают 85% кодеров..

    QarezZ, 01 Октября 2011

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

    +157

    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
    /**
     * Experiments...
     */
    class poltergeist {
    
    	private $className;
    	private $methods;
    
    	function  __construct() {
    
    		$this->className=array(
    			'page',
    			'source',
    			'user',
    			// etc
    		);
    
    		foreach ($this->className as $v) {
    
    			$this->$v = new $v();
    			$this->methods[$v] = get_class_methods($v);
    		}
    	}
    
    	function __call($name, $arg){
    
    		if ( ($k=$this->arraySearch( $name )) ) {
    
    				return $this->$k->$name($arg);
    		}
    	}
    
    	function arraySearch( $name ){
    
    		foreach ( $this->methods as $k=>$v ) {
    			if ( in_array( $name, $v) ) return $k;
    		}
    	return false;
    	}
    }

    Откопал вот...

    istem, 01 Октября 2011

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

    +148

    1. 1
    if(!(pid)&&($pid!==false))

    третье - дано!

    Lure Of Chaos, 01 Октября 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    $x=$_GET['x'];
    $y=intval($x);
    $z=round($y);
    $a=max(0, $z);
    ?>

    Ну не знал я о совмещении функций, и не знал, что точно делает каждая из них :D

    QarezZ, 01 Октября 2011

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

    +147

    1. 1
    2. 2
    die();
                return false;

    jokz, 01 Октября 2011

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

    +162

    1. 1
    if(!empty($arResult["Post"])>0)

    Как вы думаете, что это? Правильно, Битрикс!

    maxru, 30 Сентября 2011

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

    +30

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $files = file_scan_directory(dirname(__FILE__) .'/modes/', '^([^\.].*)\.inc$', array('.', '..', 'CVS'), 0, FALSE);
        foreach ($files as $file) {
          require_once($file->filename);
          $mode = $file->name;
          if (function_exists('advpoll_info_'. $mode)) {
            $advpoll_modes[$mode] = call_user_func('advpoll_info_'. $mode);
          }
        }

    brainstorm, 30 Сентября 2011

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

    +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
    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
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    <?php
    function bkconnect($login=FALSE,$update=FALSE){
    	function get_bk_inf($content){
    		if (strlen($content) > 0){
                        preg_match("#align=(.*)#i", $content, $returnarray['align']);
                        preg_match("#gamecity=(.*)#i", $content, $returnarray['gamecity']);
                        preg_match("#room_name=(.*)#i", $content, $returnarray['room_name']);
                        preg_match("#gamecity_url=(.*)#i", $content, $returnarray['gamecity_url']);
                        preg_match("#level=(.*)#i", $content, $returnarray['level']);
                        preg_match("#klan=(.*)#i", $content, $returnarray['klan']);
                        preg_match("#login_online=(.*)#i", $content, $returnarray['login_online']);
                        foreach($returnarray as $array_name => $array_data){
                                $returnarray[$array_name] = $returnarray[$array_name][1];
                                        }
                        }
                        return $returnarray;
                        }
    	function bklogin($login){
    		$tmp=rawurlencode(trim(strip_tags($login)));
    		$url="http://sandcity.combats.com/inf.pl?login=".$tmp."&short=1";
    		$response=get_headers($url,1);
    		if (strpos($response[0],'302'))
    		{$url=str_replace(" ","%20",$login);
    		 return file_get_contents($url);}
    		elseif (strpos($response[0],'200'))
    		{return file_get_contents($url);}
    		else {return"";}
    		return file_get_contents($url);
    		}
    	if($update==TRUE){
    		$myrow = mysql_query("select id,bk_login FROM black_list");
    		if(mysql_num_rows($myrow)){
    			while($result = mysql_fetch_array($myrow)){
    				$contents = bklogin($login);
    				$info = get_bk_inf($contents);
    				if(is_array($info)){
    				$sql="UPDATE `newblacklist` SET
                                                                align ='".$info['align']."',
                                                                gamecity ='".$info['gamecity']."',
                                                                room_name='".$info['room_name']."',
                                                                gamecity_url='".$info['gamecity_url']."',
                                                                level='".$info['level']."',
                                                                klan='".$info['klan']."',
                                                                login_online='".$info['login_online']."'
                                                                WHERE `id`='".$result['id']."'";
    				$myrow2 = mysql_query($sql);
    				}else{echo'error';}
    				}
    			}else{return;}
    		}else{
    			$contents = bklogin($login);
    			$info = get_bk_inf($contents);
    			if(is_array($info)){
    				return $info;}else{
    					return 'Чтото не так';}
    			}
    	}
    function liginviev($inf){
    function align($align){if($align>0){return '<img src="http://img.combats.com/i/align'.$align.'.gif" border="0px">';}else{return '&nbsp';}}
    function klan($klan){if(strlen($klan)>0){
    	return "<a href='http://capitalcity.combats.com/clans_inf.pl?".$klan."' target='_blank'>
    	<img src='http://img.combats.com/i/klan/".$klan.".gif' title='".$klan."'></a>";}else{
    		return '&nbsp';}}
    function room($rooms){if(strlen($rooms)>0){return $rooms;}else{return' ';}}
    function online($online){
    	if($online==1){return'<img src="/i/user_online.gif" />';}else{return'<img src="/i/user_offline.gif" />';}
    	return $on;}
    	}
    function Logs($id){
    $myrow = mysql_query("SELECT * FROM newblacklistlogs WHERE blackId='".$id."'");
    $crow['loc'] = mysql_num_rows($myrow);
    if($crow['loc']>0){
    	while($result = mysql_fetch_array($myrow)){
    		$crow['logs'] .='<a href="'.$result['file'].'" target="_blank"><img src="/i/fighttype6.gif" /></a>';
    		}
    		return $crow=array('col'=>$crow['loc'],'logs'=>$crow['logs']);
    	}else{return $crow=array('col'=>$crow['loc'],'logs'=>' ');}
    	}
    ?>

    Один ЧС для клан сайта игры combats.ru

    lans8097, 30 Сентября 2011

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

    +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
    22. 22
    23. 23
    <?php
    function curl($url='', $post='') {
    	$cl = curl_init();
    	curl_setopt($cl, CURLOPT_URL, $url);
    	curl_setopt($cl, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($cl, CURLOPT_HEADER, 1);
    	curl_setopt($cl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1) Gecko/20090624 Firefox/3.5');
    	curl_setopt($cl, CURLOPT_COOKIEJAR, 'cookie.txt');
    	curl_setopt($cl, CURLOPT_COOKIEFILE, 'cookie.txt');
    	if(!empty($post)) {
    		curl_setopt($cl, CURLOPT_POST, 1); 
    		curl_setopt($cl, CURLOPT_POSTFIELDS, $post);
    	} else curl_setopt($cl, CURLOPT_POST, 0);
    	$ex = curl_exec($cl);
    	curl_close($cl);
    	return $ex;
    }
    $wall_id = 'wallxxx_xxx';
    $hash = 'a2069bb43c20769e9';
    
    curl('http://vkontakte.ru/login.php?act=login&q=&[email protected]&pass=xxx&captcha_sid=&captcha_key=');
    echo curl('http://vkontakte.ru/like.php', "act=a_do_like&object={$wall_id}&hash={$hash}&wall=1");
    ?>

    Ребят, сервер отдаёт: HTTP/1.1 302 Found Server: nginx/0.7.59 Date: Thu, 29 Sep 2011 18:42:58 GMT Content-Type: text/html; charset=windows-1251 ..., но почему то "лайк" не ставит.
    В чём может быть проблема?

    substr, 29 Сентября 2011

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