Jump to content

requinix

Administrators
  • Posts

    15,045
  • Joined

  • Last visited

  • Days Won

    413

Everything posted by requinix

  1. Because the code on your machine is not the exact same code you posted here. Even more so because FatalErrorException is not a built-in class to PHP, which means there is some other code somewhere that defines and throws it.
  2. The code you have posted executes just fine: https://3v4l.org/VgRDX
  3. Here's a quick one: preg_match('/^(.*)\d+)$/', "2001:db8:a0b:12f0::1:25", $match) && list(, $ip, $port) = $match;(I was deliberately avoiding doing this with my first answer)
  4. Do you mean, like, where is the most appropriate place in code to set it? There isn't anything in there that's clearly "this is a point where the user has chosen a particular language", but the closest would be where you check $_GET. if (isset($_GET['language']) && self::is_language_supported($db, $config, $_GET['language'])) { // setcookie(...) return $_GET['language']; }
  5. Not being able to think of any nicer solution, I'd go with substr() and strrpos(). $ipport = "2001:db8:a0b:12f0::1:25"; $p = strrpos($ipport, ":"); $ip = substr($ipport, 0, $p); $port = substr($ipport, $p + 1);
  6. Then the error message is incorrect. Or the error message is referring to some other code that isn't what you posted.
  7. That is not possible: (1) the index is actually "sessionvar" and (2) you did an empty check just before. What is your real code?
  8. Then it's easy to change the script. Right now it tracks just the coldest and hottest temperatures; add two more variables for the coldest and hottest locations.
  9. FYI, next time you post code, make sure you remove sensitive information like the appid you had in that URL. So that code makes more sense than the one earlier, and doesn't have as much that needs to change. You already have a loop that goes over all the locations, so do the work of determining the highest and lowest in there. Do you only care about the temperatures? You like you don't care where the temperatures are from - just what they are? <?php session_start(); include_once("cxn.inc"); $today = date("Y-m-d H:i:s"); $sql = "SELECT airports.Name,airports.Country FROM airports INNER JOIN rosters ON airports.IATA = rosters.Arr WHERE rosters.Code = '$code' AND rosters.SectorDate >= '$today'"; $result = mysqli_query($cxn,$sql) or die ($cxn->error); $coldest = $hottest = null; while($row=mysqli_fetch_assoc($result)) { $link = 'http://api.openweathermap.org/data/2.5/weather?q='.$row['Name'].','.$row['Country'].'&units=metric&mode=xml&appid=*'; /* WEATHER API */ $xml=simplexml_load_file("$link") or die ("Cannot create object."); $temp = (int)$xml->temperature['value']; // converting to int is important or you'll have a bunch of SimpleXMLElement objects if (is_null($coldest) || $temp < $coldest) { $coldest = $temp; } if (is_null($hottest) || $temp > $hottest) { $hottest = $temp; } } /// OUTPUT GOAL /// echo $coldest; echo '<br />'; echo $hottest; ?>
  10. Alright, then we need to start from the beginning. What is the XML you have ($link?) and what does the database have to do with it?
  11. Your code doesn't make sense. Is that really what you have?
  12. How do you want the user to decide? Do you want them to give them both options at once? Have some sort of "custom" item in the list? For the list itself, a simple for loop will do: echo "<select>"; for ($m = 0; $m <= 24; $m += 0.25) { $hhmm = sprintf("%02u:%02u", floor($m), (60 * $m) % 60); echo "<option value='{$hhmm}'>{$hhmm}</option>"; } echo "</select>";
  13. Turn everything into a int, like using array_map with intval, then do min() and max() on the final array. Looks like you're getting this from XML? You might be able to do the min/max from within the XML itself, depending on what the markup is...
  14. If someone has access to the system then you're done for. Basic tenet of computer security. Obfuscating, hashing, compiling code, none of that will protect you for long. If this information is so secretive that you don't want these people with access to be able to see it then don't give them access. It's that simple.
  15. You're running some kind of update script on a database that doesn't need updating.
  16. Huh. I must have missed the changelog entry that says "file_get_contents() will now attempt to execute what it retrieves as PHP code".
  17. Yes. Using some Mail class, not vanilla mail().
  18. Are you sure that's the direction you want to rewrite? People go to /blog.html and you want that to actually execute /blog/2013.html?
  19. No. Because that would also remove the code dealing with the normal To: recipients. See the $to? Make sure $recipients does not have any information about the CC people or the BCC people.
  20. Are you saying that it does not work right now? Because that query says absolutely nothing about which day's records to update.
  21. UPDATE table SET last_dty_timestamp = /* today's date */, duty_flag = duty_flag + 1 ORDER BY last_dty_timestamp ASC /* earliest records first */, person_id /* unique ID to guarantee a stable sort */ LIMIT 4 /* only update the first four records */
  22. Tentatively, yes. And the CC ones too. Those should both be handled with the $headers earlier.
  23. JSON is probably your best bet. Upload: Do a POST with a request body containing the JSON data. PHP reads the body, decodes, and inserts into the database. Download: PHP reads the data from the database, JSON-encodes it, and outputs it.
  24. if(empty($recipients)){ $recipients = $to; if(!empty($cc)){ $recipients.= "," .$cc; } if(!empty($bcc)){ $recipients.= "," .$bcc; } }Don't put the BCC list in the list of recipients. In fact, shouldn't the Mail code handle all that itself?
×
×
  • 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.