Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Yup. So is this still a question about how to do the check using PHP code? (What about the code I posted?) Or something else?
  2. This is definitely not a job for a regular expression. Is there any particular reason you want to use one? Because the normal answer is $valid = ((ip2long($ipaddress) & ip2long($netmask)) == ip2long($ipaddress));
  3. Where are you sending the email? Where are you loading the email template? Where is the email template located?
  4. So you're concerned that someone can mess with your URLs and put all sorts of bad stuff into the "id" value? Honestly, I think it's better to treat invalid values (like "--35") as invalid values, not try to somehow force them to be valid. Take the same action you would as if someone entered "id=foo" or "id=" or removed the id entirely.
  5. If that "Cannot modify header information" error message was referring to the setcookie() line then that's your problem: you can't call it after there has been any output. Rearrange your logic so that you set the cookie before beginning output. Oh, and your code says "clicked_twice" in some places and "used_twice" in others.
  6. Why did you remove the slashes from the JSON string?
  7. After you change the function to be preg_replace_callback, you also have to change the second argument to be a function and not a mere string. The simplest way is to use an anonymous function like function($matches) { // ... } $matches will be an array just like how preg_match() works, what with [0] being the full string and [1] being a captured group. Inside this function you call constant() and return whatever you want the replacement to be. Give that a shot. If you still have problems, post the code you tried.
  8. That means your query failed (the boolean is false). What does mysqli_error say? How can you be sure that $project_id has a value?
  9. Yup, that would work too. If the BetaKey isn't unique (and isn't supposed to be) then you should add a LIMIT 1 to the query so that it stops searching for matching rows after it finds the first one.
  10. mysqli_query will return a resource representing a resultset which you can use to access the data returned from the query. It does not return actual values. You have to use one of the assorted fetch functions to get those.
  11. I just noticed some mistakes in the code you posted that would (should) have caused your script to crash. Please code your complete code without any modifications.
  12. Apache is probably doing it (if not your browser). The exact behavior isn't as important as the fact that it is being handled without causing problems, even if that means by Apache and not the PHP script.
  13. Exactly what does console.log(data);show?
  14. Please use code tags instead of copying code from your editor and putting it directly into your post, like by using the button. It's much easier for us to read that way than to deal with whatever formatting you might have set up. I've done it for you this time, please remember to do it yourself next time. Now, the title says something about you having trouble? If you have a specific problem then it'd be great if you described what that problem is, rather than ask us to just look around for what it might be. For example, are you not sure how to make your search form do an actual search? What have you tried and how did it not work?
  15. The dates are stored in data, which is actually an array of dates so I don't know what you'd want to do if it returns more than one set of dates (if that's possible). data[0].qstartDate data[0].qendDate
  16. I can't tell if you actually assigned values to all those variables. You have something that outputs an error in case of failure. Did it output an error? What did it say?
  17. Your question was "This site has PSN codes that [look like they] change every time. How do I make those codes?" Your question was not "This site distributes PSN codes. I want to do that too. Here is how I plan to get the codes and how I want to offer them to the users: [...]. How do I do that?" You have codes. Two things come first: 1. Store those codes in a database. You'll need to know the code, the amount, and whether it's been used. You'll probably want to track other information like the IP address of the person who claimed it, when they claimed it, maybe a SKU or barcode or whatever of the actual product you bought (for record-keeping), etc. 2. Build some way for you to enter new codes. If you already have an admin-type area on your site, that would be a great place. You'll want to add new codes as well as look at existing codes, check usage, and maybe create some reports like how many have been used and by whom. As for the way for a user to get those codes, how are you going to offer (aka subsidize) them? Referral programs? Whose? Or do something else?
  18. Yeah, that's not how PSN codes work. Your site would have to buy the codes (from wherever) and then... what do you want to do, just give them away? These sites do it by using advertising and affiliate programs to recoup the money spent. It's not free.
  19. The relevant bit in there is either function topic($data, $forum_data, $other_data, $inforum) { $topicc = IPSMember::load( $data['starter_id'] ); $lastp = IPSMember::load( $data['last_poster_id'] ); $starter = IPSMember::makeNameFormatted( $data['starter_name'], $topicc['member_group_id'] ); $lastposter = IPSMember::makeNameFormatted( $data['last_poster_name'], $lastp['member_group_id'] ); $data['starter'] = IPSMember::makeProfileLink($starter , $data['starter_id'] , $topicc['members_seo_name']); $data['last_poster'] = IPSMember::makeProfileLink($lastposter, $data['last_poster_id'], $lastposter['members_seo_name']); return parent::topic($data, $forum_data, $other_data, $inforum); }or function asForumTopics($data) { $topicc = IPSMember::load( $data['starter_id'] ); $lastp = IPSMember::load( $data['last_poster_id'] ); $starter = $this->caches['group_cache'][ $topicc['member_group_id'] ]['prefix'].$data['starter_name'].$this->caches['group_cache'][ $topicc['member_group_id'] ]['suffix']; $lastposter = $this->caches['group_cache'][ $lastp['member_group_id'] ]['prefix'].$data['last_poster_name'].$this->caches['group_cache'][ $lastp['member_group_id'] ]['suffix']; $data['starter'] = IPSMember::makeProfileLink($starter , $data['starter_id'] , $topicc['members_seo_name']); $data['last_poster'] = IPSMember::makeProfileLink($lastposter, $data['last_poster_id'], $lastposter['members_seo_name']); return parent::asForumTopics($data); }I don't know whether you made any changes to the plugin so I won't comment on that, but the two lines involving $lastposter $data['last_poster'] = IPSMember::makeProfileLink($lastposter, $data['last_poster_id'], $lastposter['members_seo_name']);(both identical) are definitely incorrect. $lastposter is always a string (a display name) so $lastposter['members_seo_name'] will not work. They should be using $lastp instead as that's the array of information about a user. $data['last_poster'] = IPSMember::makeProfileLink($lastposter, $data['last_poster_id'], $lastp['members_seo_name']);
  20. I would think a simple '//script[@src="http://www.mar.com/network/abc.js"][@async]'should work fine.
  21. Use code tags when posting code (or stuff like that PHP output). I've done it for you this time, please do it yourself next time. Assuming you're using mysqli, take a look at the documentation for examples on how to call stored procedures. If you aren't, the process and code will likely be very similar.
  22. Here's something that should work a little better. 1. Rewrite all requests to directories to go to your indexing script. RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ my-awesome-php-script.php [L]2a. Theoretically, as long as you don't do anything more complicated than that, the DOCUMENT_ROOT + REQUEST_URI will be the directory requested. In practice it might not be - it could be my-awesome-php-script.php itself, for example. So $path = $_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"]; if (!is_dir($path)) { // invalid path } // show files in the $path directory2b. It's possible someone could somehow (don't worry about trying to imagine exactly how they do it) manipulate the path you check. This is where you deal with . and .. and then make sure that the final resulting path is allowed. Easiest way is to work with just the REQUEST_URI by replacing /./ with / (string replacing can do this), as well as replacing /foo/../ with just / (regular expressions will make that much easier) and then making sure there aren't any ..s left in place.3. After step 2, let's say you have $requesturi = "/" . trim($_SERVER["REQUEST_URI"], "\\/") . "/"; // clean up slashes $requesturi = str_replace("\\", "/", $requesturi); // windows' slashes -> regular slashes $requesturi = str_replace("/./", "/", $requesturi); // remove . components $requesturi = preg_replace('#/[^/]+((?R)+|/)\.\./#', '/', $requesturi); // recursively remove .. components $requesturi = preg_replace('#//+#', '/', $requesturi); // repeated slashes // if there are any more ..s then the path is trying to go above the DOCUMENT_ROOT if (strpos($requesturi, "/../") !== false) { // invalid path } // the path is relative to the DOCUMENT_ROOT $path = rtrim($_SERVER["DOCUMENT_ROOT"], "\\/") . $requesturi; if (!is_dir($path)) { // invalid path } // show files in the $path directory The "base" directory is according to the REQUEST_URI (which was cleaned up to $requesturi) and you would use this when constructing links. foreach (scandir($path) as $file) { $filepath = $path . $file; $uripath = $requesturi . $file . (is_dir($filepath) ? "/" : ""); // trailing slash. not required but helps distinguish files vs directories [code] If you gave listings for . and .. then they should get special treatment: don't show .. in the root directory, leave the link alone for just ., and remove a directory for .. (All the code is untested but should be at least close to accurate.)
  23. Yes, but you should do a bit more than that. Like validate the path: make sure it doesn't go places you don't want it to go (like via a "../"), and make sure the path exists before trying to call scandir() because that's the polite thing to do. And to be honest, $num_items = 3; $split_uri = explode( "/", $uri, $num_items ); $uri = "./" . $split_uri[ $num_items - 1 ];that bothers me. Why 3? What were the two items before it? Will those change? Can you just use $_GET or even the entire query string instead?
  24. The REQUEST_URI is the raw URL sent. Spaces will be encoded as %20 (and other characters will be encoded too). So you'll need to decode it before you can use it.
  25. I feel iffy about making changes to $_GET and $_POST. How about making a copy and modifying that instead?
×
×
  • 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.