Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. You say it's a DNS problem but it sounds more like a firewall, in which case yes you'll need an SSH tunnel. (If it really is a DNS issue then that's easily addressed and you don't need a tunnel.) man sshThere's a -i option where you give the path to your key file. If you don't have it then ask the friend for it, who can also help get you connected to the server. PuTTY? That's just a GUI for SSH - you still have to provide the same information, port forwarding configuration, and SSH key.
  2. You can always filter out information you don't want care about, but if you want to see it and it's not there you can't somehow make it appear. Add a new record every time they view. Then you can look at anything you want to look at: overall statistics, "unique" views, etc.
  3. Don't bother checking that - just add the new record. It's okay to have more than one row for it. Plus you get a record of every time the user visited, not just the first time.
  4. 1. It can do either. Or both. IRC servers do both: send a chat message to all clients, and send a user-specific message to a specific client. 2. You delve into multi-threading. Briefly, when the server accept()s it creates a new thread to handle the client, and the server immediately waits for the next connection. Meanwhile the new thread does whatever it is supposed to. The main thread and the new thread can communicate with each other too. To manage the number of connections, the server stops accepting connections when it has too many child threads/connections active. 3. I don't know what you mean by "make live". Don't know what you're trying to say there either. What you have there is the standard pattern for a single-threaded server/client architecture. A "better solution" would be multi-threading.
  5. Port forwarding to what end? Actually I'm not even sure you want port forwarding at all. Port forwarding in SSH is a matter of using your SSH connection to let your machine communicate with the other machine when things like firewalls or NAT would normally get in the way. For example, you could forward your local port 2211 to the www2.mydomain.org machine's port 80, then http://localhost:2211 would work the same way as if you had browsed to http://www2.mydomain.org. Or local 80 to remote 2211 would make http://localhost work like http://www2.mydomain.org:2211. So... did I describe what you want to do?
  6. Even though the code can be fixed (it's also particularly... wordy) yes, you should go to that new table. function getBlogTags2() { $db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $sql = "SELECT tags FROM `" . TABLE_BLOG . "` ORDER BY RAND() LIMIT 1"; $row = $db->fetch_array($sql); return explode(",", $row["tags"]); }So to be clear, this will get 5 random tags (however not in random order) from a single randomly-chosen blog post.
  7. Try this: Solution for what? What case? Filename, okay, but what about the filename case? Get what done? SOLUTION FOR WHAT?
  8. As long as you agree that you need another table, You "have" to do it in your code. Use a query to get the posts and tags, explode() to get each tag, then array_rand to get (the key of) a random value.
  9. That's a problem. You need to use a separate table that has the post ID and the tag ID/name, with one post getting multiple rows for multiple tags. post_id | tag --------+---- 123 | john 123 | carlos 123 | the great tag 123 | this is a tagOnce you have that the rest should be easy(ier). Though I'm not sure what you mean by getting random tags from each post... A single random tag? All posts or one at a time?
  10. Please use tags when posting code. if(isset($_POST["password"])) { $password = $_POST["passwords"];Second line is looking for the wrong thing.
  11. When you modify $line you don't actually modify $lines too. Just a copy of $line. $lines[$n] = preg_replace('/code(\s+code)+/i', "code", $line);Surprised you forgot that since it was brought up in another thread and you had the right code there.
  12. Are you using the same username and password in phpMyAdmin that you are in your code? Find your php.ini and change two settings inside: error_reporting = -1 display_errors = onThen restart Apache, try your script again, and see if you get any error messages.
  13. Wtf happened to create all those "code"s? Regular expressions are case-sensitive by default. Use the /i flag to stop that. While I'm here, you don't need to use a loop for this. <?php $string = 'You have a code CODE code of ethics'; $string = preg_replace('/code(\s+code)+/i', "code", $string); // "code" and one or more of (whitespace and "code") print $string; ?>
  14. How did you upload the files in the first place?
  15. Either you missed that I said "replace (w/ wheel)" and not to replace everything w/*, or you just contradicted yourself when you said earlier
  16. What about replacing "(W/ wheel)" with "(W/ TIRE)"?
  17. That's related to sessions and happens during the saving (during shutdown). It means you used a numeric key for a session value, like $_SESSION[2996699736] = "some value";[edit] Yeah. That.
  18. It'd be nice if you spent the bit of time it takes to write a description of your problem, rather than just use the one-line title to cram everything in. Leaves us with questions like "What problems with your while loop?" As for the other issue, Putting aside the malformed HTML, You can't put a button inside a link. Pick one. However if you need to pass a value then you can use a like DeleteTo make that work, though, you need the current script (the one that handles editing) to support deletes too - can't have a form inside a form, and shouldn't try to switch the action of a form based on a button. There's HTML 5 stuff you could do, actually, but I probably wouldn't.
  19. Sometimes it takes more than an hour to get an answer. It'd be easier to check for any items that are not Dispatched than to check that all items are.
  20. I blame my sick boss for making me sick too and thus not quite in my right mind. But at least I did get the $n=>.
  21. If you used file_put_contents instead of fwrite(), you'd have yourself a winner. But I'd do it a bit differently: $lines = file("animals.txt"); foreach ($lines as $n => $line) { if (stripos($line, "cat") !== false) { $line = rtrim($line) . " Be careful with cats!" . PHP_EOL; } } file_put_contents("animals.txt", $lines);If the file was much larger, though, (and 100MB may be too large already,) you'd need to use a different tactic: you'd run out of memory to store the entire file in PHP's memory.
  22. Why not? You say "should look at the previous entry" I would expect that looking at the times would be the best way to do that. If you're not using an auto_increment column already then you can add one as part of a composite key like (account_id, entry): the will count from 1 per account_id, so you'll know for a fact that the previous entry was (account_id, current entry-1).
  23. Does it actually have to be an , or do you only want it to look like a link? And I take it that means you don't want the image anymore and will be using some plain text instead (eg, "Continue")?
  24. Use CSS classes. Put all the HTML you want into the header thing: the image as one thing, the "some HTML content" as another (but put inside a container like a DIV or SPAN). Put a class on each indicating when you want it to show, as in <div id="header" class="has-cookies no-has-cookies"> <img id="headimg" class="cookies"> <div class="no-cookies">(whatever)</div> </div>Create CSS rules like div#header.has-cookies > .no-cookies { display: none; } div#header.no-has-cookies > .cookies { display: none; }1. header is "empty" by default because it has both of the has-cookies/no-has-cookies classes2. Your Javascript removes the has-cookies or no-has-cookies class (whichever shouldn't be there) which causes the appropriate content to appear 3. If they have cookies you also set the headimg image (you should do that before #2) Some of this code looks a bit off so I tried to fix it, including making it use jQuery for real. $( document ).ready(function() { var code = getVar('agent'); if (code) { SetCookie("code", code, 1); } else { code = ReadCookie("code"); } var img = new Image(); var imgsrc = "images/" + code + ".gif"; img.onerror = function (evt) { // $("#headimg").attr("src", "images/no-cookie.gif"); $("#header").removeClass("has-cookies"); } img.onload = function (evt) { $("#headimg").attr("src", imgsrc); $("#header").removeClass("no-has-cookies"); } img.src = imgsrc; });
×
×
  • 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.