Jump to content

requinix

Administrators
  • Posts

    15,053
  • Joined

  • Last visited

  • Days Won

    413

Posts posted by requinix

  1. Two options:

     

    a) Compare using timestamps. If you're only doing this in PHP then sometimes that's easier, and the fact that it's just straight numbers makes it easier to understand.

    $renewaldate = time();
    if ($organisationsize == "Up to $3M" && $membershipyear = '2016' && $renewaldate >= mktime(0, 0, 0, 2, 15, 2016)) {
    b) Compare using date strings. There are three conditions you must satisfy for this to work:

    1. Reading left to right, each number in the string (eg, hour, month) must be a larger unit than the next. So you can do year/month/day (year>month>day) but not year/day/month (year>day

    2. Every component must be a number, and each number must be padded (with zeroes) to the largest length. For example, days can max out at two digits long, therefore every day must be padded to two digits. So no 'D' (day name) or 'j' (unpadded day number).

    3. Both strings must use the same format string. You can't compare YYYY/MM/DD with YYYY-MM-DD.

    In practice that means you'll probably use one of two formats: YYYY-MM-DD ("Y-m-d") or YYYY-MM-DD HH:MM:SS ("Y-m-d H:i:s"), and the exact separator character doesn't matter.

  2. When someone has gone to that much trouble to hide code it is pretty much always a backdoor hacker script.

    Either an exploit, or legitimate code that a seller wants to "protect" from prying eyes.

     

    blmg2009, there's good news and bad news. The bad news is that we can't help you decode something that's under license, which the stuff you posted is. (Normally I would remove licensed code, but what you posted isn't... well, it's harmless to have exposed.) The good news is that you want to understand how it works, not to break it apart. A fine line indeed.

     

    It's a horrible practice and wastes system resources doing a lot of stupid work, but some people think it's what they have to do to protect their code. Maybe they don't know much about licensing, or maybe they think it's truly effective, or what else I don't know. But the basic idea is to be able to give someone some code that works without being readable by a human.

    With PHP that's typically some combination of base64_decode() and gzinflate() that ultimately produces some code which can be eval()ed. Do that over and over again and eventually you get actual code that does actual stuff. It's like layers of an onion, except peeling onions isn't as painful.

    • Like 1
  3. The nginx server needs to be listening on your LAN address too. As in 192.168.1.x.

    And the port for the firewall rule is the one that nginx uses. 8080. Your computer doesn't know anything about what the router is doing.

     

    i just added a rule in firewall for port 80 to be public, but i noticed there is a few other things that operate on port 80 in my firewall....so should i make it unique?

    What do you mean? What things? Make what unique?

     

    If there isn't already a rule set up for nginx then you'd need to make one: make a new firewall exception for a particular program (and find nginx.exe or whatever) so the rule doesn't grant access to everything, then allow access to port 8080 and any remote host.

    • Like 1
  4. There was a problem where all new users were required to have admin approval to validate an account. This has been changed back to something reasonable.

     

    New users from here on: upon registration you should receive an email. Please follow the instructions to approve your account.

    Existing users who are unapproved: click the Resend link in the top-right to get the email. Follow those instructions too. Should work.

  5. So you're seeing that "thank you for your email" message but not receiving the email? Did you change anything after taking the code from the original test script (where you got the email using PHPMailer) and copy/pasting it into the script that handles the contact form? And I assume the values for Username and Password and From are all correct in your real code and you edited those just for posting it here?

  6. Alright.

     

    Use a DateTime for the chosen date and diff it to starting date. That will give you a DateInterval which can tell you how many days are between the two dates. Since you don't care about the number of cycles between the two dates (k from before) all you have to do is use modulus to get the day number (d). Which needs a bit more of an explanation.

     

    Say the diff is 108 days. The most obvious course of action is to +1 (because the starting date is day #1 and not day #0) and %15 to get 4. That's not quite right.

    Say the diff is 14 days. Smaller number. +1 is 15 and %15 is 0. That's not right: you need to get 15 and not 0. You could say "if result == 0 then result = 15" but there's an easier way:

    ($diff % 15) + 1
    What you're actually doing is taking the diff, +1 because of the starting date, then doing a trick where you -1 then %15 then +1. Watch:

    (14 % 15) + 1 = 15
    which is the result you wanted. And

    (108 % 15) + 1 = 4
    like before.

     

    $pattern = 15;
    
    $start_date = new DateTime("2015-12-14"); // day 1
    // Day 15 = 2015-12-29
    
    $chosen_date = new DateTime("2016-03-30");
    
    $difference = $chosen_date->diff($start_date)->days;
    
    $day_number = ($difference % $pattern) + 1;
    
    If($day_number == 13 || $day_number == 15) {
    Echo "possible outcome. Day $day_number.";
    }
    Else {
    Echo "not possible, day $day_number";
    }
    • Like 1
  7. Okay, so I think I figured out what you want.

     

    $start_date is the first date. You may have picked it arbitrarily, I don't know. 14 days later is the end of that cycle (1+14=15), and 15 days later (2015-12-30) is actually day 1 of the next cycle.

     

    Now you have a $chosen_date. That's going to be 15 * k + d inclusive days between it and the starting date, where k is the number of complete cycles between them and d would be the day number. As an example, with 2015-12-31 it's 17 = 15 * (1) + (2), meaning 1 complete cycle and the date is day #2 in the cycle.

     

    If the chosen date is 2016-03-30, that's 108 days later or day #109 (1+108) of the cycle. 109 = 15 * (7) + 4 and so the date is day #4 of whatever cycle.

     

    Right?

  8. Yes, that's the code. Currently it says "if not using HTTPS then redirect to the https:// version of the page". That needs to be modified to say

    If not using HTTPS and the page does not match that one OpenBay pattern then redirect to the https:// version of the page.

    To get that new condition you can use

    RewriteCond %{REQUEST_URI} !^/index.php?route=ebay/openbay/
    (which assumes that this site is not located in a subdirectory underneath the domain) added next to the existing RewriteCond.
  9. There is so much more to doing emailing properly, and so many ways it can go wrong.

     

    Do yourself a favor and get yourself a copy of PHPMailer. (There are other things but it's the most popular.) There are tons of examples and plenty of documentation on how to use it, and it will take care of everything for you.

    • Like 2
  10. As mentioned earlier, mysqli_stmt::get_result() is only available with the mysqlnd driver. If you don't have that method then you are using the old libmysqlclient, which is unfortunate. If you keep with the mysqli extension then you'll have to go the long way to get results, meaning bind_result() and fetch() and all that.

     

    Speaking of that, your problem with $user. mysqli_stmt::fetch() only returns true/false/null as to whether there were any more results to fetch. To get actual data you need to bind the result values to variables, just like how you bound input values to variables. Each time you call fetch those variables will be updated with appropriate values.

  11. var page = a column in a html table

    No, it's a float value.

     

    This searches within a range - like above.  I need the search to search outside of the range.  So if min and max entered values are 3-7...and page column holds 1-10.... 1,2,3,7,8,9 should return

    Okay. Like I said: you have a function that returns true if something is inside the range, so it should be a simple matter to make it return true if something is outside the range. Change your comparisons so that the page value is = max.
  12. Using strictly PHP and GD? Well yeah, sure it's possible, but here are all the GD functions available to use and none of them do what you want. Meaning you'd have to do the edge detection* or masking yourself.

     

    Bite the bullet and use something like ImageMagick instead. It does come as a PHP extension but more commonly you invoke the command-line program. It's powerful and I'm sure it can at least do the second method, if not both.

     

    * GD can do edge detection, where it creates an image showing edges, but it won't work for arbitrary points on an image so you couldn't rely on it.

    • Like 1
×
×
  • 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.