Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. I think you'll find it easier to find a C++ string library that does what you want. You could investigate the Boost String libraries, designed to fill in functions missing from STL: http://www.boost.org/doc/html/string_algo.html#string_algo.intro
  2. Since your original image is not continuous, the only way to make a continuous output would be to extrapolate a bit. Maybe you could assume that for all input pixels i1 and i2 which are adjacent in the input, you should draw a line in the output from f(i1) to f(i2).
  3. Let's say your points range from -50 to 100, and your image is 300 pixels wide. $imageWidth = 300; $xMin = -50; $xMax = 100; $xRange = $xMax - $xMin; # That's 150 $xShifted = $xOriginal - $xMin; # Shift so it has a 0 offset $xScaled = $xShifted * $imageWidth / $xRange; # And scale it to the image width, 300 Is that what you were after?
  4. Yes it does. Try it and you'll see
  5. You can still set the include path from your script (it will need to be done in each script). I do it like this, checking to see if it's already there first. You don't need to check if it's already there if you know it isn't. if (!preg_match('|/var/www/www.prioritysubmit.com/webroot:|', ini_get('include_path'))) { ini_set('include_path', '/var/www/www.prioritysubmit.com/webroot:' . ini_get('include_path')); }
  6. Element 0 is always the full pattern matches, and elements 1 and up are the individual matches. That's all there is to preg_match() For preg_match_all(), it depends on whether you set PREG_PATTERN_ORDER or PREG_SET_ORDER. Thay may lead to some confusion.. Basically PREG_PATTERN_ORDER means element 0 is an array of all the full pattern matches, and elements 1 and up are arrays of individual matches. Try var_dump() on an example and it'll make sense. PREG_SET_ORDER is the other option.. you basically get an array of the arrays you WOULD have gotten if you'd run preg_match() lots of times. Just imagine you kept running preg_match() and put all the results into a big array. That's PREG_SET_ORDER. preg_match_all('|(a)(b)|', 'ababab', &$matches); # Default to PREG_PATTERN_ORDER var_dump($matches); preg_match_all('|(a)(b)|', 'ababab', &$matches, PREG_SET_ORDER); var_dump($matches);
  7. regexps don't replace things that are already replaced. So the answer is no.
  8. Your code works fine for me. Did you add an empty line or space before sending the header?
  9. You can translate this as "POST variable 1viscosity was not sent to the script" Note that that's only accurate for your script, it's not a general translation for "undefined index". So you need to work out why it's not sent. The best way to work that out is to look at the generated form, which is what the others are asking for.
  10. Try this: echo '<a onclick="peoplepic(\'' .$ImageName . '\');">';
  11. It is that simple .. I would add a folder called "smarty" under your application folder. Then you will need to set the appropriate settings in your script to tell it where smarty is. Something like require_once('smarty/Smarty.class.php'); The only slightly messy part may be setting permissions on the folders smarty uses for caching and so on. Those will need to exist be writeable. And the other issue is that your bundled smarty will eventually become out of date. But at least you don't have to worry about future releases breaking your script PHP itself has quite a few third party libraries bundled with it, which is how it is able to compile with so many features without installing anything extra.
  12. It's not necessary to have your own php.ini. The system will have a default one. And yes it's quite possible that adding php.ini will have broken the site. In particular, there's a setting called "register_globals" that regularly breaks websites when it is switched off.
  13. I don't quite get that. Let's say $j = pi/2 and $i = 1. That point doesn't exist in the image but let's use it anyway. tan($j/$i) = tan((pi/2)/1) = tan(pi/2) = ???
  14. For example: require_once('child-iframe.php'); If you want to pass data to the child-iframe.php script, just set the variables like this: $foo = 'bar'; require_once('child-iframe.php'); Variable $foo will be available inside child-iframe.php
  15. We'll need to see the rest of your code. The "naechste Seite" link looks correct, so I suspect the problem is in how your code interprets that link. Do you use $_POST? If so, try using $_REQUEST instead.
  16. It creates a reference. You should stay away from these unless you know what you're doing A simple example: $a = 5; $b = &$a; $b = 2; print "a now has value $a\n"; When you make $b a reference to $a, the variables become shared. Changes to either one will affect both. Only one copy of the actual data is stored. PS In general it's a bad idea to use references to try to save memory. PHP already has mechanisms that save memory in most common situations where variables are copied.
  17. Aha, I understand now why you want to lock users out. Locking out users altogether seems primitive to me. This exact problem has been studied for decades in the database realm and in concurrent software development, and many other solutions have been devised. One approach (practiced by Mysql's default MyISAM table structure) is to have more fine grained locking. For example, if one person is editing company details, then no-one else will be allowed to edit company details until that person is finished. This allows multiple logins but prevents multiple updates of the same old data. You can make the locking even more fine grained if you want, by having a lock on only one particular data elemnt. For example, Dave can edit details for ABC Pty Ltd, while Steve edits DEF Pty Ltd. But if Steve tried to edit ABC Pty Ltd, he would be informed that it is already being edited. This will also have to be combined with timeouts and a "lock breaking" mechanism, but will result in much less inconvenience (and much more implementation effort). The other approaches, such as the conflict resolution method used in CVS and the MVCC model from Postgres are probably not appropriate. Finer grained locking feels like the right solution here.
  18. Well there's a semantic issue here .. strings in php don't have any character set. But the final document produced by php has a character set. When the browser makes a request, the server (where php is running) will usually specify which character set to interpret the document in. And that's affected by what effigy mentioned. So what I would say is "PHP does not assume that strings are ISO-8859-1", BUT php does assume that its output is iso-8859-1, and will tell the browser so. That's nothing to do with strings internally in php, which can be in any character set. They are simply data. To show what I mean, consider the following code: $iso8859 = 'é'; $utf8 = iconv('ISO-8859-1', 'UTF-8', $iso8859); The first string is iso8859-1, but the second is utf8. Both are in the same script. And php neither knows nor cares what encoding each is in. That's up to you to take care of. But when you produce the final HTML document, the browser needs to know the encoding. That gets sent with the response headers (and can be changed manually by the user, as you described).
  19. I think your question is far too general. There are just too many ways to implement such an idea. I suggest you do one of the following 1. Start implementing using whatever ideas you have now, and see what problems you come across. Then post back here asking for advice on specific problems. 2. Keep learning more about php. Once you are more experienced, this task will not seem so big.
  20. A simpler way is to have the second login overwrite the first. That is, the first session is disabled if the user logs in again from a second location. The difficult with the "locking out" policy is exactly as you mentioned, detecting a closed browser. If your boss insists on locking out second logins, then you might consider a timeout after which a user is considered to be logged out. That may lead to unfortunate situations though where a user is locked out until their own previous session times out.
  21. PHP actually has a native bool type, unlike some other languages. Internally it's stored as a long int. <?php $hide = ($_GET['hide'] === 'yes') ? true : false; if ( $hide === true ) { echo "ON"; } else { echo "OFF"; } ?>
  22. PHP doesn't have a default character set. It defaults to representing strings as 8 bit characters (256 possible values if you include null), which could represent many different character sets. You can even store utf8 strings as long as you remember that functions like strlen() won't count characters, they will count bytes.
×
×
  • 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.