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

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php
    global $userinfo;
    ...
    $a_query = "select id,name,company,email,phone,url,type from user where login='" .
    								$_SESSION["se_login"] . "' and passwd='" .
    								$_SESSION["se_passwd"] . "' and status=1";
    $a_res = mysql_query($a_query);
    ...
    list($userinfo['id'],$userinfo['name'],$userinfo['company'],$userinfo['email'],$userinfo['phone'],$userinfo['url'],$userinfo['type']) = mysql_fetch_row($a_res);
    ...

    roman_gemini, 13 Февраля 2016

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

    −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
    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
    	global $userinfo;
    	global $smarty;
    	global $cl;
    	$userinfo['id'] = 0;
    	$userinfo['name'] = '';
    	$userinfo['email'] = '';
    	$userinfo['phone'] = '';
    	$userinfo['url'] = '';
    	$userinfo['company'] = '';
    	$userinfo['type'] = '';
    
    	$flogin = def_var('flogin','');
    	$fpasswd = def_var('fpasswd','');
    	$fremember = def_var('fremember',0);
    	if ($fpasswd) {
    		$fpasswd = md5($fpasswd);
    		$_SESSION["se_login"] = $flogin;
    		$_SESSION["se_passwd"] = $fpasswd;
    	} elseif (isset($_COOKIE["co_login"]) && isset($_COOKIE["co_passwd"])) {
    		$_SESSION["se_login"] = $_COOKIE['co_login'];
    		$_SESSION["se_passwd"] = $_COOKIE['co_passwd'];
    	}
    	$auth_msg = '';
    	if (isset($_SESSION["se_login"]) && isset($_SESSION["se_passwd"])) {
    		$a_query = "select id,name,company,email,phone,url,type from user where login='" .
    								$_SESSION["se_login"] . "' and passwd='" .
    								$_SESSION["se_passwd"] . "' and status=1";
    		$a_res = mysql_query($a_query);
    		if (mysql_num_rows($a_res) > 0) {
    			$ip_res = mysql_query("select ip from ipban where ip='".$_SERVER['REMOTE_ADDR']."'");
    			if (!mysql_num_rows($ip_res)) {
    				if ($fremember == 1) {
    					setcookie("co_login",$_SESSION["se_login"],time()+60*60*24*10000,"/", $_SERVER['SERVER_NAME']);
    					setcookie("co_passwd",$_SESSION["se_passwd"],time()+60*60*24*10000,"/", $_SERVER['SERVER_NAME']);
    				}
    				list($userinfo['id'],$userinfo['name'],$userinfo['company'],$userinfo['email'],$userinfo['phone'],
    					$userinfo['url'],$userinfo['type']) =
    					mysql_fetch_row($a_res);
    				mysql_query("update user set last_ip = '".$_SERVER['REMOTE_ADDR']."' where id=".$userinfo['id']);
    			} else {
    				$auth_msg = $cl['authorization_error'];
    			}
    		} else {
    			unset($_SESSION["se_login"]);
    			unset($_SESSION["se_passwd"]);
    			$auth_msg = $cl['authorization_error'];
    		}
    	}
    	if (isset($smarty)) {
    		$smarty->assign('auth_msg',$auth_msg);	
    	}
    ?>

    Типо авторизация

    roman_gemini, 12 Февраля 2016

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

    +10

    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
    class infoshow
    {
    
    
        public function success($text)
        {
    
    
            return "<div class=\"alert alert-success\">" . $text . "</div>";
        }
    
    
        public function info($text)
        {
    
    
            return "<div class=\"alert alert-info\">" . $text . "</div>";
        }
    
    
        public function warning($text)
        {
    
    
            return "<div class=\"alert alert-warning\">" . $text . "</div>";
        }
    
    
        public function danger($text)
        {
    
    
            return "<div class=\"alert alert-danger\">" . $text . "</div>";
        }
    
    }

    Учим ООП

    CoolCoder, 12 Февраля 2016

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(file_exists("uploads/".$row['id'].".png")){
        $urlimg="cursor: pointer;background-image: url('/uploads/".$row['id'].".png');background-size: 250px;";
    }else{
        $urlimg="cursor: pointer;background-image: url('newimg/?{$row['url']}');";
    
    }
                $write .= ' 
                                <div class="thumb" style="'.$urlimg.'" onclick="location.href=\'/page/'.$row['id'].'/\'"></div>
                                ';

    CoolCoder, 12 Февраля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $row['sub']=str_replace("{&amp;quot;",'{"',$row['sub']);
        $row['sub']=str_replace("&amp;quot;:&amp;quot;",'":"',$row['sub']);
        $row['sub']=str_replace("&quot;",'"',$row['sub']);
        $row['sub']=str_replace("&amp;",'"',$row['sub']);
        $row['sub']=str_replace("quot;:quot;",'":"',$row['sub']);
        $row['sub']=str_replace("{quot;",'{"',$row['sub']);
        $row['sub']=str_replace("quot;}",'"}',$row['sub']);
        $row['sub']=str_replace("quot;:",'":',$row['sub']);
        $sub = json_decode($row['sub']);

    CoolCoder, 12 Февраля 2016

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

    +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
    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
    $sql = array();
    foreach ($stats as $date => $array) {
        $where="";
        $where = array();
        $where['date'] = $date;
        foreach ($array as $sub => $array1) {
    
            $where['sub'] = $nosqlmap->text($sub);
    
            foreach ($array1 as $webmaster => $array2) {
                $where['user']=$webmaster;
    
    
                foreach ($array2 as $offer => $array3) {
                    $where['offer'] = $offer;
    
                    foreach ($array3 as $promo => $array4) {
                        $where['promo'] = $promo;
    
                        foreach ($array4 as $potoc => $array5) {
    
                            $where['potoc'] = $nosqlmap->o9($potoc);
    
                            if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'] = 0;
                            if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'] = 0;
                            if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'] = 0;
                            if (!isset($stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'])) $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'] = 0;
    
                            $where['unics'] = $array5['unics'];
                            $where['hits'] = $array5['hits'];
                            $where['orders'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['orders'];
                            $where['aprove'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['aprove'];
                            $where['noorder'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['noorder'];
                            $where['money'] = $stats_o[$date][$sub][$webmaster][$offer][$promo][$potoc]['money'];
                            $sql[] = $where;
                        }
    
                    }
    
                }
            }
    
        }
    }

    CoolCoder, 12 Февраля 2016

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

    +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
    $error = 0;
                list($date, $time) = explode(' ', $_POST['date_till']);
                if (isset($date) && isset($time)) {
                    list($day, $month, $year) = explode('.', $date);
                    list($hour, $min) = explode(':', $time);
                    if (isset($day) && isset($month) && isset($year) && isset($hour) && isset($min)) {
                        $date_till = "$year-$month-$day $hour:$min:00";
                        $executed = Groups::setOutOfRangeGroups($date_till);
                        if (!$executed) {echo 'q';
                            $error = 1;
                        }
                    } else {echo 'w';
                        $error = 1;
                    }
                } else {echo 'e';
                    $error = 1;
                }

    Нормальные герои всегда идут в обход!

    deep, 12 Февраля 2016

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

    +5

    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
    class Db {
    
        private $where;
        private $select = '*';
        private $limit;
        private $order_by;
        private $query;
        private $set;
    
        private function query_string($table){
            $query = ($this->query) ? $this->query : "SELECT $this->select FROM $table WHERE $this->where $this->order_by $this->limit";
            return $query;
        }
        function query($text){
            $this->query = $text;
            return $this;
        }
        function where_text($text){
            $operator = 'AND';
            if (!$this->where){
                $this->where = $text;
            } else {
                $this->where .= $operator." ".$text;
            }
            return $this;
        }
        function order_by_text($text){
            if (!$this->order_by){
                $this->order_by = ' ORDER BY '.$text;
            } else {
                $this->order_by .= ', '.$text;
            }
        }
        function connect($host,$login_mysql,$password_mysql,$baza_name) {
            $db = @mysql_connect("$host", "$login_mysql", "$password_mysql");
            mysql_set_charset('utf8',$db);
            if (!$db) exit("<p>Sorry, not available MySQL server</p>");
            if (!@mysql_select_db($baza_name,$db)) exit("<p>Unfortunately, the database is not available</p>");
        }
        function select($column){
            $this->select = $column;
            return $this;
        }
        function limit($start,$count){
            $this->limit = ' LIMIT '.$start.','.$count;
            return $this;
        }
        function order_by($key){
            if (is_array($key)){
                foreach ($key as $column => $value){
                    if (!$this->order_by){
                        $this->order_by = ' ORDER BY '.$column.' '.$value;
                    } else {
                        $this->order_by .= ', '.$column.' '.$value;
                    }
                }
            } else {
                if (!$this->order_by){
                    $this->order_by = ' ORDER BY '.$key;
                } else {
                    $this->order_by .= ', '.$key;
                }
            }
            return $this;
        }
        function where($key,$compare = '='){
            $operator = 'AND';
            if (is_array($key)){
                foreach ($key as $column=>$value){
                    if (!$this->where){
                        $this->where = $column.$compare."'".$value."' ";
                    } else {
                        $this->where .= $operator." ".$column.$compare."'".$value."' ";
                    }
                }
            } else {
                $key = explode(',',$key);
                if (!$this->where){
                    $this->where = $key[0].$compare."'".$key[1]."' ";
                } else {
                    $this->where .= $operator." ".$key[0].$compare."'".$key[1]."' ";
                }
            }
            return $this;
        }
        function search($column,$search){
            $operator = 'AND';
            $search = strtr($search,array(" "=>" +"));
            $search = '+'.$search;
            $w = 'MATCH('.$column.") AGAINST('".$search."' IN BOOLEAN MODE)";
            if (!$this->where){
                $this->where = $w;
            } else {
                $this->where .= $operator." ".$w;
            }
            return $this;
        }
        function lines($table,$ext = true){
            $msql_query = mysql_query($this->query_string($table));
            $line = mysql_fetch_assoc($msql_query);

    "Удобный php класс для работы с MySQL"
    https://habrahabr.ru/post/277095

    Lure Of Chaos, 12 Февраля 2016

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <td>Текущий статус</td>
                <td><select name="nStatus" size="1" disabled>
                    <option value="0" <?if ($row[nStatus] == '0') { echo 'SELECTED'; }?>>Cоздан</option>
                    <option value="1" <?if ($row[nStatus] == '1') { echo 'SELECTED'; }?>>Продан</option>
                    <option value="2" <?if ($row[nStatus] == '2') { echo 'SELECTED'; }?>>Тестируется</option>
                    <option value="3" <?if ($row[nStatus] == '3') { echo 'SELECTED'; }?>>Бесплатная работа</option>
                    <option value="4" <?if ($row[nStatus] == '4') { echo 'SELECTED'; }?>>Эксплуатация</option>
                    <option value="5" <?if ($row[nStatus] == '5') { echo 'SELECTED'; }?>>Заблокирован</option>
                    <option value="7" <?if ($row[nStatus] == '7') { echo 'SELECTED'; }?>>Приостановлен</option>
                    <option value="6" <?if ($row[nStatus] == '6') { echo 'SELECTED'; }?>>Отключен</option>
                    </select></td>

    grieverrr, 11 Февраля 2016

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

    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
    class ConnectDB {
      protected static $_instance; 
      
      private function __construct() {
        $this->DB = new DBConnector();
      }
    
      private function __clone() {}
    
      private function __wakeup() {}
    
      public static function getInstance() {
        
        if (empty(self::$instance)) {
          self::$_instance = new self;   
        }
        return self::$_instance;
      }
    
    }

    Синглтон, который каждый рас создает новый объект

    Nemesys, 10 Февраля 2016

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