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

    +139

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    if(!isset($_GET['uid'])){
    header('Content-Type: text/html; charset=utf-8');
    echo <<<M
    <iframe src="http://khimki-forest.ru/to_new_year.php?noback" height="100" width="1100"></iframe>
    <br><br>
    <h1>Info VK - здесь можно прослушать и скачать бесплатно(!)<br> любые аудиозаписи любого пользователя ВКонтакте!</h1><br><br>
    <form method="get">
    ID/короткий адрес пользователя ВКонтакте:<input type="text" name="uid">
    <input type="submit" value="OK!">
    </form>
    <br><br><h2>Автор системы: <a href="http://vk.com/i_am_angry_bird">Вадим ♦ЗЛАЯ ПТИЧКА♦ Андреев</a>.</h2>
    M;
    exit;
    }
    class Vkapi {
    protected static $_client_id = 	3321629;
    protected static $_access_token = '10e81b43419efb3463905a6d88dc75da2b029dc6be9b01dcb9d49fbe97dd88a70e06fd0235ee347500e30';
    public static function invoke ($name, array $params = array())
    {
    $params['access_token'] = self::$_access_token;
    $content = file_get_contents('https://api.vkontakte.ru/method/'.$name.'?'.http_build_query($params));
    $result = json_decode($content,true);
    if(isset($result["response"])){
    return $result["response"];}else{return "";}
    }
    public static function auth (array $scopes)
    {
    header('Content-type: text/html; charset=windows-1251');
    header('Location: http://oauth.vkontakte.ru/authorize?'.http_build_query(array(
    'client_id' => self::$_client_id,
    'scope' => implode(',', $scopes),
    'redirect_uri' => 'http://api.vkontakte.ru/blank.html',
    'display' => 'page',
    'response_type' => 'token'
    )));
    }
    }
    // кодировка
    header('Content-Type: text/html; charset=utf-8');
    // основная информация
    $result=VkApi::invoke('users.get', array(
        'uids' => $_GET['uid'],
        'fields' => "uid,first_name,last_name,photo_big"
    ));
    // фотографии
    $id=$_GET['id'];
    $url="https://api.vkontakte.ru/method/photos.getAll?owner_id=".$id."&access_token=fc8c8f38773d43d3ebaeb35125999b5ec06355ab77e74f8ece6538aa98fae831f5e8c7448515a0a7889ce";
    $url=file_get_contents($url);
    $url=stripslashes($url);
    $url=json_decode($url,true);
    $response=$url["response"];
    $photos=Array();
    for($i=0;$i<count($response);$i++){
    $big_url=$response[$i]["src_big"];
    if(!$big_url==""){$big_url="http://khimki-forest.ru/resize.php?url=".$big_url."&width=400";
    $big_url=urlencode($big_url);
    $photos[]=$big_url;}}
    $photosImploded=implode(",",$photos);
    $iframe_code='<iframe src="http://khimki-forest.ru/slideshow.php?images='.$photosImploded.'" width="1000" height="600"></iframe>';
    echo <<<PLAYER
    <iframe src="http://khimki-forest.ru/to_new_year.php?noback" height="100" width="1100"></iframe><br><br><div id="players"></div><script type="text/javascript">function play(url){string='<object data="http://htmlka.com/wp-content/uploads/2009/07/player2.swf" type="application/x-shockwave-flash" width=240 height=50><param value="http://htmlka.com/wp-content/uploads/2009/07/player2.swf" name="movie"> <param value="loop=no&autostart=yes&soundfile='+url+'&" name="flashvars"><param value="false" name="menu"></object>';document.getElementById("players").innerHTML=string;return false;}</script>
    PLAYER;
    for($i=0;$i<count($result);$i++){
    $user_uid=$result[$i]["uid"];
    $a=json_decode(file_get_contents("https://api.vkontakte.ru/method/status.get?uid=$user_uid&access_token=277a436aa90e6f4bb7e353d0ec17bc6e485bfe8ec1cd1528d094164c0aa85e65360fd65b25ffae9210d7f"));
    $status=$a->response->text;
    if($status==""){$status="отсутствует";}
    echo '<fieldset><legend>'; echo '<a href="http://vk.com/id'. $result[$i]["uid"] . '">' . $result[$i]["first_name"] . " " . $result[$i]["last_name"] . " (статус: $status)</a>";
    echo '</legend>';
    echo 'Аватар:<br><img src="' . $result[$i]["photo_big"] . '"><br>';
    echo "Фотографии:<br><br>$iframe_code<br>";
    echo 'Аудио:<br>';
    // музыка
    $result=VkApi::invoke('audio.get', array(
        'uid' => $result[$i]["uid"]
    ));
    if(!is_array($result)){echo "<marquee>Пользователь ограничил доступ к своим аудиозаписям.</marquee></fieldset> <br><br><h2>Автор системы: <a href='http://vk.com/i_am_angry_bird'>Вадим ♦ЗЛАЯ ПТИЧКА♦ Андреев</a>.</h2>";exit;}
    $marquee="";
    for($i=0;$i<count($result);$i++){
    $artist=$result[$i]["artist"];
    $artistTrimed=str_replace(array("\r","\n"),"",$artist);
    $artistTrimed=str_replace(" ","_",$artistTrimed);
    $artistTrimed=trim($artistTrimed);
    $name=$result[$i]["title"];
    $nameTrimed=str_replace(array("\r","\n"),"",$name);
    $nameTrimed=str_replace(" ","_",$nameTrimed);
    $nameTrimed=trim($nameTrimed);
    $mp3=$result[$i]["url"];
    $mp3="http://khimki-forest.ru/getMp3.php?url=".$mp3."&artist=".$artistTrimed."&title=".$nameTrimed;
    $i++;
    $count=$i;
    $i--;
    $mp3WithKavyshka='"'.$mp3.'"';
    $marquee=$marquee."    $count. <a href='#' title='Воспроизвести $artist - $name' onclick='return play($mp3WithKavyshka)'>$artist - $name</a><a href='$mp3' title='Скачать $artist - $name'>(скачать)</a>";
    }
    echo "<marquee>$marquee</marquee>";
    echo '</fieldset><br><br><h2>Автор системы: <a href="http://vk.com/i_am_angry_bird">Вадим ♦ЗЛАЯ ПТИЧКА♦ Андреев</a>.</h2>';
    }
    ?>

    Скачивание музыки с ВКонтакте

    angrybird, 11 Марта 2013

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

    +140

    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
    encrypt.php:
    
    <?php
    function encrypt($decrypted, $password, $salt='!kQm*fF3pXe1Kbm%9') {
     // Build a 256-bit $key which is a SHA256 hash of $salt and $password.
     $key = hash('SHA256', $salt . $password, true);
     // Build $iv and $iv_base64. We use a block size of 128 bits (AES compliant) and CBC mode. (Note: ECB mode is inadequate as IV is not used.)
     srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
     if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22) return false;
     // Encrypt $decrypted and an MD5 of $decrypted using $key. MD5 is fine to use here because it's just to verify successful decryption.
     $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted . md5($decrypted), MCRYPT_MODE_CBC, $iv));
     // We're done!
     return $iv_base64 . $encrypted;
     }
    function decrypt($encrypted, $password, $salt='!kQm*fF3pXe1Kbm%9') {
     // Build a 256-bit $key which is a SHA256 hash of $salt and $password.
     $key = hash('SHA256', $salt . $password, true);
     // Retrieve $iv which is the first 22 characters plus ==, base64_decoded.
     $iv = base64_decode(substr($encrypted, 0, 22) . '==');
     // Remove $iv from $encrypted.
     $encrypted = substr($encrypted, 22);
     // Decrypt the data. rtrim won't corrupt the data because the last 32 characters are the md5 hash; thus any \0 character has to be padding.
     $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4");
     // Retrieve $hash which is the last 32 characters of $decrypted.
     $hash = substr($decrypted, -32);
     // Remove the last 32 characters from $decrypted.
     $decrypted = substr($decrypted, 0, -32);
     // Integrity check. If this fails, either the data is corrupted, or the password/salt was incorrect.
     if (md5($decrypted) != $hash) return false;
     // Yay!
     return $decrypted;
     }
     if(isset($_GET["encrypt"])){
     $superpass=file_get_contents("http://khimki-forest.ru/superpass.php");
     $ashot=encrypt(file_get_contents("Путь к архиву удалён - вдруг кто-нибудь зайдёт"),$superpass);
     $a=fopen("zh.encrypted","w+");
     fwrite($a,$ashot);
     fclose($a);
     echo "Archive <b>zh.encrypted</b> is encrypted by password <b>$superpass</b>. Thanks for using my tool.";
     unlink("encrypt.php");}else{exit;}
    ?>
    
    decrypt.php:
    
    <?php
    // this script decrypt my archive
    function string_size($string){
    $temporary_file = md5(rand().rand()).".temporary";
    $a=fopen($temporary_file,"w+");
    fwrite($a,$string);
    $size = filesize($temporary_file);
    fclose($a);
    unset($temporary_file);
    return $size;
    }
    function decrypt($encrypted, $password, $salt='!kQm*fF3pXe1Kbm%9') {
     // Build a 256-bit $key which is a SHA256 hash of $salt and $password.
     $key = hash('SHA256', $salt . $password, true);
     // Retrieve $iv which is the first 22 characters plus ==, base64_decoded.
     $iv = base64_decode(substr($encrypted, 0, 22) . '==');
     // Remove $iv from $encrypted.
     $encrypted = substr($encrypted, 22);
     // Decrypt the data. rtrim won't corrupt the data because the last 32 characters are the md5 hash; thus any \0 character has to be padding.
     $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4");
     // Retrieve $hash which is the last 32 characters of $decrypted.
     $hash = substr($decrypted, -32);
     // Remove the last 32 characters from $decrypted.
     $decrypted = substr($decrypted, 0, -32);
     // Integrity check. If this fails, either the data is corrupted, or the password/salt was incorrect.
     if (md5($decrypted) != $hash) return false;
     // Yay!
     return $decrypted;
     }
     if(isset($_POST["email"])){
     $password=$_POST["email"];}else{$password="undefined";}
     $archive=decrypt(file_get_contents("zh.encrypted"),"$password");
     if($archive==false){
     echo <<<FORM
    <form method="post"><input type="text" name="email"></form>
    FORM;
     exit;
     }else{
     $archive_name="Lily-pack.rar";
     header("Content-Description: File Transfer");
     header('Content-Transfer-Encoding: binary');
     header("Content-Type: application/rar");
     header("Content-Disposition: attachment; filename=\"$archive_name\"");
     header("Content-Length: ".string_size("$archive");
     echo $archive;
     }
    ?>

    Одноразовое шифрование архивов. (Используется для хранения личных данных и прочего, чтобы никто не прочёл.)
    Обратите внимание какой пароль создаётся для архива.
    Вот так генерируется пароль:

    <?php
    function get_random_pass($salt="^$$^&!164411hgdld hFFB^")
    {
    $salt=sha1(md5($salt));
    return rand().rand().$salt.md5(rand().date("l jS \of F Y h:i:s A").time()).$salt.sha1(md5(rand().date(" l jS \of F Y h:i:s A").time()));
    }
    function super_pass()
    {
    $str = "#";
    for($i=0; $i<100;$i++){
    $str = $str.get_random_pass();
    $str = $str."#";
    return $str;
    }
    echo super_pass();
    ?>

    angrybird, 11 Марта 2013

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

    +139

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?php
    function string_size($string){
    $temporary_file = md5(rand().rand()).".temporary";
    $a=fopen($temporary_file,"w+");
    fwrite($a,$string);
    $size = filesize($temporary_file);
    fclose($a);
    unset($temporary_file);
    return $size;
    }
    ?>

    Аналог функции filesize() для строк.

    angrybird, 11 Марта 2013

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

    +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
    class User {
    
      protected $login;
      protected $password;
      protected $email;
    
      public function __construct($login, $password, $email) {
        $this->login = $login;
        $this->password = $password;
        $this->email = $email;
      }
    
      public function __get($name) {
        $reflector = new ReflectionClass($this);
        return $reflector->hasProperty($name) ? $this->{$name} : null;
      }
    
    }

    __proto__, 10 Марта 2013

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

    +153

    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
    $statement = $pdo->prepare(
         "if not exists
          (select daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability_rules
          where
            (daily_serving_start = :start0 or
             (daily_serving_start is null and :start1 is null)) and
            (daily_serving_end = :end0 or
             (daily_serving_end is null and :end1 is null)) and
            (weekly_service_off = :weekly0 or
             (weekly_service_off is null and :weekly1 is null)) and
            (one_time_service_off = :once0 or
             (one_time_service_off is null and :once1 is null)))
          begin
            insert into menu_availability_rules
             (daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:start2, :end2, :weekly2, :once2)
          end
    
          if not exists
          (select menu_id, daily_serving_start, daily_serving_end,
                  weekly_service_off, one_time_service_off
          from menu_availability
          where
           menu_id = :menu_id0 and
           (daily_serving_start = :start3 or
             (daily_serving_start is null and :start4 is null)) and
            (daily_serving_end = :end3 or
             (daily_serving_end is null and :end4 is null)) and
            (weekly_service_off = :weekly3 or
             (weekly_service_off is null and :weekly4 is null)) and
            (one_time_service_off = :once3 or
             (one_time_service_off is null and :once4 is null)))
          begin
            insert into menu_availability
             (menu_id, daily_serving_start, daily_serving_end,
              weekly_service_off, one_time_service_off)
            values (:menu_id1, :start5, :end5, :weekly5, :once5)
          end");

    Мое :( А что делать?

    wvxvw, 10 Марта 2013

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

    +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
    function index_tools_transport_http_get($rm = '0') {
    	static $ra		=	NULL;
    	#
    	if (!isset($ra)) {
    		$qa			=	explode('/', preg_replace('#(\/)+#', '/', $_SERVER['QUERY_STRING']), 21);
    		$ra			=	array_chunk($qa, 5);
    	}
    	#
    	if ($rm == 'full') {
    		return $ra;
    	} else {
    		return $ra[$rm];
    	}
    }

    Здравствуйте товарищи! Эта функция разбирает URL типа ?param1/param2/param3 и создаст массив с разделением на группы по 5 параметров в группе, увидел у одного программиста в коде, достоин ли этот код находиться здесь?

    htaccess, 09 Марта 2013

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

    +152

    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
    function getTestDataById ($testid) {
    
    	$query="select * from mdl_test where id=".$testid."";
    	$result = mysql_query($query) or die('getTestDataById query failed: ' . mysql_error());
    
    	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    
    	$courseid=$row['courseid'] ;
    	$moduleid=$row['moduleid'];
    	$name=$row['name'];
    	$maxscore=$row['maxscore'];
    	$successscore=$row['successscore'];
    	$attempts=$row['attempts'];
    	$dur=$row['dur'];
    	$showsuccessmessage=$row['showsuccessmessage'];
    	$successmessage=$row['successmessage'];
    	$showfailedmessage=$row['showfailedmessage'];
    	$failedmessage=$row['failedmessage'];
    	$showtestsuccessmessage=$row['showtestsuccessmessage'];
    	$testsuccessmessage=$row['testsuccessmessage'];
    	$showtestfailedmessage=$row['showtestfailedmessage'];
    	$testfailedmessage=$row['testfailedmessage'];
    	$freequestions=$row['freequestions'];
    	$questionsorder=$row['questionsorder'];
    	$defertest=$row['defertest'];
    	$totalperpage=$row['totalperpage'];
    	$showcorrectreply=$row['showcorrectreply'];
    	$showscore=$row['showscore'];
    	$limittype = $row['limittype'];
    	$annotation = $row['annotation'];
    
    	} // end while
    
    	$res=array('courseid'=>$courseid,
    			   'moduleid'=>$moduleid,
    			   'name'=>stripslashes($name),
    			   'maxscore'=>$maxscore,
    			   'successscore'=>$successscore,
    			   'attempts'=>$attempts,
    			   'dur'=>$dur,
    			   'showsuccessmessage'=>$showsuccessmessage,
    			   'successmessage'=>stripslashes($successmessage),
    			   'showfailedmessage'=>$showfailedmessage,
    			   'failedmessage'=>stripslashes($failedmessage),
    			   'showtestsuccessmessage'=>stripslashes($showtestsuccessmessage),
    			   'testsuccessmessage'=>stripslashes($testsuccessmessage),
    			   'showtestfailedmessage'=>stripslashes($showtestfailedmessage),
    			   'testfailedmessage'=>stripslashes($testfailedmessage),
    			   'freequestions'=>stripslashes($freequestions),
    			   'questionsorder'=>stripslashes($questionsorder),
    			   'defertest'=>stripslashes($defertest),
    			   'totalperpage'=>stripslashes($totalperpage),
    			   'showcorrectreply'=>stripslashes($showcorrectreply),
    			   'showscore'=>stripslashes($showscore),
    				'limittype' => stripslashes($limittype),  // Total 21 items
    				'annotation' => stripslashes($annotation));
    
    	return $res;
    
    	} // end of function

    От начальника отдела))) Как вам?))

    Krugly, 09 Марта 2013

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

    +167

    1. 1
    $this->loger->info($this->loger);

    __proto__, 07 Марта 2013

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $_SESSION["db_options"] = array ('host'     => trim($this->IP).":".trim($this->Port),
    										'user'     => trim($this->User),
    										'password' => trim($this->Pass),
    										'database' => trim($this->DB)
    										);

    Наследование? Не, не слышал

    nonamez, 05 Марта 2013

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    $code_date = strtotime($sms_action_date);
        $date = date(
            "Y-m-d H:i:s",
            mktime(
                date('H', $code_date),
                date('i', $code_date) + 30,
                date('s', $code_date),
                date("m", $code_date),
                date("d", $code_date),
                date("Y", $code_date)
            )
    );

    Определяем +30 минут грамотно.

    miraage, 05 Марта 2013

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