Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. RSA deals with modular arithmetic, so the standard functions aren't useful. The meaning of "power of -1" is also different, as here it refers to an inverse in modular arithmetic, rather than an inverse in real arithmetic. Consider that in real arithmetic, a^-1 is the number such that a * a^-1 = 1. This is easy to find in real arithmetic, as it's just 1/a, giving a * 1/a = 1. But in modular arithmetic, it's much more difficult to calculate. What you want is the integer b such that a * b (mod n) = 1. For example, the inverse of 2 in mod 5 arithmetic is 3, because 2 * 3 (mod 5) = 6 (mod 5) = 1. Anyway, the place to start if you want to implement RSA is learning modular arithmetic.
  2. The advice is free, but it doesn't come fast. I only check this site once a day (unless I've got nothing else to do), so you can expect 24 hours between each response from me. If you want someone to write code for you, then you can make an offer in the freelancing section of the forum. Regarding "include", what it does is add another page into your page as if it had been called directly. It's often used to choose between different pages based on a GET value, as in teng's second example. If you haven't already, you can try out his code and see what it does. You'll need to have news.php and article.php in the same place as index.php
  3. When you start paying us for advice, that's when we start delivering on time Until then, be happy that we even respond. Teng's code looks good. Once you've solved 1 with that, you might find the solution to 2 is clear. Oops, teng that is "switch" not "swithc"
  4. Please post your code (if any). It sounds to me like you want include("$page.php"); (after verifying that the value of $page is allowed). I'm having trouble understanding your question 1 though. For question 2, you can have a default template directory, and have your scripts use that if they cannot find a specific template. Is that the kind of thing you're looking for?
  5. Probably a silly question, but can't you generate the map after unfolding instead of generating it on a sphere and then unfolding?
  6. Is the specification something like "Produce n equally spaced numbers starting at x and ending at y" ? My first impression is that you may be having rounding problems. I notice that you set $curredit[1] using number_format(), and then you use that value in a computation later. It's probably better if you use the original value (not formatted) for calculation, and only format for display. You may find that the problems disappear after that.
  7. inter, have you used arrays? Multi-level arrays? String-indexed arrays? They are very powerful. Arrays let you store large quantities of data in one place. They also let you sort that data, and then display it in the sorted order. String indexed arrays let you look up data by a key of some sort. In cooldude's example, he uses date as the key. This allows you to instantly find all data for a date just by accessing $data['2008-01-01'], for example. So if you're not familiar with arrays, it's time to start
  8. Try `key` with backquotes around it.
  9. Thanks, just wanted to make sure I wasn't missing anything
  10. What do you mean by "I need to view all the images" ? Do you want to display them on a website? As thumbnails?
  11. 30 seconds? You should thinking in milliseconds. A function calling itself (recursion) is probably the easiest way to go about it. Is it a requirement that the output be valid php code?
  12. See this script: <?php $a->val = 1; f($a); function f($a) { $a->val = 2; } var_dump($a); ?> So it just passes an object and alters it inside. Run it under php 4 and you'll find the output is 1, but run it under php 5 and the output is 2. The point is that php 5 passes objects by reference, but php 4 passes them copy-on-write. Since you seem to be using objects to store data only, you might want to use an array instead of an object. Arrays will still be passed copy-on-write even in php 5.
  13. The order should be SELECT, FROM, LEFT JOIN, WHERE. The WHERE can't go before the FROM and the LEFT JOIN.
  14. How about this situation? SELECT * FROM t1 LEFT JOIN t2 ON (t1.id = t2.id) WHERE t1.name = 'fenway' AND t2.something IS NULL In postgresql at least this will usually be an index scan on t1.name = 'fenway', followed by an index scan on t1.id = t2.id (implementing the left join), and finally a filter on t2.something IS NULL.
  15. Ok I had a think about this. A condition applying to the left side of the join can be applied first, but a condition applying to the right side will need to applied afterwards. Does that sound right? The other day I was helping someone with a left join in mysql where there was no matching index on the right hand table. The solution we used was to apply the condition on the right table in a subquery, and then left join with the subquery. Before we did that, it was generating the entire result set and filtering, which was so horrible that it timed out.
  16. You should submit $_SERVER['REMOTE_ADDR'] to the table. There's a lot of other stuff in the $_SERVER array that you don't need. As for comparing it, the keyword is "geolocation". Google will give you mountains of results for this. It can be done in SQL in many ways, one of which is storing the lowest and highest ip of each range along with its country. To generate that table you'll need a geolocation database.
  17. Can you post your current code? Then we can suggest how to alter it.
  18. I assume it's not example.com in your real code? Which version of php is this? There's a note here about problems caused by IIS running on the server.
  19. I think that code of 127 is generated by the shell itself. If you try to execute a program that doesn't exist, then of course no program will be executed. If no program is executed, what is the exit status of the program that didn't run? There is none. So the shell creates a "dummy" exit status of 127, to allow scripts to know that the command failed. To replicate this in php, you would have your child return the dummy status of 127 of the exec fails.
  20. I don't think there is .. if there was, it would be mentioned in the pcntl documentation somewhere. You can use the signal constants though, like SIGSTOP, SIGHUP, etc etc. For exit status, that is defined by the application, so there is never a standard string representation of that.
  21. It doesn't use the where clause until the end? What do you mean by that?
  22. I realize my example is over-simplified, but so is the explanation given in Wikipedia. If you look at a simple example of a cpu capable of handling 1 processes per minute but being given 2 per minute, it'll go like this: 1 process runs, 2 added, 1 waiting 1 process runs, 2 added, 2 waiting 1 process runs, 2 added, 3 waiting and so on .. the run queue will be increasing constantly. Yet a single additional cpu will enable the machine to process the entire run queue. In terms of a snapshot at a single moment (say, when 10 jobs are in the queue) then yes, you would need 10 additional processors to clear the queue within 1 minute. But that doesn't mean you need 10 additional processors to run the same processes with a constant load of 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.