Posts by Inkeliz • 20,671 points
671 posts
-
1
votes1
answer550
viewsA: Replace one symbol with another in PHP
What must occur is that the + represents space, so when using the $_GET['q'] it contains space, not the symbol of +. This exchange, internal PHP, makes the str_replace does not work, because there…
-
1
votes1
answer1612
viewsA: Security and login authentication in Ionic 3 using PHP-generated access token
Is this a safe way to authenticate? If not, how to do? Set your goals, without this it is impossible to determine what is safe. Raising the height of your house wall does not make it difficult to…
-
4
votes1
answer95
viewsA: Do I need Coins (or any other currency) running on a blockchain?
Yes. The blockchain itself is like a mere database, maybe it’s the worst database of all. However, a database does not "run" an application. Typically the other way around, an application consumes…
-
4
votes2
answers99
viewsA: MYSQL: How to make a month closure from day 26 to day 26
Just specify the day and so pick everything that is between the dates: SELECT SUM(custosgerais) FROM custos WHERE data_baixa >= '2017-01-26 00:00:00' AND data_baixa < '2017-02-26 00:00:00' You…
-
5
votes1
answer9213
views -
6
votes1
answer67
viewsA: How to generate temporary image for development environment?
I believe you’re referring to https://placeholder.com/, on it you can generate images "with gray background and a background marking containing the dimensions of the same". For example: <img…
-
4
votes1
answer871
viewsA: How to get the values within multiple tags?
PHP already has native functions to handle HTML. I don’t believe that using REGEX for this purpose, is recommended. First you take HTML, using file_get_contents or cURL, how are you using the…
-
3
votes2
answers724
viewsA: mysqli_real_escape_string Prevent SQL Injection?
There is a possibility of SQL Injection even when using the function mysqli_real_escape_string()? Not typically, unless used strange charset. Suppose you use UTF8MB4 and always use the " (or ') in…
-
0
votes2
answers102
viewsA: How to convert "month" to "months" using PHP timestamp?
You can check if the last letter is s or if the $j is 5: if($difference !== 1){ $periods[$j] .= mb_substr($periods[$j], -1, 1) === 's' ? 'es' : 's'; } The other way would be: if($difference !== 1){…
-
1
votes2
answers39
viewsA: Lack of security page registration
Yes, he can. Actually there are two questions here: Send this information as if you are logged in to a user session: Send this information arbitrarily without posing as a connected user. In both…
-
1
votes2
answers152
viewsA: doubts about the variable session_start()
Ignoring all the problems, that there are at least four, you should do a new query to get this information, assuming you have the information of nome saved in some database column, related to…
-
1
votes2
answers1667
viewsA: get who gave like on video youtube PHP API
This is not possible, at least not that way. Google has a API for Youtube, you need to authorize this, obviously. If it authorizes, you can use the "Retrieve the Current user’s rating of a video",…
-
3
votes1
answer99
views -
30
votes2
answers1370
viewsA: How does code obfuscation work in Javascript?
This is not encryption. This is just hexadecimal (Base16), like any other encoding, like Base64, Base32, Base91... If you make a: fmt.Println(hex.EncodeToString([]byte("Olá mundo!"))) You will have…
javascriptanswered Inkeliz 20,671 -
1
votes1
answer553
viewsA: How to get the return of multi Curl (curl_multi_add_handle)?
First, the curl_multi is not "compatible" with the functions of curl_*. That is, first you create Curl normally (using the curl_init() and the curl_setopt()), then add this Curl to Handle in…
-
1
votes3
answers406
viewsA: PHP array that is not getting values
Just to differentiate from the other answers, you may not use if and actually don’t even use > or < if you want. You can create an array and do the same operation regardless of whether the…
-
1
votes2
answers64
viewsA: Deleting a Session automatically
You can make sessions predictable for yourself. This has a risk involved, but so you could destroy the previous session, knowing the current state. In theory the idea my idea is simple, in the…
-
1
votes1
answer404
viewsA: I made this code to send an automatic email to the subscriber in db . The registration is ok, but the email does not go to the client. What is wrong?
I believe it’s because of 'FROM:$vemail', when you use ' PHP does not interpret anything inside it. Change to: 'FROM: '.$vemail or "FROM: $vemail" Should to work. However, there is another detail,…
-
7
votes3
answers599
viewsA: Is mixing HTTP with HTTPS a problem?
If you use SSL but do not use HSTS (nor HPKP) you allow an attacker to downgrade to HTTP. Having SSL, without HSTS, is the same as nothing. You cannot turn on HSTS (nor HKPK), this will break access…
-
1
votes2
answers881
viewsA: Problem running str_pad in PHP
The str_pad does not work with multi-byte characters, since it does not add all characters at once. The original code of str_pad is exactly: switch (pad_type_val) { case STR_PAD_RIGHT: left_pad = 0;…
-
2
votes2
answers325
viewsA: Can you open the outllok through php, without being a mailto?
Exists as using exec, but this requires that PHP is being used on the client side, what is not common. According to the documentation of Outlook CLI: outlook.exe /c ipm.note /m [email protected] Other…
-
1
votes2
answers771
viewsA: Sort foreach in php
You can also use the arsort: $algos = array_flip(hash_algos()); foreach($algos as $algo => $len){ $algos[$algo] = strlen(hash($algo, '', true)); } arsort($algos); foreach($algos as $algo =>…
-
3
votes2
answers528
viewsA: generate id Session/secure php cookie
Do not use mt_rand, time, rand, lcg_value and neither uniquid. These resources CAN generate a unique but unpredictable number. Some become pathetic, to predict the time used just look at the clock,…
-
27
votes5
answers2375
viewsA: Should I show generic error messages like, wrong password or user, or specific messages?
I believe the answers are good, but @Stormwind’s response to "a generic error message" left me a little puzzled. Today in systems like Google and Microsoft is different from the past, now first ask…
-
0
votes1
answer119
viewsA: For file_get_contents are there options similar to those of Curl?
In fact you can even use the Sockets for this, it is logical that with the file_gets_contents will also get. It is important to remember that in the case below I am not using the Netscape format,…
-
0
votes1
answer438
viewsA: CURLOPT_HEADERFUNCTION - Return of cookies
This code will never work, first see the documentation of the CURLOPT_HEADERFUNCTION: This callback Function must Return the number of bytes Actually Taken care of. If that amount differs from the…
-
1
votes2
answers238
viewsA: More than one return on a method in PHP
There are several ways, in fact what you want is not "More of a return", including. But you could do: const ERR_MENOR_QUE_UM = 0; const ERR_MAIOR_QUE_VINTE = -1; const ERR_DIVISIVEL_POR_DOIS = -2;…
-
0
votes2
answers277
viewsA: PHP Curl Twitter Check if data is correct
I believe that to answer this simply you miss and hit your password on Twitter and see the difference in responses. Based on this, the difference between the right and wrong password is that: If hit…
-
0
votes1
answer920
viewsA: Cookies with Curl help
All you need to do is use: curl_setopt($handle, CURLOPT_COOKIEFILE, 'caminho/cookie.txt') This will load the cookies that were previously saved, provided you specify the correct file. The…
-
0
votes3
answers1242
views -
1
votes2
answers990
viewsA: How to encrypt GET and copy the parameter
You can use a simple HMAC to check if the id remains unchanged, this will be safe as long as no one knows the key used by you, logical it must be strong and generated safely, I will explain this…
-
4
votes2
answers745
viewsA: Problem with str_replace php
No, you do not need REGEX, you can use the strtr, he has a different behavior than str_replace: $arrayFrutas = [ "banana" => 'f.banana', "bananaGrande" => 'f.banana_grande' ]; $string =…
-
2
votes3
answers275
viewsA: Using the explode() function on Infomoney
Utilise explode to handle and find HTML, and PHP has native resources for this... For me it is a huge gambit. You can use Xpath (or another resource) to locate that element directly. The number is…
-
3
votes1
answer1005
viewsA: Best Way to Use AES Encryption
What algorithm to use to derive the key? So that it is as far away from the password as possible and always has 256 BIT? "Best" is Argon2i which is available in PHP 7.2 (or via PECL). But since you…
-
2
votes2
answers118
viewsA: Problems with JSON + PHP
I believe this occurs when Dexes cease to be sequential, so it is necessary to be an object to continue with the same Dexes. For example consider this: $json =…
-
2
votes1
answer370
viewsA: Return values in time format
A very simple way would be to add 0 to the left until there are two numbers, you have the fmt.Sprintf you can do this. If you use it it would look like: func (c Clock) String() string { return…
-
1
votes2
answers241
viewsA: Add cart values from a Session
You can use: $total = array_sum(array_column($_SESSION['product_cart'], 'price')); echo 'O total é ' . $total; The array_column() will select only the column price and the array_sum() will add up…
-
3
votes2
answers946
viewsA: Encryption with bcrypt + random salt
First, never do that: if(crypt($senha_digitada, $senha_armazenada) === $senha_armazenada) Any string is a secret should never be compared using == or ===, This is not constant time and exposes the…
-
7
votes6
answers32253
viewsA: What is the best way to create a PHP login system
In PHP use Argon2id, this is available in PHP 7.2: $hash_str = sodium_crypto_pwhash_str($password, SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE, SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE ); Then use…
-
2
votes1
answer51
viewsA: Session passing value that was not expected
The code makes no sense since the PHP will run everything and send to client. When you do: <li class="secretariado" onclick="<?php $_SESSION['selctcurso'] = 'secretariado3'; ?>"> It’s…
-
2
votes1
answer71
viewsA: Separate array by a certain value
Just make a foreach adding up the previous values until it reaches 4: // Seu array: $arr = array_fill(1, 10, 2); $total = 0; foreach($arr as $i => $item){ $total += $item; if($total >= 4){…
-
2
votes2
answers4450
viewsA: How to use openssl_encrypt encryption method?
Two different keys: If you want to use asymmetric encryption you seek the use of openssl_public_encrypt, on it you can use a public key. You can generate a private key using openssl_pkey_new, so you…
-
1
votes3
answers101
viewsA: Run a script once yes and once no
Users are registered where? They have some unique and sequential identification number, just do: if($id_do_ususario % 2 === 0){ executaScript(); } That way when the id for 1 it will not trigger,…
-
3
votes3
answers1512
viewsA: How to do so, if the record exists, it updates, if it does not do an Insert of the same
You don’t need PHP, at least you can ignore it depends on the case. In Mysql you have a similar feature, which can be done natively with the REPLACE, according to the manual. REPLACE Works Exactly…
-
1
votes1
answer1950
viewsA: Send headers in HTTP Request with Curl in PHP
Possibly this is because the array is formatted wrong. The CURLOPT_HTTPHEADER expects an array of the type: ['Content-Type: application/json', 'Qualquer: Coisa']; Each array value must be a row,…
-
0
votes1
answer34
viewsA: Check Unix user
As far as I know, maybe I’m wrong, there is no way to extend functions or interfaces in Golang, created by other Packages, much less in this case. First, you must define us imports the os, but that…
-
0
votes3
answers62
viewsA: Can anyone do this with PHP without jquery?
Just submit the form also the previous information, so you add the new and gives a echo. This will require a new field: <form> //.. <input type="hidden" name="historico"…
-
2
votes2
answers59
viewsA: Insert string with strtoupper
If the idea is to replace everything could simply use the str_replace and the strtoupper to keep everything in check, if that’s what you want. $listaDeSubstituição = [ 'b' => '♭' ]; $chord =…
-
1
votes1
answer878
viewsA: How to generate two Google Charts on the same page?
What defines where the graphic will be presented is precisely the document.getElementById('chart_div'), specified on the last lines. Assuming you are using Jquery, you could create new elements and…
-
2
votes2
answers199
viewsA: How to show Options (HTML) with database elements
If you don’t understand why you are just getting the last record you will make this mistake again. Note exactly in: while($linha = $pegadiv->fetch(PDO::FETCH_ASSOC)){ $idConta = $linha['id'];…