Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. It's the ternary operator and works like if (isset($mValues['Result'])) { // X ? ___ : ___ $temp = $mValues['Result']; // ___ ? Y : ___ } else { $temp = 0; // ___ ? ___ : Z } $Result = $temp;
  2. There's no opening <?php in what you posted. It's not the complete script.
  3. "Same trouble" meaning that even with your AcceptPathInfo off, requests to files such as the ones OP mentioned are still being sent to your CGI-handled PHP scripts?
  4. // use sessions session_start(); // if the form was submitted if ($_SERVER['REQUEST_METHOD'] == 'POST') { // if they clicked the YES button if (isset($_POST['YES'])) { // this script supports a ?return= in the URL for where to return the user // default of whatever the current "directory" is (like /foo/verify.php -> /foo) $redirect = isset($_GET['return']) ? urldecode($_GET['return']) : './'; // also supports a custom expiration time (in seconds) // default of "only during this session" $expire = isset($_GET['x']) && is_numeric($_GET['x']) ? intval($_GET['x']) : -1; // only lasts during this session if ($expire == - 1) { $_SESSION['verified'] = "yes"; header("location: " . $redirect); exit(0); } // cookie that doesn't expire for a long time if ($expire == 0) { setcookie("verified", "yes", mktime(0, 0, 0, 01, 01, date("Y") + 30)); $_SESSION['verified'] = "yes"; header("location: " . $redirect); exit(0); } // otherwise a regular expiration time setcookie("verified", "yes", (time() + $expire)); $_SESSION['verified'] = "yes"; header("location: " . $redirect); exit(0); } // clicked NO else { header("location: http://www.youtube.com/watch?v=gppbrYIcR80"); exit(0); } } ?> ... // checks that the user has verified themselves already function verified(){ $redirect_url = 'http://www.YOURSITEROOT.com/verify.php'; $expires = - 1; session_start(); $validated = false; // different cases to check for... if (!empty($_COOKIE["verified"])) { $validated = true; } if (!$validated && isset($_SESSION['verified'])) { $validated = true; } if (is_numeric($expires) && $expires == - 1 && !isset($_SESSION['verified'])) { $validated = false; } if ($validated) { return; } else { $redirect_url = $redirect_url . "?return=" . $_SERVER['REQUEST_URI'] . "&x=" . $expires; Header('Location: ' . $redirect_url); exit(0); } } verified(); ?>Code's a little amateurish, a little buggy, and could definitely benefit from formatting and indentation.
  5. The thing you posted doesn't have any HTML stripping so... can't really say. There being such a thing would explain what you're experiencing, but without the code it's anybody's guess where that's happening. Follow the path the code takes, where $strHtmlOutput goes from that point to where it's put into the email. Put some echos or logging statements or something so you can find out where the HTML is being stripped.
  6. You can't do it just by editing XML. There has to be some code somewhere to handle the translations. I would structure the XML like <?xml version="1.0" encoding="utf-8"?> <home> <translation lang="en-us"> <firstHeader>Welcome to my Site</firstHeader> <firstParagraph>You are here because your not there.</firstParagraph> <secondParagraph>You are Ugly because we are beautiful</secondParagraph> <thirdParagraph>If there no ugly people then there is no beautul people.</secondParagraph> <question>Make sense right?</question> </translation> <translation lang="leet"> <firstHeader>VV3|_(0/\/\3 70 /\/\`/ 5173</firstHeader> <firstParagraph>I don't have the patience to translate the rest of them</firstParagraph> <secondParagraph>An insult</secondParagraph> <thirdParagraph>Some kind of justification for you not killing yourself even though you're so ugly</thirdParagraph> <question>Is your site full of snobs or is it just you?</question> </translation> </home>
  7. Like people languages? You find somebody fluent in both English, whatever grammar you're using there, and the language you want it translated into, then ask/hire them to translate it. You can't automate it.
  8. It won't. I'm saying that you can't simply hide that information from the user. The browser and the user are the same thing: you cannot treat one differently than the other.
  9. Now that you've posted your password on a public forum, Shiva, you should go change it.
  10. On the right track but that's probably (evidently) not enough. What's the rest of your code?
  11. Not possible. Any link that your site uses, even if it's not shown visibly to the user, would work for anybody else who tried it. Instead don't link to the files directly. Link to a script which downloads (or whatever) the file to the user, but only does so if they're logged in and have access and whatever other criteria you require. You don't even have to camouflage the links then: it doesn't matter if they try to mess with it because they can't touch how the script works.
  12. Another option is explode() and array_chunk(). $words = explode(" ", $text_to_scan); $records = array_chunk($words, 18);
  13. That's just a regular query string. 63 would presumably be the ID number of the post to display. Those are definitely not real folders. URL rewriting
  14. requinix

    Connection

    What does an EXPLAIN of it return? I'm guessing tmp_price_compare doesn't have any indexes either? And why are you using a not-actually-temporary temporary table for this?
  15. And that's the problem: the part you're using is the one I wrote to try to make it more obvious how your code was working. Working incorrectly. The second thing I posted is what you're supposed to use, but you can use variables (like how I did in the other) if you want to make it easier to read.
  16. No, what I said is technically true. Read it again: I didn't say they're executed first, I said they have higher precedence. Meanwhile you are also correct about that not affecting the order of evaluation and about short-circuiting. [edit] If && did not have higher precedence than || then your test script would not output "B". echo (true || true && false) ? "Y" : "N"; // normal echo ( (true || true) && false ) ? "Y" : "N"; // forced || >= && echo ( true || (true && false) ) ? "Y" : "N"; // forced && > || YNY
  17. Please use [code] tags when posting code. if (($_FILES["fileToUpload"]["type"] == "audio/mp3") || ($_FILES["fileToUpload"]["type"] == "audio/wav") || ($_FILES["fileToUpload"]["type"] == "audio/mpeg") && ($_FILES["fileToUpload"]["size"] >= 26214400) && ($_FILES["fileToUpload"]["size"] <= 70000000) )Operator precedence. && has higher precedence than ||, meaning a || b && c works like a || (b && c). Rearranging your code, $mp3 = ($_FILES["fileToUpload"]["type"] == "audio/mp3"); $wav = ($_FILES["fileToUpload"]["type"] == "audio/wav"); $mpeg = ($_FILES["fileToUpload"]["type"] == "audio/mpeg") && ($_FILES["fileToUpload"]["size"] >= 26214400) && ($_FILES["fileToUpload"]["size"] <= 70000000); if ($mp3 || $wav || $mpeg) {Use parentheses to change that behavior. if ( (($_FILES["fileToUpload"]["type"] == "audio/mp3") || ($_FILES["fileToUpload"]["type"] == "audio/wav") || ($_FILES["fileToUpload"]["type"] == "audio/mpeg")) && ($_FILES["fileToUpload"]["size"] >= 26214400) && ($_FILES["fileToUpload"]["size"] <= 70000000) )
  18. Don't use regular expressions to sift through HTML. Use a real HTML parser like DOMDocument, which then lets you use DOMXPath. Like $dom = new DOMDocument(); $dom->loadHTML($str); $xpath = new DOMXPath($dom); $nodes = $xpath->query("//tr[@class='category']/td[@class='category']/a"); foreach ($nodes as $node) { echo $node->textContent, "\n"; }
  19. That tiny little bit of code you posted will work, but only if you surround it in some more code that uses it properly. What is the rest of the code?
  20. Allow me to interrupt and restate what I said before: don't store the username. The user information is already in your database so I can only assume there is a user ID too. The primary key of that user table. Store that.
  21. Store the user along with the data being entered. Remember to use a foreign key and not the actual username.
  22. Then you'll probably have to make your own function to deal with it. Since the problem is simply finding the number of leading 1 bits I'd just go with a function to do both IPv4 and IPv6 that gives you exactly the result you need. Means you don't have to parse the address for real, simply count how many 1 bits you find until the first 0. "Simply". Thing is that there are a few valid formats you'd have to account for: pieces not having all four hex digits, omitted zeroes with a ::, a trailing IPv4 address... Unless you can restrict the input.
  23. Sort by the time descending and change your headings in code when the corresponding date changes. $date = empty foreach ($row found) { if (date from $row != $date) { $date = date from $row echo new date heading } echo item }If your dates are grouped using something that needs beginning and ending output (like a beginning and ending ) then use a slightly more complicated $date = empty foreach ($row found) { if (date from $row != $date) { if ($date is not empty) { echo ending output } $date = date from $row echo new date heading and beginning output } echo item } if ($date is not empty) { echo ending output }
  24. It should work for IPv6 too. Maybe your PHP doesn't support it? var_dump(defined('AF_INET6')); // true=has support, false=no supportWhat do you get when you try? Would be a warning and a result of 0.
  25. Do you want to show all the *.pdf files? There's a much simpler way to do this: <?php $files = glob($d . "/*.pdf"); foreach ($files as $f) { echo "<a href='{$f}'></a><br />"; } ?> glob For just one type of file use (eg) "/Catalog_*.pdf". Otherwise if it's literally those four types (and you want them all together) then same as above but using $files = glob($d . "/{Catalog,Calendar,Schedule,Newsletter}_*.pdf", GLOB_BRACE);
×
×
  • 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.