user-input

How to cleanse a string to avoid SQL Injection and the most common types of attack? (in PHP)

試著忘記壹切 提交于 2019-12-01 10:47:09
Is there a way to, in as little code as possible, to filter a string for both SQL injection and the most common forms of attack? In my scripts I'm using the following, I would like to know whether it's reasonably safe and whether someone else has a suggestion: $cleanName = htmlspecialchars(addslashes($dirtyName)); See how I filtered it both for html chars and for quotes and double-quotes. NOTE: I'm using addslashes() rather than mysql_real_escape_string() because I don't want to hardcode the DB I'm using into my code. Is this ok? Thanks in advance Probably not... you need to escape your raw

Using user input to create a new object [JAVA]

给你一囗甜甜゛ 提交于 2019-12-01 10:32:31
Hi I am trying to create a program to create a new object whenever the user inputs a new information for a certain object. Currently I have this. import java.util.Scanner; public class Main { public static void main (String args[]) { String input; Scanner scanner = new Scanner(System.in); do { System.out.println("Computer Menu"); System.out.println("1. Add a new Desktop Information"); System.out.println("2. Add a new Laptop Information"); System.out.println("3. Display all Computer Information"); System.out.println("4. Quit"); System.out.print("Please enter either 1 to 4: "); input =(scanner

How to store sessions of a telegram bot user in my db

对着背影说爱祢 提交于 2019-12-01 10:28:11
问题 I wanna code a telegram bot, so when I gonna receive messages from a user I should know about last message he/she sent to me and in which step does he/she located. So I should store sessions of the user (I understood this when I searched) but I don't know what exactly should I do? I know I need a table in a db that stores UserId, ChatId but I don't know these: How to make a root for steps and store them in db (I mean how do I understand where the user is located now) What are other columns

In Python, is there a way to validate a user input in a certain format? [duplicate]

我的未来我决定 提交于 2019-12-01 09:34:59
This question already has an answer here: Asking the user for input until they give a valid response 18 answers In python, I'm asking the user to input an office code location which needs to be in the format: XX-XXX (where the X's would be letters) How can I ensure that their input follows the format, and if it doesn't ask them to input the office code again? Thanks! The standard (and language-agnostic) way of doing that is by using regular expressions : import re re.match('^[0-9]{2}-[0-9]{3}$', some_text) The above example returns True (in fact, a "truthy" return value, but you can pretend it

How to handle both integer and string from raw_input?

独自空忆成欢 提交于 2019-12-01 08:47:26
Still trying to understand python. It is so different than php. I set the choice to integer, the problem is on my menu I need to use letters as well. How can I use integer and string together? Why can I not set to string than integer? def main(): # Display the main menu while True: print print " Draw a Shape" print " ============" print print " 1 - Draw a triangle" print " 2 - Draw a square" print " 3 - Draw a rectangle" print " 4 - Draw a pentagon" print " 5 - Draw a hexagon" print " 6 - Draw an octagon" print " 7 - Draw a circle" print print " D - Display what was drawn" print " X - Exit"

How to cleanse a string to avoid SQL Injection and the most common types of attack? (in PHP)

会有一股神秘感。 提交于 2019-12-01 08:35:51
问题 Is there a way to, in as little code as possible, to filter a string for both SQL injection and the most common forms of attack? In my scripts I'm using the following, I would like to know whether it's reasonably safe and whether someone else has a suggestion: $cleanName = htmlspecialchars(addslashes($dirtyName)); See how I filtered it both for html chars and for quotes and double-quotes. NOTE: I'm using addslashes() rather than mysql_real_escape_string() because I don't want to hardcode the

Hide user input, and only allow certain characters

邮差的信 提交于 2019-12-01 08:28:59
问题 Is there any way to hide user input when asked for in C? For example: char *str = malloc(sizeof(char *)); printf("Enter something: "); scanf("%s", str);getchar(); printf("\nYou entered: %s", str); // This program would show you what you were writing something as you wrote it. // Is there any way to stop that? Another thing, is how can you only allow certain characters? For example: char c; printf("Yes or No? (y/n): "); scanf("%c", &c);getchar(); printf("\nYou entered: %c", c); // No matter

<h:inputText> doesn't seem to work within <ui:repeat>, only the last entry is submitted

半腔热情 提交于 2019-12-01 08:27:43
问题 I have an <ui:repeat> with <ui:inputText> : <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" template="./templates/masterLayout.xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core"> <ui:define name="content"> <ui:repeat value="#{genproducts.dbList()}" var="itemsBuying"> <div class="indproduct"> <p class="center">#{itemsBuying.name}</p>

How to make a batch file that send application an input char

一世执手 提交于 2019-12-01 06:53:11
I'm writing a batch file that launch an application. app.exe After the application is launched, I'm getting a list of options in the console, and the program waits for input, for example: a: start session b: end session c: end How do I make the batch type a ? David R Tribble Other than using echo as @npclaudiu suggested, you could also write the expected input to a text file and then have the app read the file: app.exe <input.txt This works if the app expects more than one line of input. First, make sure if the application supports command line arguments. For example, at your command prompt,

waiting for user input in separate thread

纵然是瞬间 提交于 2019-12-01 06:21:56
I am trying to accomplish a way to spawn a thread that waits for user input; if no input is entered within 10 seconds, I want the script to kill off the spawned thread and continue processing. I've got a way to get the input back from the thread if text is entered but I have no way to let the timeout kill off the newly spawned thread. In the example below is the closest I have come. I tell the newly created thread that it is a daemon and it will exit when the main script exits. The issue that I have with this is that the thread will continue to wait until either the script exits, or the user