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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    class BHStorage extends BHProto {
      private static $instance;
      public static function _() {
        if(isset(self::$instance)) return self::$instance;
        self::$instance = new self();
        return self::$instance;
      }
      private $db;
      private function __construct() {
        global $DB;
        $this->db = $DB;
      }

    Недосинглтон. Скажите уже кто нибудь адептам битрикса, что на дворе уже 2016 год.
    https://github.com/dbfun/bitrix-heretic/blob/master/lib/BHStorage.php

    Keeper, 05 Мая 2016

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

    −4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // установлен ли модуль?
      public static function isInstall($module) {
        $data = COption::GetOptionString('main', 'heretic/'.$module, 'N');
        return $data == 'Y';
      }

    И снова гитхаб радует битрикс шлаком. В этот раз, нас радует репозиторий с говорящим описание "Битрикс Еретик" https://github.com/dbfun/bitrix-heretic/blob/master/lib/BHProto.php
    А установлен ли модуль? Таки да. Всегда- да!

    Keeper, 05 Мая 2016

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

    +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
    if(!strpos($amount,'.')) {
        $amount = $amount . '.00';
    } else {
    	$strlength = strlen(explode('.',$amount)[1]);
    	if($strlength != 2) {
    		if($strlength == 1) {
    			$amount = $amount . '0';
    		}
    		if($strlength > 2) {
    			$amount = round($amount,2);
    		}
    	}
    }

    Получение дробного до сотых числа

    ykpon, 05 Мая 2016

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

    −1

    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
    /**
     * Provides URL shortening functionality, like tinyurl.com, bit.ly, ow.ly and other popular services.
     * (c) 2011, it-in, http://it-in.ru
     * @author Sergey Kovalev <[email protected]>
     * @version 1.0
     */
    /**
    * Basic URL path, to which short code will be added.
    */
    define("BASE_SHORT_PATH", "http://it-in.ru/~");
    /**
    * ID of the infoblock which holds information about shortned URLs.
    */
    define("TINYURL_IBLOCK_ID", 11);
    Class TinyURL
    {
    	/**
    	* Converts decimal number to any base
    	* @param integer $num Your decimal integer
    	* @param integer $base Base to which you wish to convert $num (leave it 0 if you are providing $index or omit if you're using default (62))
    	* @param string $index If you wish to use the default list of digits (0-1a-zA-Z), omit this option, otherwise provide a string (ex.: "zyxwvu")
    	* @return string
    	* @link http://www.php.net/manual/ru/function.base-convert.php#52450
    	*/
    	private static function dec2any( $num, $base=62, $index=false ) {
    		if (! $base ) {
    			$base = strlen( $index );
    		} else if (! $index ) {
    			$index = substr( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ,0 ,$base );
    		}
    		$out = "";
    		for ( $t = floor( log10( $num ) / log10( $base ) ); $t >= 0; $t-- ) {
    			$a = floor( $num / pow( $base, $t ) );
    			$out = $out . substr( $index, $a, 1 );
    			$num = $num - ( $a * pow( $base, $t ) );
    		}
    		return $out;
    	}
    	/**
    	* Converts number in any base to decimal
    	* @param integer $num Your custom-based number (string) (ex.: "11011101")
    	* @param integer $base Base with which $num was encoded (leave it 0 if you are providing $index or omit if you're using default (62))
    	* @param string $index If you wish to use the default list of digits (0-1a-zA-Z), omit this option, otherwise provide a string (ex.: "abcdef")
    	* @return integer
    	* @link http://www.php.net/manual/ru/function.base-convert.php#52450
    	*/
    	private static function any2dec( $num, $base=62, $index=false ) {
    		if (! $base ) {
    			$base = strlen( $index );
    		} else if (! $index ) {
    			$index = substr( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base );
    		}
    		$out = 0;
    		$len = strlen( $num ) - 1;
    		for ( $t = 0; $t <= $len; $t++ ) {
    			$out = $out + strpos( $index, substr( $num, $t, 1 ) ) * pow( $base, $len - $t );
    		}
    		return $out;
    	}
    	/**
    	* Shortens URL.
    	* @param string $url Absolute URL to be shortened, like http://www.yandex.ru.
    	* @return string
    	*/
    	public static function shorten($url)
    	{
    		CModule::IncludeModule("iblock") || die("Couldn't load one of the required modules. Error fe51e037.");
    		// Check if there is already shortened version of the required URL.
    		$res = CIBlockElement::GetList(
    			array(),
    			array('IBLOCK_ID' => TINYURL_IBLOCK_ID, 'PREVIEW_TEXT' => $url),
    			false,
    			false,
    			array('ID')
    		);
    		if($ob = $res->GetNextElement())
    		{
    			$arFields = $ob->GetFields();
    			return BASE_SHORT_PATH . self::dec2any($arFields['ID']);
    		}
    		
    		// Shorten new URL and create a record in database.
    		$el = new CIBlockElement;
    		$ELEMENT_ID = $el->Add(array(
    			'IBLOCK_ID' => TINYURL_IBLOCK_ID,
    			'NAME' => $url,
    			'PREVIEW_TEXT' => $url,
    			'PREVIEW_TEXT_TYPE' => 'html',
    		));
    		if($ELEMENT_ID)
    		  return BASE_SHORT_PATH . self::dec2any($ELEMENT_ID);
    		else
    		  die($el->LAST_ERROR);
    	}
    	
    	/**
    	* Converts short code to full URL, e.g. 8UdA -> http://yandex.ru.
    	* @param string $short_code
    	* @return string Full URL.

    Продолжаем копаться в недрах гитхаба в поисках изумрудов от bitrix.
    Данное творение некого адепта битрикса (из it-in, http://it-in.ru) для создания tinyurl

    Keeper, 04 Мая 2016

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

    0

    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
    <snippet>
    	<content><![CDATA[
    /**
     * стандартный класс модуля
     */
    Class adeveloper_main extends CModule
    {
    	const MODULE_ID = 'adeveloper.main';
    	var \$MODULE_ID = 'adeveloper.main'; 
    	var \$MODULE_VERSION;
    	var \$MODULE_VERSION_DATE;
    	var \$MODULE_NAME;
    	var \$MODULE_DESCRIPTION;
    	var \$MODULE_CSS;
    	var \$strError = '';
    	function __construct()
    	{
    		\$arModuleVersion = array();
    		include(dirname(__FILE__)."/version.php");
    		\$this->MODULE_VERSION = \$arModuleVersion["VERSION"];
    		\$this->MODULE_VERSION_DATE = \$arModuleVersion["VERSION_DATE"];
    		\$this->MODULE_NAME = "Module Name";
    		\$this->MODULE_DESCRIPTION = "Module desc";
    		\$this->PARTNER_NAME = "Adeveloper";
    		\$this->PARTNER_URI = "http://adeveloper.ru";
    	}
    	function InstallDB(\$arParams = array())
    	{
    		//RegisterModuleDependences('main', 'OnBuildGlobalMenu', self::MODULE_ID, 'CAdeveloperBp', 'OnBuildGlobalMenu');
    		return true;
    	}
    	function UnInstallDB(\$arParams = array())
    	{
    		//UnRegisterModuleDependences('main', 'OnBuildGlobalMenu', self::MODULE_ID, 'CAdeveloperBp', 'OnBuildGlobalMenu');
    		return true;
    	}
    	function InstallEvents()
    	{
    		return true;
    	}
    	function UnInstallEvents()
    	{
    		return true;
    	}
    	function InstallFiles(\$arParams = array())
    	{
    		return true;
    	}
    	function UnInstallFiles()
    	{
    		return true;
    	}
    	function DoInstall()
    	{
    //		global \$APPLICATION;
    	
    		RegisterModule(self::MODULE_ID);
    	}
    	/**
    	 *  @todo добавить блок удаления инфоблока, пока не делаю, чтобы лишнего не удалить
    	 */
    	function DoUninstall()
    	{
    //		global \$APPLICATION;
    		UnRegisterModule(self::MODULE_ID);
    	}
    };
    ]]></content>
    	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    	<tabTrigger>bx-module-class</tabTrigger>
    	<!-- Optional: Set a scope to limit where the snippet will trigger -->
    	<scope>source.php</scope>
    </snippet>

    Шел 2016 год, а var и globals все никак не могу покинуть адептов битрикса.

    https://github.com/adevelopers/bitrix/blob/master/BitrixSnippets/modules/bx-module-class.sublime-snippet

    Keeper, 03 Мая 2016

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

    0

    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
    // Функция определения мобильных браузеров
      public static function is_mobile(){
        $user_agent=strtolower(getenv('HTTP_USER_AGENT'));
        $accept=strtolower(getenv('HTTP_ACCEPT'));
       
        if ((strpos($accept,'text/vnd.wap.wml')!==false) || (strpos($accept,'application/vnd.wap.xhtml+xml')!==false)){
          return 1; // Мобильный браузер обнаружен по HTTP-заголовкам
        }
       
        if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE'])){
          return 2; // Мобильный браузер обнаружен по установкам сервера
        }
       
        if (preg_match('/(mini 9.5|vx1000|lge |m800|e860|u940|ux840|compal|'.
        'wireless| mobi|ahong|lg380|lgku|lgu900|lg210|lg47|lg920|lg840|'.
        'lg370|sam-r|mg50|s55|g83|t66|vx400|mk99|d615|d763|el370|sl900|'.
        'mp500|samu3|samu4|vx10|xda_|samu5|samu6|samu7|samu9|a615|b832|'.
        'm881|s920|n210|s700|c-810|_h797|mob-x|sk16d|848b|mowser|s580|'.
        'r800|471x|v120|rim8|c500foma:|160x|x160|480x|x640|t503|w839|'.
        'i250|sprint|w398samr810|m5252|c7100|mt126|x225|s5330|s820|'.
        'htil-g1|fly v71|s302|-x113|novarra|k610i|-three|8325rc|8352rc|'.
        'sanyo|vx54|c888|nx250|n120|mtk |c5588|s710|t880|c5005|i;458x|'.
        'p404i|s210|c5100|teleca|s940|c500|s590|foma|samsu|vx8|vx9|a1000|'.
        '_mms|myx|a700|gu1100|bc831|e300|ems100|me701|me702m-three|sd588|'.
        's800|8325rc|ac831|mw200|brew |d88|htc\/|htc_touch|355x|m50|km100|'.
        'd736|p-9521|telco|sl74|ktouch|m4u\/|me702|8325rc|kddi|phone|lg |'.
        'sonyericsson|samsung|240x|x320vx10|nokia|sony cmd|motorola|'.
        'up.browser|up.link|mmp|symbian|smartphone|midp|wap|vodafone|o2|'.
        'pocket|kindle|mobile|psp|treo)/', $user_agent)){
          return 3; // Мобильный браузер обнаружен по сигнатуре User Agent
        }
       
        if (in_array(substr($user_agent,0,4),
          Array("1207", "3gso", "4thp", "501i", "502i", "503i", "504i", "505i", "506i",
          "6310", "6590", "770s", "802s", "a wa", "abac", "acer", "acoo", "acs-",
          "aiko", "airn", "alav", "alca", "alco", "amoi", "anex", "anny", "anyw",
          "aptu", "arch", "argo", "aste", "asus", "attw", "au-m", "audi", "aur ",
          "aus ", "avan", "beck", "bell", "benq", "bilb", "bird", "blac", "blaz",
          "brew", "brvw", "bumb", "bw-n", "bw-u", "c55/", "capi", "ccwa", "cdm-",
          "cell", "chtm", "cldc", "cmd-", "cond", "craw", "dait", "dall", "dang",
          "dbte", "dc-s", "devi", "dica", "dmob", "doco", "dopo", "ds-d", "ds12",
          "el49", "elai", "eml2", "emul", "eric", "erk0", "esl8", "ez40", "ez60",
          "ez70", "ezos", "ezwa", "ezze", "fake", "fetc", "fly-", "fly_", "g-mo",
          "g1 u", "g560", "gene", "gf-5", "go.w", "good", "grad", "grun", "haie",
          "hcit", "hd-m", "hd-p", "hd-t", "hei-", "hiba", "hipt", "hita", "hp i",
          "hpip", "hs-c", "htc ", "htc-", "htc_", "htca", "htcg", "htcp", "htcs",
          "htct", "http", "huaw", "hutc", "i-20", "i-go", "i-ma", "i230", "iac",
          "iac-", "iac/", "ibro", "idea", "ig01", "ikom", "im1k", "inno", "ipaq",
          "iris", "jata", "java", "jbro", "jemu", "jigs", "kddi", "keji", "kgt",
          "kgt/", "klon", "kpt ", "kwc-", "kyoc", "kyok", "leno", "lexi", "lg g",
          "lg-a", "lg-b", "lg-c", "lg-d", "lg-f", "lg-g", "lg-k", "lg-l", "lg-m",
          "lg-o", "lg-p", "lg-s", "lg-t", "lg-u", "lg-w", "lg/k", "lg/l", "lg/u",
          "lg50", "lg54", "lge-", "lge/", "libw", "lynx", "m-cr", "m1-w", "m3ga",
          "m50/", "mate", "maui", "maxo", "mc01", "mc21", "mcca", "medi", "merc",
          "meri", "midp", "mio8", "mioa", "mits", "mmef", "mo01", "mo02", "mobi",
          "mode", "modo", "mot ", "mot-", "moto", "motv", "mozz", "mt50", "mtp1",
          "mtv ", "mwbp", "mywa", "n100", "n101", "n102", "n202", "n203", "n300",
          "n302", "n500", "n502", "n505", "n700", "n701", "n710", "nec-", "nem-",
          "neon", "netf", "newg", "newt", "nok6", "noki", "nzph", "o2 x", "o2-x",
          "o2im", "opti", "opwv", "oran", "owg1", "p800", "palm", "pana", "pand",
          "pant", "pdxg", "pg-1", "pg-2", "pg-3", "pg-6", "pg-8", "pg-c", "pg13",
          "phil", "pire", "play", "pluc", "pn-2", "pock", "port", "pose", "prox",
          "psio", "pt-g", "qa-a", "qc-2", "qc-3", "qc-5", "qc-7", "qc07", "qc12",
          "qc21", "qc32", "qc60", "qci-", "qtek", "qwap", "r380", "r600", "raks",
          "rim9", "rove", "rozo", "s55/", "sage", "sama", "samm", "sams", "sany",
          "sava", "sc01", "sch-", "scoo", "scp-", "sdk/", "se47", "sec-", "sec0",
          "sec1", "semc", "send", "seri", "sgh-", "shar", "sie-", "siem", "sk-0",
          "sl45", "slid", "smal", "smar", "smb3", "smit", "smt5", "soft", "sony",
          "sp01", "sph-", "spv ", "spv-", "sy01", "symb", "t-mo", "t218", "t250",
          "t600", "t610", "t618", "tagt", "talk", "tcl-", "tdg-", "teli", "telm",
          "tim-", "topl", "tosh", "treo", "ts70", "tsm-", "tsm3", "tsm5", "tx-9",
          "up.b", "upg1", "upsi", "utst", "v400", "v750", "veri", "virg", "vite",
          "vk-v", "vk40", "vk50", "vk52", "vk53", "vm40", "voda", "vulc", "vx52",
          "vx53", "vx60", "vx61", "vx70", "vx80", "vx81", "vx83", "vx85", "vx98",
          "w3c ", "w3c-", "wap-", "wapa", "wapi", "wapj", "wapm", "wapp", "wapr",
          "waps", "wapt", "wapu", "wapv", "wapy", "webc", "whit", "wig ", "winc",
          "winw", "wmlb", "wonu", "x700", "xda-", "xda2", "xdag", "yas-", "your",
          "zeto", "zte-"))) {
            return 4; // Мобильный браузер обнаружен по сигнатуре User Agent
        }
       
        return false; // Мобильный браузер не обнаружен
      }

    Все те же адепты битрикса. Наслаждайтесь https://github.com/raVidok/bitrix/blob/master/%D0%A4%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0% B8%2C%20%D0%BA%D0%BB%D0%B0%D1%81%D1%81%D 1%8B/%D0%9E%D0%B1%D1%89%D0%B8%D0%B9%20%D0%BA% D0%BB%D0%B0%D1%81%D1%81%20%D1%81%20%D0%B F%D0%BE%D0%BB%D0%B5%D0%B7%D0%BD%D0%BE%D1 %81%D1%82%D1%8F%D0%BC%D0%B8/func.php

    P.S. С нетерпением ждем кодов 5, 6 и 7 :)

    Keeper, 03 Мая 2016

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

    0

    1. 1
    https://github.com/Londeren/Bitrix/blob/master/1C/bx_1c_import.php

    Копался в недраг гитхаба и наткнулся на простыня для импорта 1с для битрикса

    Keeper, 03 Мая 2016

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

    +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
    $vv = $_GET['new'];
    $v1 = $_GET['1'];
    $v2 = $_GET['2'];
    $v3 = $_GET['3'];
    $v4 = $_GET['4'];
    $v5 = $_GET['5'];
    $v6 = $_GET['6'];
    $v7 = $_GET['7'];
    $v8 = $_GET['8'];
    $v9 = $_GET['9'];
    $v10 = $_GET['10'];
    $v11 = $_GET['11'];
    $v12 = $_GET['12'];
    if (mb_strlen($vv) >= 1) {
    	mysql_query ("INSERT INTO vote (title, votes) VALUES ('$vv', '0')");
    	header('Location: /index.php');
    	exit;
    }
    if (mb_strlen($v1) >= 1 or mb_strlen($v2) >= 1 or mb_strlen($v3) >= 1 or mb_strlen($v4) >= 1 or mb_strlen($v5) >= 1 or mb_strlen($v6) >= 1 or mb_strlen($v7) >= 1 or mb_strlen($v8) >= 1 or mb_strlen($v9) >= 1 or mb_strlen($v10) >= 1 or mb_strlen($v11) >= 1 or mb_strlen($v12) >= 1) {
    	mysql_query ("UPDATE vote SET title='$v1' WHERE id='1'");
    	mysql_query ("UPDATE vote SET title='$v2' WHERE id='2'");
    	mysql_query ("UPDATE vote SET title='$v3' WHERE id='3'");
    	mysql_query ("UPDATE vote SET title='$v4' WHERE id='4'");
    	mysql_query ("UPDATE vote SET title='$v5' WHERE id='5'");
    	mysql_query ("UPDATE vote SET title='$v6' WHERE id='6'");
    	mysql_query ("UPDATE vote SET title='$v7' WHERE id='7'");
    	mysql_query ("UPDATE vote SET title='$v8' WHERE id='8'");
    	mysql_query ("UPDATE vote SET title='$v9' WHERE id='9'");
    	mysql_query ("UPDATE vote SET title='$v10' WHERE id='10'");
    	mysql_query ("UPDATE vote SET title='$v11' WHERE id='11'");
    	mysql_query ("UPDATE vote SET title='$v12' WHERE id='12'");
    	header('Location: /');
    	exit;
    }

    Сохранение вопросов в опроснике.

    slowpoke59rus, 27 Апреля 2016

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

    0

    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
    if (empty($_GET['mms']) and empty($_GET['mass']) and empty($_GET['showuser']) and empty($_GET['user']) and empty($_GET['rate'])) {
    $db = mysql_connect ( "mysql.hostinger.ru", "u391920429_gala", "kirill1998" );
    mysql_select_db ( "u391920429_gala", $db );
    $pas = $_POST['pas'];
    $pass1 = $_POST['pass1'];
    $pass2 = $_POST['pass2'];
    $lop = addcslashes($pass1, '?%');
    $jjj = mysql_real_escape_string ($lop);
    $pol = addcslashes($pass2, '?%');
    $kkk = mysql_real_escape_string ($pol);
    $i = $_GET['edit'];
    $mail = $_POST['mail'];
    $stat = $_POST['stat'];
    $ava = $_POST['ava'];
    $ie = addcslashes($i, '?%');
    $ieq = mysql_real_escape_string ($ie);
    $id = preg_replace('~[^a-z0-9 \x80-\xFF]~i', "",$ieq);
    $lol = addcslashes($mail, '?%');
    $ooo = mysql_real_escape_string ($lol);
    $per = addcslashes($stat, '?%');
    $adr = mysql_real_escape_string ($per);
    $po = addcslashes($ava, '?%');
    $popa = mysql_real_escape_string ($po);
    $re=mysql_query("SELECT * FROM users WHERE id='$id'", $db);
    $user = $_SESSION["id"];
    if (mb_strlen($_POST['mail']) >= 4) {
    $up=mysql_query("UPDATE users SET email='$ooo' WHERE id='$user'", $db);
    }
    if (mb_strlen($_POST['stat']) >= 5) {
    $up=mysql_query("UPDATE users SET stat='$adr' WHERE id='$user'", $db);
    }
    if (mb_strlen($_POST['ava']) >= 4) {
    $up=mysql_query("UPDATE users SET ava='$popa' WHERE id='$user'", $db);
    }
    $name = $_SESSION["name"];
    $result=mysql_query("SELECT * FROM users WHERE name='$name'", $db);
    $myrow=mysql_fetch_array($result);
    $passs = md5($pas);
    if ($passs == $myrow["pass"]) {
    if ($jjj == $kkk) {
    if (mb_strlen($jjj) >=5) {
    $mdpass = md5($jjj);
    $up=mysql_query("UPDATE users SET pass='$mdpass' WHERE id='$user'", $db);
    }
    }
    }
    $res=mysql_fetch_array($re);
    if ($_SESSION["id"] == $id) {
    	if ($res['ban'] == 1) {
    		echo '<div class="user_prof">
    		<div class="name_prof_block">Профиль</div>
    				<form name="set" action="/prof.php?edit='.($res['id']).'" method="post">
    				<div class="name_prof_b">Почта</div>
    					<input class="form_mail" value="'.$res['email'].'" name="mail" type="text"/>
    				<div class="name_prof_b">Аватар</div>
    					<input class="form_ava" value="'.$res['ava'].'" name="ava" type="text"/>
    				<div class="name_prof_b">Статус</div>
    					<div class="bb_code_div">'.BB_PANEL('set','stat').'</div>
    					<textarea class="form_status" name="stat" type="text">'.$res['stat'].'</textarea>
    					<input class="add_news" value="Сохранить" type="submit"/>
    				</form>
    		</div>';
    		echo '<div class="stat_prof">
    		<div class="name_prof_block">Пароль</div>
    				<form action="" method="post">
    					<input class="form_mail" placeholder="Старый пароль" name="pas" type="text"/>
    					<input class="form_mail" placeholder="Новый пароль" name="pass1" type="text"/>
    					<input class="form_ava" placeholder="Повторите новый пароль" name="pass2" type="text"/>
    					<input class="add_news" value="Сменить пароль" type="submit"/>
    				</form>
    		</div>';
    	}
    	if ($res['ban'] == 0) {
    	echo '<div class="user_prof">Ваш аккаунт заблокирован<a class="logout_prof" href="/?step=exit">Выход</a></div>';
    	}
    }
    else {
    		echo 'Доступ запрещен';
    }
    }

    slowpoke59rus, 27 Апреля 2016

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

    0

    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
    <?php
    /** тестовая отправка xmlrpc-запроса */
    
    $productId = 665;
    $msisdn = '79210000001';
    $user = 'myuser';
    $pass = 'mypassword';
    $url='http://localhost/';
    
    $request = xmlrpc_encode_request('startService', ['phone' => $msisdn, 'productId' => $productId]);
    
    $header[] = "Content-type: text/xml";
    $header[] = "Content-length: ".strlen($request) . "\r\n";
    $header[] = $request;
    
    echo "Запрос:\r\n";
    print_r($request);
    
    if ($curl = curl_init()) {
    	curl_setopt($curl, CURLOPT_URL, $url);
    	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    	curl_setopt($curl, CURLOPT_HEADER, true);
    	curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    	curl_setopt($curl, CURLOPT_USERPWD, $user . ':' . $pass);
    
    	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    	curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    	curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST' );
    
    	$out = curl_exec($curl);
    }
    $response = xmlrpc_decode($out);

    А мы-то весь день гадем, почему тело запроса на сервер не поступает.

    jonnywalker, 27 Апреля 2016

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