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

    Всего: 9

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

    −9

    1. 1
    2. 2
    Is there PHP mysql_real_escape_string for postgresql?
    pg_escape_string

    https://www.php.net/manual/en/function.pg-escape-string.php

    real_escape_string, 23 Декабря 2021

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

    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
    <?php
    /* 
    Purpose : To add database functions.
    Created : Nikitasa
    Date : 16-11-2016
    */
    include 'configs/dbconfig.php';
    class mysql{
    	var $link;
    	// connect database function 
    	public function connect_database(){		
    		$this->link = mysqli_connect(Host,Username,Password,Database);
    		if(!$this->link){
    			die('Unable to connect');
    		}
    		// return $this->link;
       }
    	// query execution
    	public function execute_query($query){		  
    		$result = mysqli_query( $this->link, $query);  
    		// mysqli_more_results($this->link);   
    		return $result;
    	}
      	
    	
    	// next query execution
    	public function next_query(){		      
    		mysqli_next_result($this->link);		
    	}
    	
    	// result display	    
    	public function display_result($result){ 
    		$obj = mysqli_fetch_assoc($result);
    		return $obj;
    	} 
    	
    	// clear the results	    
    	public function clear_result($result){ 
    		mysqli_free_result($result);
       } 
    
    	// real escape string 
    	public function real_escape_str($str){
    		return mysqli_real_escape_string($this->link, $str);
    	}	
    	// number of rows	
    	public function num_rows($result){ 
    		$num = mysqli_num_rows($result);
    	   return $num;
    	}            
    	// close connection
    	public function close_connection(){
    		//mysqli_close($res);	
    		mysqli_close($this->link);	
    	}
    } 
    $mysql = new mysql();
    ?>

    real_escape_string, 07 Ноября 2020

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

    +3

    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
    # Alternative mysql_real_escape_string without mysql connection
    
    function escape_string($param) {
        if(is_array($param))
            return array_map(__METHOD__, $param);
    
        if(!empty($param) && is_string($param)) {
            return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $param);
        }
    
        return $param;
    }
    
    #Using example
    $name       = @trim(escape_string(stripslashes($_POST['name'])));

    https://gist.github.com/wilnaweb/ca37459bdf92aa74bd2dd7994fa5b0df

    real_escape_string, 09 Сентября 2020

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

    +3

    1. 1
    Error displaying the error page: Application Instantiation Error: Could not connect to MySQL.

    МОЭК запустила дополнительный информационный сервис для москвичей о сроках отключения горячей воды

    https://online.moek.ru

    real_escape_string, 03 Июня 2020

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

    +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
    <?php
                          function php2js ($var) {
    			if (is_array($var)) {
    				$res = "[";
    				$array = array();
    				foreach ($var as $a_var) {
    					$array[] = php2js($a_var);
    				}
    				//return "[" . join(",", $array) . "]";
    				return "" . join(",", $array) . "";
    				
    			}
    			elseif (is_bool($var)) {
    				return $var ? "true" : "false";
    			}
    			elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
    				return $var;
    			}
    			elseif (is_string($var)) {
    			
    						
    				//return "\"" . addslashes(stripslashes($var)) . "\"";
    				  return "" . addslashes(stripslashes($var)) . "";	
    			}
    		
    			return FALSE;
    		}

    real_escape_string, 19 Мая 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    def test_wash_table_column_name(self):
        testcase_ok = "Programmer"
        testcase_injection = "' OR ''='"
        self.assertEqual(dbquery.real_escape_string(testcase_ok), testcase_ok)

    real_escape_string, 19 Мая 2019

    Комментарии (9)
  8. Си / Говнокод #25620

    +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
    char *real_escape_string(const byte *src, int size)
    {
        char *escaped;
        char *pos;
    
        if (memchr(src, '\0', size - 1) || memchr(src, '\n', size) || memchr(src, '\r', size)) {
    	fprintf(stderr, "cannot handle this string\n");
    	return NULL;
        }
    
        pos = escaped = malloc(sizeof(char) * (size * 2 + 1));
    
        if (escaped == NULL) {
    	fprintf(stderr, "malloc failed: %m\n");
    	return NULL;
        }
    
        for (int i = 0; i < size; ++i) {
    	if (!isalnum(src[i])) {
    	    *escaped++ = '\\';
    	}
    	*escaped++ = src[i];
        }
    
        *escaped = '\0';
    
        return pos;
    }

    real_escape_string, 19 Мая 2019

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

    −1

    1. 1
    Если есть "mysql_real_escape_string", то где тогда "mysql_real_unescape_string"?

    real_escape_string, 09 Ноября 2018

    Комментарии (8)
  10. Python / Говнокод #24694

    −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
    import datetime
    import mysql.connector
    
    cnx = mysql.connector.connect(user='scott', database='employees')
    cursor = cnx.cursor()
    
    query = ("SELECT first_name, last_name, hire_date FROM employees "
             "WHERE hire_date BETWEEN %s AND %s")
    
    hire_start = datetime.date(1999, 1, 1)
    hire_end = datetime.date(1999, 12, 31)
    
    cursor.execute(query, (hire_start, hire_end))
    
    for (first_name, last_name, hire_date) in cursor:
      print("{}, {} was hired on {:%d %b %Y}".format(
        last_name, first_name, hire_date))
    
    cursor.close()
    cnx.close()

    Как выглядит mysql_real_escape_string в Python?

    real_escape_string, 31 Августа 2018

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