Posts by Inkeliz • 20,671 points
671 posts
-
3
votes2
answers1423
viewsQ: How to force download local information in the browser?
I’m trying to do something kind of like this: $('button').on('click', function() { obj = {}; $('pseudoform').find('input,textarea').each(function() { obj[$(this).attr('name')] =…
-
1
votes1
answer1564
viewsA: How to pass a parameter via curl_exec to another url with PHP?
The response of @Daniel Omine says about the POST method and meanwhile if it’s GET it could simply do: $parametro = http_build_query($transactionReference, '', '&', PHP_QUERY_RFC3986);…
-
0
votes2
answers50
viewsA: how to get the highest repetition index (source 0) within a php string
This does not work with multibyte characters! In the condition of posting could simply do: $string = 'ddddeeeeeefffffffffgggggggggggggggggghhhhh'; $QntPorCaractere = count_chars($string, 1);…
-
1
votes1
answer9369
viewsA: HTTP/1.1 302 Found Is this normal or in trouble?
It is normal, it only indicates that the page was "moved" and the Location: will indicate where the user should go. This Wikipedia post about HTTP codes is enough to answer: 3xx Redirection 302…
-
2
votes1
answer258
viewsA: Curl returning indefinite offset
Summary: The strlen($header) has nothing to do with getting the information, that’s a Curl requirement. The variable $cookie, how do you define the reference use (&$cookie) you will have all…
-
1
votes2
answers222
viewsA: I’m trying to build a Megasena betting generator with the following parameters
If you can’t repeat between them it would be easier to define which choices are possible, then: $NumerosDiposniveis = range(0, 59); When selecting one of them, then run:…
-
2
votes1
answer2509
viewsA: Curl Post Office Tracking
This Curl was made to not work, actually the problems: Your call is to the wrong page, /sistemas/rastreamento, when accessing the page by browser and "track" any order, you make a request to another…
-
4
votes8
answers955
viewsA: split/regex only on the first vertical bar "|"
A very simple way would be to get the length of the first part (João) and then use it to take all the rest. For example: texto = "João|||23anos|"; partes = []; partes.push( texto.split('|')[0] );…
-
1
votes1
answer900
viewsA: Security in PHP BD Access
Just answer: If his code had to be exposed to the public at any time, he would expose his credentials? If you do: $login = 'usuario' $senha = 'minhasenha'; That will never be a good idea, this is…
-
2
votes1
answer419
viewsA: Curl returning null value in JSON with PHP
There are several possible problems: This endpoint (https://api.twitter.com/1.1/statuses/update.json) expects you to send the access_token, obtained using the Oauth. Solution: Inform the…
-
0
votes1
answer263
viewsA: How do I get information for Twitter accounts?
This answer is before editing, based on commenting. If you want an example, then suppose you have website X, which uses this code: <?php /** * NÃO UTILIZE ESTE CÓDIGO EM PRODUÇÃO! */…
-
2
votes3
answers1847
viewsA: Jquery: calculate the number of banknotes of the cashout value (deliver as few as possible)
Just divide by the largest ballot and decrease, it follows the same idea of the answer of @Magichat. var notasDisponiveis = [100, 50, 20, 10, 5, 2]; function calcularNotasNecessarias(valor,…
-
1
votes1
answer620
viewsA: What is Netscape HTTP Cookie File for and how?
This is a cookie storage format and in this case it was done using the Curl as mentioned in the comments This file was generated by libcurl! Edit at your own risk.. What good is he? As a way to…
-
2
votes1
answer93
viewsA: Which Apache2 Cipher Suite is compatible with Chrome 49 on Windows XP?
Windows XP natively supports only broken (or weak, if you want to be optimistic), for starters it only supports Sslv2, Sslv3 and TLS 1.0, i.e., TLS 1.1 and 1.2 are not supported. The Cipher Suite…
-
1
votes1
answer130
viewsQ: Why does this goroutin loop just repeat the last value?
This loop is always repeating the last value, consider the following: type unique struct { id, nonce uint64 } func (unique *unique) print() { fmt.Println(unique.id) } func main() { teste :=…
-
3
votes2
answers396
viewsA: Golang language
I can’t answer every question... Is there anything ready regarding AES encryption and RSA for the Go language? Yes, actually much more than just RSA and AES. But, about the AES it also supports…
-
0
votes1
answer43
viewsA: Regrouping repeated items from an array
Just make a simple foreach, considering: $array = [ [ 'categoria' => 1, 'titulo' => 'teste 1', 'descricao' => 'teste 1', 'id_no_banco' => 1, ], [ 'categoria' => 2, 'titulo' =>…
-
3
votes4
answers4690
viewsA: Caesar cipher - problem with letters and spaces
I think an easier way to explain it would be: int main(){ char frase[200]; strncpy(frase, "SUA FRASE QUALQUER", 200); for(int i=0; i < strlen(frase); i++){ if(frase[i] >= 65 &&…
-
1
votes3
answers63
viewsA: Reorder variables by throwing the blanks to the end
Using only foreach could do: foreach($array as $index => $valor){ if(empty($valor)){ unset($array[$index]); $array[$index] = $valor; } } This will check whether it is empty and will remove it…
-
0
votes2
answers67
viewsA: help with php regular expression
/!\ I don’t recommend using this! You can use REGEX: /<script.*?>(.*?<\/script.*?>)?/i Therefore: <ScrIpT>alert()</ScrIpT> <script type=\"text/javascript\">alguma…
-
2
votes5
answers1513
viewsA: Skip Record within a while
If you want to ignore the tipo of 2 completely, it would be ideal not to get them from the database, using for example: $query = "SELECT * FROM tabela WHERE tipo != 2"; If the 2 is maximum type, can…
-
1
votes1
answer37
viewsA: Array does not go full through json
According to your code: $x = 0; // <<< while($services = $querytwo->fetch(PDO::FETCH_ASSOC)) { $var[$x] = $services['name']; } The $x will always be 0, you have several options to fix…
-
1
votes4
answers294
viewsA: Replace character by PHP function
Using a simpler REGEX: \(([0-9.]+)\) This will allow any character between 0 and 9 (0-9) and points (.), in this case he would allow a 0...123. But I wouldn’t take any () additional. However, if you…
-
1
votes1
answer948
viewsA: Format Note to 2 Decimal Places
Once it is multiplying you can solve two problems at once by using the Bcmath, after all float count "wrong". Then set the number of houses: bcscale(2); Then do: $nota1 = $_POST['input1']; $nota2 =…
-
0
votes1
answer21
viewsA: Taking data from php formats with cycles
This occurs due to the difference of single and double quotes in php, recommend you read this to understand. In your case you have two options (actually you have other options): Use '...'.$c:…
-
3
votes2
answers212
viewsA: Web server in Go apparently is not creating new requests
This occurs because of where the variable is set, when you set: var Nome string It becomes global, accessible to everything, so not just a connection. Making: curl -X POST -d "nome=inkeliz"…
-
1
votes1
answer1249
viewsA: Go to page and login with Curl
It doesn’t work because Facebook requires you to send more information. Simply monitoring the network traffic you can see that the "Login" is done in: https://m.facebook.com/login/async/ It also…
-
4
votes1
answer2108
viewsA: Update data with Audible Alert
Just use the play(), nor need Jquery, if using Jquery use .trigger('play'). First set the audio that will trigger: <audio id="notificacao" preload="auto"> <source…
-
3
votes3
answers36
viewsA: String handling at alternate positions
You simply use REGEX: Service Id\s+:\s?([0-9]+) Thus: preg_match('/Service Id\s+:\s?([0-9]+)/', $result1, $ServiceIds); echo $ServiceIds['1']; The \s+ is the space, with any size, the \s+? is an…
-
6
votes1
answer515
viewsQ: What differs an FPGA to a CPU?
I was looking at some publications on the BLAKE cryptographic algorithm, which was one of the finalists in the SHA-3 competition, whose winner was Keccak. Finally, in a specific excerpt from the…
-
0
votes3
answers370
viewsA: Sort phone numbers in a string
There is no information about the origin of these data, if the answer from @Leo Caracciolo is sufficient. In general cases, such as where you are reading from the file you can use the usort, as…
-
6
votes1
answer732
viewsA: How to see if there is already a record in the mysql and php database
Give a UNIQUE in the column, this will prevent Mysql from having two equal information in that column, example: ALTER TABLE utilizadores ADD UNIQUE (email) That will make the email be unique, ie can…
-
12
votes2
answers7290
viewsA: What is the importance of Integrity and Crossorigin attributes?
This is done to ensure that the files have not been modified. The sha-384 It’s a cryptographic summary of the SHA-2 family, so it’s an encryption hash. This feature is sensitive to any change, ie…
-
1
votes3
answers1380
viewsA: How to print an HTML using PHP a <ul> list of items with 3 different types?
I don’t know what the difficulty would be if I wanted to do it the usual way, mixing PHP with HTML, utilize: <div class="row"> <?php $cores = ['carrot', 'amethyst', 'sunflower']; $index_cor…
-
1
votes3
answers1036
viewsA: problem filling in form with uppercase letters
I think the ideal would be to actually fix the "this generates a BUG on my site there in the panel" and to support the uppercase characters normally. Meanwhile there is the mb_strtolower() which…
-
3
votes3
answers691
viewsA: How to correctly format a monetary value?
Another solution would be to remove only keep the whole numbers and divide them by 100. $moeda = 'R$ 1.550,52'; $valor = preg_replace('/[^0-9]/', '', $moeda); $valor = bcdiv($valor, 100, 2); $valor…
-
0
votes3
answers1589
viewsA: How to redirect user after login according to user type?
You are issuing a header after sending the body, which is sent by <!-- FIM PHP LOGIN -->, this is not allowed, by default you should be getting a: Warning: Cannot Modify header information -…
-
0
votes1
answer224
viewsA: PHP: Replace only on the first word repeated
It may have a specific function for this, but is easy to do at hand. Assuming the text: My name is "Victor", the name "his" "is" "Victor", "his" name "is" "Victor" We can simply do: Find the ",…
-
1
votes1
answer78
viewsA: Logical help with PHP using Twitter API
Tos from Twitter: Following/Not following Automated Actions: You may not follow or fail to follow Twitter accounts indiscriminately or in bulk. Aggressive stalking is a violation of the Twitter…
-
1
votes2
answers156
viewsA: How to use preg_match_all in this excerpt?
That answer is based on the question before editing. Just use: /<a href="https:\/\/myanimelist.net\/topanime.php\?type=var1">(.*?)<\/a><\/div>/ It is necessary to escape the / and…
-
0
votes2
answers312
viewsA: How to round up number?
You can simply check that the integer value is equal, that is: $inteiro = intval($numero); if(($numero - $inteiro) !== 0e0){ // Então adicionar $inteiro + 0.5 } You could do something like: function…
-
4
votes3
answers253
viewsA: Separate zero from dates
Just use the n instead of m, according to the documentation: Numerical representation of a month, zero left Therefore: $mesAtual = date('n'); var_dump($mesAtual); // = string(1) "6" Test this. It…
-
1
votes3
answers902
viewsA: How to convert text field with mask to double
An alternative would be to use a single str_replace, no need to use this twice. echo str_replace(['.', ','], ['', '.'], $valor); Test this. You can also use the strtr: echo strtr($valor, ['.' =>…
-
2
votes3
answers87
viewsA: PHP - Loop accentuation problem in a string
You can also use the mb_substr, or even regex. $frase = 'nós'; $tamanho = mb_strlen($frase); for($posicao = 0; $posicao < $tamanho; $posicao++){ echo mb_substr($frase, $posicao, 1, "UTF-8") .…
-
2
votes1
answer75
viewsA: Make a START TRANSACTION does not reserve the ID of the tables involved, in case of Insert failure
This is a feature of AUTO INCREMENT, according to the documentation itself: "Lost" auto-increment values and Sequence gaps In all lock modes (0, 1, and 2), if a transaction that generated…
-
5
votes3
answers207
viewsA: Question about Twitter API
What the documentation wants is that credentials (token, bearer token, secret key...) should be kept only with you, safely. Once this information is obtained you will be able to make requests on…
-
1
votes2
answers1256
viewsA: how to read the return variables using json Curl and php
See this response. The problem is in json_decode($result, true), after the CURL, you have two options: Change to json_decode($result) and keep the rest as is; or Keep the json_decode($result, true)…
-
3
votes1
answer70
viewsA: Return an in_array() true within an SQL result
I believe you should use the array_column var_dump(in_array(1182652232, array_column($dados_top_visitas, 'cod_usuario'))); Test this. The in_array only checks values that are in the array, but not…
-
13
votes2
answers662
viewsA: What is Timing-Attack and where does it apply?
It is a problem that affects anything that does not have constant time, I believe that better explain with examples, maybe someone will answer the most theoretical part. Suppose this type of code,…
security-guardanswered Inkeliz 20,671 -
5
votes1
answer156
viewsA: What is the possibility of finding a particular 192-character string in 10 minutes?
Well, there are exactly 2 128 possible combinations, 340 cylinders. Making such a request in 10 minutes is somewhat complicated, virtually undetectable. However there are some flaws, a little…