1. Список говнокодов пользователя Govnisti_Diavol

    Всего: 29

  2. PHP / Говнокод #13538

    +151

    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
    97. 97
    98. 98
    99. 99
    <?php
    class user {
    	var $logined=false;
    	var $information;
    	var $err_code=0;
    	var $err_arr;
    	var $cookie_time=2592000;
    	var $_db;
    	var $no_profile_photo="/assets/img/no_profile_photo.jpg";
    	var $friends_list=array();
    	var $friends_list_to=array();
    	var $friends_list_from=array();
    	//RewriteRule ^(.*)profile_photo.jpg$ assets/img/no_profile_photo.jpg [L]
    
    	function db($_db){
    	$this->_db=$_db;
    	}
    
    	function set_err_txts(){
    		$this->err_arr[0]="";
    		$this->err_arr[1]="login preg";
    		$this->err_arr[2]="no such login in db";
    		$this->err_arr[3]="wrong pass";
    		$this->err_arr[4]="";
    	}
    
    	function auth($login,$pass,$md5=false){
    	if(!($login)) {return false;}
    	////////////////////////////////////
    	$this->set_err_txts();
    	$cookie_time=time()+$this->cookie_time;
    	/////////////////////////////
    	if(!(preg_match("/^[a-z0-9_-]+$/i",$login))) 
    	{$this->err_code=1; return false;}
    	////////////////////////////////////////////////////////////
    	$sql="select id, login, salt from users where login='".$login."'";
    	$res=mysql_query($sql,$this->_db);
    	//echo $sql; echo var_dump($this->_db); echo var_dump($res);
    	if(!($item=mysql_fetch_array($res)))
    	{$this->err_code=2; return false;}
    	///
    	$id=$item['id'];
    	$salt=$item['salt'];
    	////////////////////////////////////////////////////////////
    	if(!($md5)){ $pass=$this->code_pass($pass,$salt); }
    	////////////////////////////////////////////////////////////////
    	$sql="select * from users where (login='".$login."') and (pass='".$pass."')";
    	$res=mysql_query($sql,$this->_db);
    	//echo $sql; echo var_dump($this->_db); echo var_dump($res);
    	if(!($item=mysql_fetch_array($res)))
    	{$this->err_code=3; return false;}
    	/////////////////////////////////////////////////////////////
    	setcookie("login", $login, $cookie_time,"/"); 
    	setcookie("pass", $pass, $cookie_time,"/");
    	$sql="update users set visit_time=".time()." where id='".$id."'";
    	mysql_query($sql,$this->_db);
    	$this->information=$item;
    	$this->logined=true;
    	////////////////////////////////////////////////////////////////
    	$sql="
    	select users_params.name, users_params_values.value 
    	from users_params, users_params_values 
    	where 
    	(users_params_values.user_id='".$id."') 
    	and 
    	(users_params_values.param_id=users_params.id)";
    		$res=mysql_query($sql,$this->_db);
    		while($item=mysql_fetch_row($res)){
    		$this->information[$item[0]]=$item[1];
    	}
    	$this->information["folder"]="/profiles/".substr($login,0,1)."/".$login."/";
    	$this->information["profile_photo"]=$this->information["folder"]."profile_photo.jpg";
    	$this->create_friends_list();
    	return true;
    	}
    	
    	function get_info_by_id($target_user_id){
    	$sql="select id, login, visit_time from users where id='".$target_user_id."'";
    	$res=mysql_query($sql,$this->_db);
    	$item=mysql_fetch_array($res);
    	$login=$item['login'];
    	$this->information["login"]=$login;
    	$this->information["visit_time"]=$item['visit_time'];
    	$this->information["id"]=$item['id'];
    	$sql="
    	select users_params.name, users_params_values.value 
    	from users_params, users_params_values 
    	where 
    	(users_params_values.user_id='".$target_user_id."') 
    	and 
    	(users_params_values.param_id=users_params.id)";
    		$res=mysql_query($sql,$this->_db);
    		while($item=mysql_fetch_row($res)){
    		$this->information[$item[0]]=$item[1];
    	}
    	$this->information["folder"]="/profiles/".substr($login,0,1)."/".$login."/";
    	$this->information["profile_photo"]=$this->information["folder"]."profile_photo.jpg";
    	}
    	.... over 9000 ....

    Понос

    Govnisti_Diavol, 02 Августа 2013

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

    +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
    <?php
    session_start();
    
    if (empty($_SESSION['login']) or empty($_SESSION['session_id'])) {
    	$DATA = array('login' => $_POST['login'], 'password' => $_POST['password']);
    	include "classes/data_base_class.php";
    	$auth_result = DataBase::StartAuth($DATA['login'], $DATA['password']);
    	
    	if ($auth_result == 1) {
    		echo '<meta http-equiv="refresh" content="0;URL=../error.php?mod=auth">';
    		exit();
    	}
    	else
    	{
    		$_SESSION['login'] = $auth_result['user_login'];
    		$_SESSION['user_name'] = $auth_result['user_name'];
    		$_SESSION['session_id'] = $auth_result['reg_data'];
    		echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
    		exit();
    	}
    }
    else
    {
    	echo '<meta http-equiv="refresh" content="0;URL=../index.php">';
    	exit();
    }
    ?>

    Вот вам авторизация, ага - ага!

    Govnisti_Diavol, 07 Мая 2013

    Комментарии (3)
  4. JavaScript / Говнокод #12890

    +144

    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
    genchatmessage: function(text, avatar1, avatar2, time, rtl) {
    		if (typeof rtl == "undefined") var rtl = false;
    		if (typeof avatar == "undefined") var avatar = "images/user_male.png";
    		if (typeof time == "undefined") var time = this.gettime();
    		var tr = document.createElement("tr");
    		var td = [document.createElement("td"), document.createElement("td"), document.createElement("td")];
    		var div = document.createElement("div");
    		var span = document.createElement("span");
    		var pre = document.createElement("pre");
    		span.innerHTML = time;
    		pre.innerHTML = interface.innerText(String(text));
    		if (rtl) {
    			div.className = "chat-message-rtl";
    		} else div.className = "chat-message";
    		if (typeof avatar1 == "string") {
    			var img1 = document.createElement("img");
    			img1.src = avatar1;
    			td[0].appendChild(img1);
    		}
    		if (typeof avatar2 == "string") {
    			var img2 = document.createElement("img");
    			img2.src = avatar2;
    			td[2].appendChild(img2);
    		}

    Govnisti_Diavol, 14 Апреля 2013

    Комментарии (4)
  5. Java / Говнокод #12609

    +65

    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
    package com.example.testing;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
        
    }

    Govnisti_Diavol, 17 Февраля 2013

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

    +119

    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
    <?php
    session_start();
    if(empty($_SESSION['login']) or empty($_SESSION['id']) or empty($_SESSION['auth_key']))
    {
        header("Location: index.php");
    }
    else
    {
        $user_name = $_POST['name'];
        $user_sname = $_POST['sname'];
        $user_gender = $_POST['gender'];
        $user_about = $_POST['about'];
        
        
        $user_phone = $_POST['phone'];
        $user_mail = $_POST['email'];
        
        $user_company = $_POST['company'];
        $user_company_position = $_POST['position'];
        
        
        $user_login = $_POST['login'];
        $user_password = $_POST['password'];
        
        include 'includes/xd4sw.php';
        $update_query = mysql_query("UPDATE users SET user_name='$user_name', user_sname='$user_sname', user_gender='$user_gender',
                user_about='$user_about', user_phone='$user_phone', user_mail='$user_mail', user_company='$user_company', 
                user_company_position='$user_company_position', user_login='$user_login', user_password='$user_password' WHERE user_id=".$_SESSION['id']);
        mysql_close($db);
        header('Location: settings.php?act=good');
        
    }
    
    ?>

    НА НАХ!!!!

    Govnisti_Diavol, 12 Февраля 2013

    Комментарии (31)
  7. JavaScript / Говнокод #12414

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var onClear = function(e)
                {
                    if(e.value == "Логин" || e.value == "Пароль")
                        {
                            e.value = "";
                        }
                }

    <input type="text" name="login" value="Логин" onclick="onClear(this);"/>
    Ох блин...

    Govnisti_Diavol, 14 Января 2013

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

    +44

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function addHeadJS($src){
        $js_tag = '<script language="JavaScript" type="text/javascript" src="/'.$src.'"></script>';
    	if($this->is_ajax) { echo $js_tag; return true; }
    	$this->addHead($js_tag);
        return true;
    }

    Добавляет тег <script> с указанным путем
    @param string $src - Первый слеш не требуется
    @return true

    Govnisti_Diavol, 04 Января 2013

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

    +43

    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
    <?php
    session_start();
    if(empty($_SESSION['UserLogin']) or empty($_SESSION['UserId']))
    {
      header('Location: /');
    }
    else
    {
      if($_GET['mess_id'] == "")
      { 
         header('Location: /'); 
      }
      else
      {
        include("application/db.config.php");
        $GetUserIdQuery = mysql_query("SELECT id FROM Users WHERE id=".$_SESSION['UserId'], $db);
        $UserIdArr = mysql_fetch_array($GetUserIdQuery);
        
        $GetMessInfoQuery = mysql_query("SELECT * FROM Messages WHERE DialogId=".$_GET['mess_id'], $db);
        $MessageInfoArr = mysql_fetch_array($GetMessInfoQuery);
        if($UserIdArr['id'] != $MessageInfoArr['UserTo'])
        {
          header('Location: /');  
        }
        else
        {
            mysql_close($db);  
           ......................................................... и так далее...
        }
      } 
    }

    В довесок к этому(http://govnokod.ru/12268), БЛ*АТЬ!

    Govnisti_Diavol, 14 Декабря 2012

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

    +156

    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
    this.start = function() {
    		// Инициализирует парсинг выгрузки из Агента Плюс.
    		if (this.open()) {
    			this.catalogs = this.getTags("catalogs", true)[0].childs;
    			this.subdocuments = this.getTags("documents", true)[1].childs;
    			this.guids = this.document.childs[0].childs[0].childs;
    			this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
    			this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
    			this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
    			this.deals = this.getCatalog("Договоры").childs[0].childs;
    			this.nomenclature = this.getCatalog("Номенклатура").childs;
    			this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
    			this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
    			this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
    			this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
    			for (var i = 0; i < this.catalogs.length; i++) {
    				this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
    				this.info.catalog.push(this.catalogs[i].attrib);
    			}
    			for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
    				this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
    				this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
    				this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
    			}
    			for (var i = 0; i < this.deals.length; i++) {
    				this.names.deals.push(this.deals[i].attrib.Name);
    				this.info.deals.push(this.deals[i].attrib);
    				this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
    			}
    			for (var i = 0; i < this.measure.length; i++) {
    				this.names.measure.push(this.measure[i].attrib.Name);
    				this.info.measure.push(this.measure[i].attrib);
    				this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
    			}
    			for (var i = 0; i < this.contragents.length; i++) {
    				this.names.contragents.push(this.contragents[i].attrib.Name);
    				this.info.contragents.push(this.contragents[i].attrib);
    				this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
    			}
    			for (var i = 0; i < this.sellpoints.length; i++) {
    				this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
    				this.info.sellpoints.push(this.sellpoints[i].attrib);
    				this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
    			}
    			for (var i = 0; i < this.guids.length; i++) {
    				this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
    			}
    			
    			this.dynamic.routes = new Array();
    			for (var i = 0; i < this.route.childs.length; i++) {
    				var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
    				var adr = sp.Name;
    				var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
    				var ptypeguid = this.hash.deals[ca.A08].A06;
    				var cagent = ca.Name;
    				var dealguid = ca.A08;
    				var exists = false;
    				for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
    				if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
    			}
    		} else return;
    	};

    Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.

    Govnisti_Diavol, 12 Декабря 2012

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

    +50

    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
    <?php
    session_start();
    if(empty($_SESSION['UserLogin']) or empty($_SESSION['UserId']))
    {
      header('Location: /');
    }
    else
    {
      include("application/db.config.php");
      $GetterUser = $_POST['ForUser'];
      $SenderUser = $_SESSION['UserId'];
      $Rem = strip_tags($_POST['Rem']);
      $Text = strip_tags($_POST['Text']);
    
      if($Rem == "" or $Text == "")
      {
        header("Location: sent_mess?to=$GetterUser&status=bad");
      }
      else
      {
        $SendingMessQuery = mysql_query("INSERT INTO Dialogs(From, To, Rem, Text) VALUES($SenderUser, $GetterUser, '$Rem', '$Text')", $db) or die(mysql_error());
        mysql_close($db);
        header("Location: sent_mess?to=$GetterUser&status=good");
      }
    }
    ...

    Govnisti_Diavol, 11 Декабря 2012

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