Jump to content

requinix

Administrators
  • Posts

    15,227
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. If $response is that XML then $xml = simplexml_load_string($response); $ip = ->children("http://schemas.xmlsoap.org/soap/envelope/") // <env:*> ->body // <env:body> ->children("http://webServices.server.ifce.fr/") // <ns2:*> ->getInformationPreleveurResponse // <ns2:getInformationPreleveurResponse> ->children("") // <*> ->informationPreleveur; // <informationPreleveur> echo (string)$ip->adresse1; // 4 PLACE DE L'EGLISE
  2. And what I'm saying is, since your website cannot control the user's phone or the information the Vipps site stored in their browser, you can't log the user out. You being able to log out of Vipps does not mean that your site can make it happen for you.
  3. Unless they provide a way to revoke an access token, the only thing you can do is make sure the user is logged out of your system - you simply can't log someone out of some other website (not unless you can find an security weakness in their site to do so). But a secure OAuth login prompt should not have the side effect of signing the user into that site in the first place... This isn't just an issue for your two sites: anyone on a shared computer needs to know that if they log into anything, be that Google or Facebook or Amazon, then they have to log out again before they leave. I don't know all the details of what's going on but it doesn't sound like there's anything you can do.
  4. This would be easier to explain if I could see what $response contains. Because it is XML, if you "echo $response" then all the <tags> in it will be invisible, but any <tag>123</tag> will show up as "123". To see the XML and the <tags>, either "htmlspecialchars($response)" like I showed before, or View Source in your browser. Here is an example of how you can read a SOAP response using SimpleXML. If you want to see the "u:month" value inside the <dimension>, 1. The first element is the Envelope. You need to be in the "soapenv" namespace to access it, so call children() with the URI noted in the xmlns attribute. You do not need ->Envelope because $xml is already the root node. 2. The second element is the Body. You need to be in the "soapenv" namespace, but you are already so you do not need to call children() again. Then ->Body. 3. The third element is the getDataResponse. That is the "tns" namespace so call children() again, then ->getDataResponse. 4. Next is the record. It is not in any namespace, which means it is in in the default namespace, but there is no default "xmlns" attribute anywhere to tell you a special URI so use just "". Then ->record. There are multiple "record"s so add [0] for the first item. 5. Next is dimensions, which is also in the default namespace, so ->dimensions. 6. Next is dimension, so ->dimension. Finally you can use ["name"] to get the attribute, but only because it is also in the default namespace. If you can show the XML response you are receiving, with the XML <tags>, then I can show you the exact PHP code to get the information you need.
  5. $response will be XML. What is the output of // var_dump($response);// affiche string (676) + la chaine de caractère // echo $response; // affiche la chaine de caractère echo "<pre>", htmlspecialchars($response), "</pre>"; // <soapenv:Envelope ...???... </soapenv:Envelope>
  6. The nature of OAuth is that you do not control the user's session with the remote site. You can't log the user out like you want to do, and arguably you should not either: it's not your concern. Why do you think you need to be able to log the user out of that other site?
  7. https://www.google.com/search?q=mysql+sum+returning+null
  8. I'd just not bother and do the same thing I do when NPM and Cargo (Rust) have problems: delete the lock file and reinstall. That should fix any "partial" thing that put you into a weird state.
  9. Sounds like you've decided on a solution. What was the problem?
  10. Don't worry about whether you have the "right" code. Everyone can arrive at the right code eventually. What's more important is the process you use to arrive at that code. There's a lot to PHP, and all programming languages, but ultimately they all act like a recipe: you use particular ingredients in a particular sequence to achieve a particular result. Sometimes you can substitute one ingredient for another, and sometimes you can adjust the sequence to work better, but most of the time you can't throw things into a pot and expect something edible. Being a good cook is about understanding each part and combining them successfully. Here we have a few ingredients to work with, such as databases, math, arrays, for loops, and foreach loops. Each of those is made up even more ingredients, such as the mysqli library, SQL queries, integer division, array brackets, and ternary expressions. It's a lot of moving parts but understanding what each does and means is crucial to being able to use them correctly. And when you understand them, it's easier to arrange them in an order to achieve the result you want. The best piece of advice is something I said earlier: don't always copy and paste code but spend some time to learn what it represents so that you can extract the relevant parts and apply them to your own code. On the more factual side of things, I'll pick the one that stands out: $items = $codes; $count = $codeCount; You start with the $codes and $codeCount variables and then copy them into the $items and $count variables. So you now have two pairs of variables that mean the same things. There's no need to have duplicates like that, so you could keep the two you started with and forget the two new ones - all you have to do then is adjust the later code to use the correct variables.
  11. Looks like you're kinda throwing syntax at the problem and hoping it goes away. That very, very rarely ever works. I will say that I wrote the wrong variable name a couple times in my previous post. $chunks is the one that has the chunks of the array, not $chunk. If you fix that with columns 2-4 then they should work equally correctly, but the only reason they work at all now is because you stumbled into some code that is wrong but accidentally makes the other parts do what you want. With the three columns working, compare your code for those with the code for the first one.
  12. My reply was a bit late so I did assume you were still working on it. Not everyone does, when they're waiting for replies, but you seemed more responsible than that. You're much closer. $chunks will be an array with a chunk for each column: $chunk[0] for the first, $chunk[1] for the second, and so on. That means each column doesn't need an additional foreach on $chunks itself. You only need the one foreach, and you run it on the appropriate $chunk[X] directly. No worries. I've been doing this long enough that I'm pretty good at spotting which people want help to work through the problem and which people want help so they don't have to do the work at all.
  13. The code I posted was a sample of how the process can work. You should spend some time to read through it, maybe look up what unfamiliar parts are doing (or ask), then adapt it to suit your own specific needs. The end result should be something that is part what I wrote and part what you had before.
  14. Then array_chunk won't be quite as helpful: it'll create 3 chunks of the same size and 1 of a remainder. I can't think of an easier way of doing this than creating your own chunks: <?php const COLUMNS = 4; $items = range(1, 98); $count = count($items); $base = floor($count / COLUMNS); // 24 $remainder = $count % COLUMNS; // 2 // so $base * COLUMNS + $remainder == $count $chunks = []; for ($start = 0; $start < $count; ) { // the base amount, plus one if there are any remainder to include $length = $base + ($remainder-- > 0 ? 1 : 0); $chunks[] = array_slice($items, $start, $length); $start += $length; } print_r($chunks); // [1-25, 26-50, 51-74, 75-98]
  15. Read. The. Error. Messages. Please don't make me bold the relevant parts.
  16. So if you open up your user settings, let's say the JSON file, you can see in there an entry for php.debug.executablePath with the correct file path? And another entry for php.validate.executablePath with the same file path?
  17. Both of the messages there (the two that are actual errors, that is) tell you what to do. Have you done that?
  18. What you currently do is chunk it into groups of 4 (so it goes 1,2,3,4; 5,6,7,8; 9,10,11,12) and then use array_column to get the Nth member of each group into the Nth column (column 1 has 1,5,9; column 2 has 2,6,10, etc). What you want to do is chunk it so there are 4 groups, and then put the contents of the Nth group into the Nth column. Now here's a question. If you have 10 items to put into those four columns, do you want 1 | 4 | 7 | 10 2 | 5 | 8 | 3 | 6 | 9 | where the last "column" is incomplete, or 1 | 4 | 7 | 9 2 | 5 | 8 | 10 3 | 6 | | where the last "row" is incomplete? The normal answer here, with the values going column-by-column, would be the first. That means there are ceil(10 items / 4 columns) = 3 items per column, except the last which has (10 items - 3 items per column * 3 columns not counting the last) = 1 item remaining. Fortunately you only need to figure out how many items you want in each of the 4 chunks - that is, ceil(number of items / number of columns). Then PHP will give you an array with four elements and each column can foreach over its respective chunk, just like you're doing now except you're asking it to chunk with the wrong number.
  19. I don't know what you were doing in those screenshots but it sure doesn't look like you tried running "python app.py".
  20. Yeah, don't do that. See if your hosting provider is willing (and able) to turn off mod_security for you: it's a great thing in theory but reports so many false positives that it just ends up being a pain in the ass. If that's not an option, all you have to do to bypass this particular security measure is to encode the data. For example, with base 64. Submit the data encoded and have your PHP decode it.
  21. Actually, it looks like PHP itself protects you from the kind of attack I was thinking of. So that's nice. So not just any file can be read. However your script will still let anyone read any PDF file that exists on your server. And it's simple: all they have to do is pass the right "fname" and "lname" values to create a $path that goes where they want it to go. That would have been it, yes: var_dump would create some output on its own, then you would echo the true value that it returned (which would display as "1").
  22. Congratulations, you have mod_security installed. Are you on shared hosting or do you have a dedicated server you can control?
  23. It's just regular old normalization: if you have two pieces of data then you need two columns to hold them. Slight clarification to a thing I said: non-float with the smallest unit, so for an integer column you'd have $1.23 as 123 but with a decimal(_,2) column you'd have 1.23 perfectly fine. But with a decimal you have to care about the number of decimal places, and as pointed out different currencies use different scales.
  24. Hard to know without being able to see what it was that didn't work. But what you have isn't actually correct. And I don't just mean because of the significant remote file inclusion vulnerability you've created - one that would allow anyone to view any file that exists on your server, including PHP source code and configuration files and confidential files and really anything they can imagine. $a = glob($path); $b=($a[0]); $cd=($b); $cc = ("$cd"); - $a will be an array of files matching the $path pattern. Good. - $b will be the first file in the array. The parentheses don't do anything and are useless. - $cd will be the same as $b. There's no point to having both $cd and $b. The parentheses don't do anything here either. - $cc will be the value of $cd (a filename) put into a string (it was already a string) - or in other words, the same as $cd and $b. No point to this. And ditto about the parentheses here again. Please, do yourself a favor and learn PHP. That way you will not have to stumble around anymore. A non-obvious thing is your use of the Accept-Ranges header. Your script does not actually support ranges. Do not send this header because your server will be lying to the browser.
  25. There is no standard hybrid format for currency and amount. Use a non-float column that stores the amount measured in the lowest units (so $1.23 is 123 and ¥123 is also 123) and a string column for the currency code.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.