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

    +160

    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
    /*
    ...
    */
    
    /* Add some salt */
    $sold = $settings['users']['password_salt'];
    $password = $sold.$password;
    
    /* 1. MD5 */
    $password = md5($password);
    		
    /* 2. SHA1 */
    $password = sha1($password);
    		
    /* 4. Base64 */
    $password = base64_encode($password);
    		
    /* 5. Fatality! */
    $password = sha1($password);
    
    /* Well done! */
    return $password;

    Мощно

    qman, 10 Января 2011

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

    +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
    <?php
    class pvalidator extends validator {	
    	public function fname($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
    	}
    	
    	public function lname($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
    	}
    	
    	public function tname($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё]{3,16}$/iu", $value);
    	}
    	
    	public function nickname($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё \-]{3,32}$/iu", $value);
    	}
    	
    	public function country($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё \-]{2,32}$/iu", $value);
    	}
    	
    	public function sity($value) {
    		return (bool) preg_match("/^[А-Яа-яЁё \-]{2,16}$/iu", $value);
    	}
    	
    	public function school($value) {
    		return (bool) preg_match("/^[№А-Яа-яЁё 0-9\-]{2,16}$/iu", $value);
    	}
    	
    	public function hresponse($value) {
    		return (bool) preg_match("/^.{0,32}$/iu", $value);
    	}
    	
    	public function activity($value) {
    		return (bool) preg_match("/^.{0,32}$/iu", $value);
    	}
    	
    	public function interest($value) {
    		return (bool) preg_match("/^.{0,32}$/iu", $value);
    	}
    }
    ?>

    Моё свежее, с утра высранное!

    Devzirom, 10 Января 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $i=0;
    foreach($info['members'] as $m_name){
    	$i++;
    		$date = date($fdate,$m_name['time']);
    	 $block_vars['num_online'].='<a href="index.php?name=user&op=userinfo&user='.$m_name['u_id'].'">' .$m_name['u_name'].'</a>, ';
    	  if($mcount>0) 
    	 if($i>$mcount) break;
    	}

    Мартин, 09 Января 2011

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

    +161

    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
    <?php
    ...
    	public function update() {
    		if($this->data['id'])
    			return false;
    		
    		$values = array();
    		
    		foreach($this->data AS $key => $value) {
    			if($key == 'id')
    				continue;
    			
    			$values[] = "`{$key}` = " . ($value ? "'{$value}'" : "NULL");
    		}
    		
    		$result = $this->sql->query("
    			UPDATE `users`
    			SET (".implode(', ' $values).")
    			WHERE `id` = '{$this->data['id']}'");
    		
    		return (bool) $this->sql->affected_rows;
    	}
    ...
    ?>

    Моё

    Devzirom, 09 Января 2011

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

    +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
    $query = mysql_query("SELECT * FROM `accounts` WHERE `login` = '".@$_COOKIE['sc2tACC']."' LIMIT 1");
    if ($query and @isset($_COOKIE['sc2tACC']) AND mysql_num_rows($query)) {
    	$auth = mysql_fetch_array($query);
    	if($auth['password'] == $_COOKIE['sc2tPASS'] and @isset($_COOKIE['sc2tPASS'])) {
    		$AS = "OK";
    		if($_SERVER['PHP_SELF'] != "/chat.php" and $auth['status'] != 1) {
    			mysql_query("UPDATE `accounts` SET `timestamp` = '".microtime(1)."', `ip` = '".$_SERVER['REMOTE_ADDR']."', `lastpage` = '".$_SERVER['REQUEST_URI']."'  WHERE `id` = '".$auth['id']."' LIMIT 1;");
    		}
    	} else {
    		$loginError = "Неверный пароль";
    	}
    } else {
    	$loginError = "Неверный логин";
    }

    ne0n, 09 Января 2011

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

    +164

    1. 1
    2. 2
    3. 3
    function isUTF8 ($str) {
        return $utf8 = (preg_match("/^([\x09\x0A\x0D\x20-\x7E]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})*$/", $str)) ? true : false;
    }

    говно или нет?

    stasoft, 08 Января 2011

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

    +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
    <?php
    
    $res=mysql_query('SELECT hosts FROM site_stats LIMIT 200');
    
    while($row = mysql_fetch_row($res)) {
    $a = array (
    $row[0]
    );
    }
    
    foreach ($a as $v) {
    print "$v. ";
    }
    ?>

    http://www.php.ru/forum/viewtopic.php?t=29941 (если не удалят)

    Devzirom, 08 Января 2011

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

    +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
    <?php
    class VIEW_View
    {
    	private $_path;
    	private $_template;
    	private $_var = array();
    
    	public function __construct($path = '')
    	{
    		$this->_path = $_SERVER['DOCUMENT_ROOT'] . $path;
    	}
    
    	public function set($name, $value)
    	{
    		$this->_var[$name] = $value;
    	}
    
    	public function __get($name)
    	{
    		if (isset($this->_var[$name])) return $this->_var[$name];
    		return '';
    	}
    
    	public function display($template, $strip = true)
    	{
    		$this->_template = $this->_path . $template;
    		if (!file_exists($this->_template)) die('Шаблона ' . $this->_template . ' не существует!');
    
    		ob_start();
    		include($this->_template);
    		echo ($strip) ? $this->_strip(ob_get_clean()) : ob_get_clean();
    	}
    
    	private function _strip($data)
    	{
    		$lit = array("\\t", "\\n", "\\n\\r", "\\r\\n", "  ");
    		$sp = array('', '', '', '', '');
    		return str_replace($lit, $sp, $data);
    	}
    
    	public function xss($data)
    	{
    		if (is_array($data)) {
    			$escaped = array();
    			foreach ($data as $key => $value) {
    				$escaped[$key] = $this->xss($value);
    			}
    			return $escaped;
    		}
    		return htmlspecialchars($data, ENT_QUOTES);
    	}
    }
    ?>

    Тема: "foreach в шаблонизаторе." http://www.php.ru/forum/viewtopic.php?t=29937

    Заголовок в блоге: "Меня зовут — Анатолий Ларин - Архив блога - Прощай Smarty или простой шаблонизатор"
    http://larin.in/archives/16

    Devzirom, 08 Января 2011

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

    +161

    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
    class my_anekdots
    {
        private $url="http://anekdots.ru/roulette.pl?catid=";
        private $type=2;
        private $output;
        private $content;
        public function getRandAnekdots()
        {
            $this->content = file_get_contents($this->url.$this->type);
            $this->parseAnekdots()->_display();
            
        }
        private function parseAnekdots()
        {
            preg_match('|<font face=Tahoma size=2 style="font-size: 11px;"><p align=justify>(.*?)</p></font>|is',$this->content,$matches);
            $this->output = $matches[1];
            $this->output = str_replace('\n','<br />',$this->output);
            return $this;
            
        }
        public function _display()
        {
            echo "<span style='padding:5px;'>".$this->output."</span>";
        }
    }
    $my_anekdots = new my_anekdots;
    $my_anekdots->getRandAnekdots();

    O_op

    DanxilLs, 08 Января 2011

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

    +34

    1. 1
    2. 2
    foreach($keys as $key) 
         $settings[$type][$fieldname][$key] =  (isset($fl[$type] [$fieldname] ['widget'] [$key] ) ) ? $fl[$type] [$fieldname] ['widget'] [$key] : '';

    вобля

    brainstorm, 08 Января 2011

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