Jump to content

requinix

Administrators
  • Posts

    15,286
  • Joined

  • Last visited

  • Days Won

    435

Everything posted by requinix

  1. Can you unfiddle with the directory? What did you do?
  2. Use -> for nodes and [] for attributes (or indexes). So like the ISP value, and both use the arrow. $geoLocXML = $getGeoLocXML->result[0]; echo($geoLocXML . '<br>'); echo($geoLocXML->isp . '<br>'); echo($geoLocXML->city . '<br>'); echo($geoLocXML->countryname . '<br>');
  3. Use your web server's built in logging mechanisms instead. Don't even need PHP.
  4. IPB 3 is old and unsupported. No updates, no improvements, no fixes. We need to move to something that's still actively maintained. IPB 4 is the best candidate but apparently there are some issues we need to work out with it first.
  5. Sorry about the few days of lost content but IP.Board 4 was clearly not up to the job. Two points specifically: 1. Due to their implementation of search, search engine spiders were killing site performance. This was the main problem. 2. They dropped features we need and use, namely BBCode (very handy for a programming community) and Mark Solved (their Discussion forum style is not a replacement). To the handful of members who signed up in the last few days, sorry but you will need to sign up again. I promise your experience on this site will be better than it was before.
  6. During this time the forums will be upgraded to IP.Board 4. After the site comes back online, a number of background jobs will need to run so there may be a few anomalies here and there.
  7. [edit] You know what? Nevermind. Feeding the troll is the real detriment. ajoo, do your own research before believing one anonymous person with a fancy green nameplate on some site on the internet. And with that, I sign off from PHP Freaks until later this month when ~stuff~ will happen, because if Jacques wants to continue spreading his FUD then I don't want to be around for it.
  8. Don't use a prepared statement. $query = "SELECT fname, lname, city, email, cell FROM staff" . ($staff > 0 ? " WHERE staff_id = " . (int)$staff : "");But what you're doing doesn't make sense. Without a staff ID, you'll pull just one random person's information out. What's the point?
  9. I don't know your application. You're going to have to make some decisions on your own. This "status ID" thing isn't in the list of searchable terms so it sounds like you should put that condition straight into the query itself. Are you not familiar enough with SQL to know how to do that?
  10. Either modify $where to include your condition, or write it straight into the query. Whichever makes more sense in the code.
  11. Some people like "src" because that's traditional for compiled languages. It doesn't make as much sense for PHP, and particularly not when it's the only directory at that level. Otherwise you've got the gist of it: public/html should be the web-accessible assets and a PHP script or two, then most everything else lives outside there. Separate classes/includes/lib/logs is good.
  12. You would have origin issues - unless you configured the server to allow cross-origin requests. You can totally do that. Is it how PHP is supposed to work? There is no "supposed". It is capable of doing many things and you are using it to do one thing. That's fine. Node.js? If you want, but that's an entirely different discussion.
  13. My special powers tell me that OP is in the regular ol' EST/EDT region in Canada, and where America/Toronto is the correct timezone identifier.
  14. The code is syntactically valid. If I knew what you were trying to do with it, I would make a comment pertaining to that.
  15. A quick adjustment to Jacques's regex: ISBN-10s can end with an X instead of the final digit, so (?[\\d-]+[Xx]?).
  16. What you're dealing with is known as the knapsack problem. It is not trivial to solve. How large is $arr? The easiest solution will probably be to generate every possible combination of players, then filter out the ones that do not meet your team and salary requirements, then find the one with the maximum projection.
  17. Which is it? Daylight savings or no daylight savings?
  18. Also check the browser's console to see if there were errors or something. And check the "network" or whatever tab to see the response (if any) sent by the server, and whether it contained what you think it contained.
  19. Sounds like OP is using "EST" as a layman's term. So
  20. Which was... what? Please share with the rest of the class.
  21. The only reason I can think of that someone would have the markup is because they're copying it from somewhere, and that's an instance where not being familiar with HTML causes the opposite problem. For example, Google Analytics gives you some On that note, 1. Stuff like the generator should be automatic anyways - not manually written out by someone. 2. The robots thing should be a global- or page-level option that a user enables in some configuration area, then rendered into HTML appropriately - not manually written out by someone. 3. The canonical URL should definitely be automatic - unless you want someone to be able to say that a particular page is derivative of some other page on some other website (which would be quite suspicious).
  22. As said, that code is just plain wrong. And I too prefer the dedicated subdomain method rather than a URL prefix. That code also doesn't provide any way for a user to give their preference. Maybe they want to see the full site on their phone? Maybe you want to test out the mobile site on your desktop? Nicest method is with a cookie and putting something in the URL to switch between versions. $mobile = (isset($_COOKIE["mobile"]) ? (bool)$_COOKIE["mobile"] : $this->mobiledetect->isMobile()); $mobileurl = (strncmp($_SERVER["REQUEST_URI"], "/m/", 3) == 0); // use a ?sticky query string parameter to force the desktop/mobile site with a cookie if (isset($_GET["sticky"])) { // awkwardness to copy the session cookie parameters $params = session_get_cookie_params(); $params["lifetime"] || $params["lifetime"] = 0; $params["path"] || $params["path"] = "/"; $params["domain"] || $params["domain"] = $_SERVER["HTTP_HOST"]; setcookie("mobile", ($mobileurl ? "1" : "0"), $params["lifetime"], $params["path"], $params["domain"]); // redirect to the url without the ?sticky $query = array_diff_key($_GET, array("sticky" => 0)); $url = "http://" . $_SERVER["HTTP_HOST"] . strtok($_SERVER["REQUEST_URI"], "?") . ($query ? "?" . http_build_query($query) : ""); redirect($url); } // mobile device on a non-mobile page else if ($mobile && !$mobileurl) { $url = "http://" . $_SERVER["HTTP_HOST"] . "/m" . $_SERVER["REQUEST_URI"]; redirect($url); } // non-mobile device on a mobile page else if (!$mobile && $mobileurl) { $url = "http://" . $_SERVER["HTTP_HOST"] . substr($_SERVER["REQUEST_URI"], 2); // remove leading /m redirect($url); }then <a href="http://www.example.com/path/to/page">Desktop version that redirects to mobile if (a) a mobile device and no cookie or (b) mobile=1 cookie</a> <a href="http://www.example.com/m/path/to/page">Mobile version that redirects to desktop if (a) a non-mobile device and no cookie or (b) mobile=0 cookie</a> <a href="http://www.example.com/path/to/page?sticky">Desktop version and sets a mobile=0 cookie</a> <a href="http://www.example.com/m/path/to/page?sticky">Mobile version and sets a mobile=1 cookie</a>
  23. DTD, XSD, or Relax NG schema validation could do a lot of work, but AFAIK wouldn't be able to validate actual attribute values (eg, that the canonical URL has the right domain). That basically leaves you with your own validation routines. As long as you approach it like a whitelist - specifically allow certain structures, disallow everything else - then this is quite possible. However it gets exponentially more difficult as you allow more complex HTML; just that example there would be fine, but I'm more concerned about what else would be possible. Unless you want to get really sophisticated with this, you should do the specific key/value meta pairs thing (and a separate entry for the canonical URL, plus whatever else). It's the safest course of action, and it doesn't require that the user understand writing HTML markup. As a secondary option for the user, you could allow them to input HTML and then scan it for particular elements to keep. As in load the string into DOMDocument (no regular expressions), search for and tags, then extract the data into that key/value system. I could write a proof of concept for the "sophisticated" approach, if someone asks for it, but I just started playing FFXIV and right now I'd rather do that.
  24. Really tired of people wanting arrays over objects... Look. $xml = new SimpleXMLElement("/path_to_file/file.xml", 0, true); // or simplexml_load_file if you insist foreach ($xml->row as $row) { echo "{$row->name} is {$row->age} years old<br>\n"; } See how easy that was? As for the actual problem, try it out on a regular array (which has the same problem that objects do). echo "<pre>"; print_r(object2array(array("name" => "Happy", "age" => 20))); echo "</pre>";Now try to understand what it is doing:1. Is $object an array? Yes. foreach over it and call object2array on each member. 2. Is $object["name"] an array? No. Call get_object_vars on it, see that the return value is no good, and call strval. 3. Is $object["age"] an array? No. Call get_object_vars on it, see that the return value is no good, and call strval. It's assuming that every single value nested within the $object is either an object or array. And that's not necessarily - or even likely to be - true. It needs to check a) if $object is an array, or b) if $object is an object, or otherwise c) it's neither. But don't do that. Just use SimpleXML like it's supposed to be used. Objects aren't scary. They won't bite.
×
×
  • 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.