Re: [PHP] Login

2008-10-08 Thread Bernhard Kohl
http://us.php.net/manual/en/function.include.php
# http://en.wikipedia.org/wiki/Code_injection#PHP_Injection
?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] concatenating with "." or ","

2008-08-27 Thread Bernhard Kohl
tedd wrote:
> There are significant orders of magnitude difference between your results
> and mine.
> For example, it didn't make any difference if you used a comma or
> concatenation, but in my system concatenation was 15 times faster than using
> a comma. Interesting, I would have guessed it would have been the other way
> around.

I refined the test, so that it is more random and therefore maybe more accurate.

Test Results
Results for 2048 cycles of echoing a 32-character string with a random
32-character string 2048 times:
comma Method

Number of Echoes: 536

Total time: 1.57938525391 milliseconds

Average time: 0.00294661427968 milliseconds
concat Method

Number of Echoes: 537

Total time: 2.64919824219 milliseconds

Average time: 0.0049005994 milliseconds
interpol Method

Number of Echoes: 480

Total time: 4.38319873047 milliseconds

Average time: 0.00913166402181 milliseconds
heredoc Method

Number of Echoes: 495

Total time: 3.66322021484 milliseconds

Average time: 0.00740044487847 milliseconds
Results for echoing 128 random 32-character string 2048 times:
comma Method

Number of Echoes: 536

Total time: 817.227 milliseconds

Average time: 1.52467723881 milliseconds
concat Method

Number of Echoes: 537

Total time: 826.971 milliseconds

Average time: 1.53998324022 milliseconds
interpol Method

Number of Echoes: 480

Total time: 3764.781 milliseconds

Average time: 7.84329375 milliseconds
heredoc Method

Number of Echoes: 495

Total time: 540.391 milliseconds

Average time: 1.0916989899 milliseconds

--
For all those who want to try it out, here is the code:
--

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml";>


Test for Tedd


Test Results
 array("total_time" => 0, "count" => 0),
  "concat" => array("total_time" => 0, "count" => 0),
  "interpol" => array("total_time" => 0, "count" => 0),
  "heredoc" => array("total_time" => 0, "count" => 0)

);
$results2 = $results1;
$test_array = array();
$test_string = md5(time()); // a 32 character string
$eval_strings = create_eval_strings();
for ($i = 0; $i < $iterations; ++$i) $test_array[] =
str_shuffle($test_string); // random strings
for ($i = 0; $i < $iterations; ++$i) test_method(rand(0,3));

function test_method($method) {
  $start_time = $end_time = 0;
  $test_array =& $GLOBALS['test_array'];
  $test_string =& $GLOBALS['test_string'];
  $eval_strings =& $GLOBALS['eval_strings'];
  for ($i = 0; $i < 10; ++$i) {
$j = rand(0, $GLOBALS['iterations']);
$test_array[$j] = str_shuffle($test_array[$j]); // change some arr
vals to outsmart any php speedup/cache
  }
  $arr2 = array(); // array for 2nd test
  for ($i = 0; $i < $GLOBALS['iterations2']; ++$i) $arr2[] =
$test_array[rand(0, $GLOBALS['iterations'])];
  # 1st test will output # of iterations random strings
  # 2nd test will output a sequence of #iterations2 random strings
  switch ($method) {
case 0: // comma
  # -> TEST 1 <-
  ob_start();
  $start_time = microtime(true);
  foreach ($test_array as $array_value) {
 echo $test_string, $array_value;
  }
  $end_time = microtime(true);
  ob_end_clean();
  $GLOBALS["results1"]["comma"]["total_time"] += abs($end_time -
$start_time)*1000/$GLOBALS["iterations"];
  ++$GLOBALS["results1"]["comma"]["count"];
  # -> TEST 2 <-
  ob_start();
  $start_time = microtime(true);
  eval($eval_strings['comma']);
  $end_time = microtime(true);
  ob_end_clean();
  $GLOBALS["results2"]["comma"]["total_time"] += abs($end_time -
$start_time)*1000;
  ++$GLOBALS["results2"]["comma"]["count"];
  break 1;
case 1: // concatenation
  # -> TEST 1 <-
  ob_start();
  $start_time = microtime(true);
  foreach ($test_array as $array_value) {
 echo $test_string.$array_value;
  }
  $end_time = microtime(true);
  ob_end_clean();
  $GLOBALS["results1"]["concat"]["total_time"] += abs($end_time -
$start_time)*1000/$GLOBALS["iterations"];
  ++$GLOBALS["results1"]["concat"]["count"];
  # -> TEST 2 <-
  ob_start();
  $start_time = microtime(true);
  eval($eval_strings['concat']);
  $end_time = microtime(true);
  ob_end_clean();
  echo $eval_string."\n";
  $GLOBALS["results2"]["concat"]["total_time"] += abs($end_time -
$start_time)*1000;
  ++$GLOBALS["results2"]["concat"]["count"];
  break 1;
case 2: // interpolation
  # -> TEST 1 <-
  ob_start();
  $start_time = microtime(true);
  foreach ($test_array as $array_value) {
 echo "{$test_string}{$array_value}";
  }
  $end_time = microtime(true);
  ob_end_clean();
  $GLOBALS["results1"]["interpol"]["total_time"] += abs($end_time
- $start_time)*1000/$GLOBALS["iterations"];
  ++$GLOBALS

Re: [PHP] concatenating with "." or ","

2008-08-25 Thread Bernhard Kohl
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml";>


Test for Tedd


Comma took: '.(abs($e_t -
$s_t)*1000/$iterations).' milliseconds on average.';
# <-- Concatenation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
echo $test_string.$array_value;
}
$e_t = microtime(true);
ob_end_clean();
echo 'Concatenation: '.(abs($e_t -
$s_t)*1000/$iterations).' milliseconds on average.';
# <-- Interpolation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
echo "{$test_string}{$array_value}";
}
$e_t = microtime(true);
ob_end_clean();
echo 'Interpolation: '.(abs($e_t -
$s_t)*1000/$iterations).' milliseconds on average.';
# <-- HereDoc
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
   echo <



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Internationalisation and MB strings

2008-08-01 Thread Bernhard Kohl
/* snippetty */

foreach ($mb_array as $mb_string) {

 strlen('œŸŒ‡Ņ');
}

/* snip */

Oh, this is supposed to be a *strlen($mb_string)*; of course

>


Re: [PHP] Writing my own web based user forum

2008-08-01 Thread Bernhard Kohl
pw = md5($pw);
  $this->username = $name;
  return true;
 }
}

$new_user = new user();
if ($new_user->set_user('Joe', 'swordfish') {
 $fp =@ fopen('/some_dir/users.txt', 'a');
 @fwrite($fp, serialize($new_user));
 @fclose($fp);
}

# the next time you need it simple read it in again with unserialize()

?>
On Fri, Aug 1, 2008 at 1:49 PM, Jason Pruim <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> I am looking at writing my own web based user forum somewhat for my own
> knowledge, and because I know that I don't know enough to be able to tie in
> authentication so they only need 1 user account.
>
> Does anyone have any examples short of downloading something like phpbb and
> tearing it apart?
>
> It will probably be really light weight, basic forum that hopefully will
> expand into more as time goes on :)
>
> I've tried searching the web but have not been able to turn up any help
> unless I was to write a bridge for a song...
>
> Any knowledge you can bestow upon me is greatly appreciated!
>
> Thanks!
>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 11287 James St
> Holland, MI 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] After INSERT form submit - Data doesn't refresh!

2008-07-22 Thread Bernhard Kohl
Thijs jou should read the OP's statement again ..

The OP wrote: . *(The INSERT function is executed before the SELECT in the
page).*


Re: [PHP] After INSERT form submit - Data doesn't refresh!

2008-07-22 Thread Bernhard Kohl
I'm pretty sure this is a cache issue ..

To disable caching:*
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
*

But if you have the modification date then use
*$time = filemtime($ffile);
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

*
On Tue, Jul 22, 2008 at 1:14 PM, Rahul S. Johari <
[EMAIL PROTECTED]> wrote:

> Ave,
>
> I'm wondering if there's a PHP solution to this, I could be in the wrong
> place.
> I have an INSERT form which submits to the same php page, which also
> displays the records from the mySQL database the INSERT form submits to.
> When the form submits and the page returns, the added record does not show
> up unless you "Refresh" the page.
>
> I'm imagining even after form submit, the Browser is caching the data and
> displaying data from the Cache.
>
> Is there a solution to this? Is there anything PHP can do to instruct the
> browser not the cache the data?
>
> Thanks!
>
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
>
> [Email] [EMAIL PROTECTED]
> [Web]   http://www.rahulsjohari.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] An HTML5 radar chart

2008-07-19 Thread Bernhard Kohl
I did not get it to work in Opera 9.5. But in Firefox 2.x it worked

Why are you doing that with JavaScript?


Re: [PHP] Advice on a radar chart

2008-07-15 Thread Bernhard Kohl
If you are willing to use googles chart api ..

http://code.google.com/apis/chart/#radar

Yeti

On Tue, Jul 15, 2008 at 11:35 AM, Richard Heyes <[EMAIL PROTECTED]>
wrote:

> Hey,
>
> Can anyone suggest an efficient method for plotting the marks on a radar
> chart? I have the background done (
> http://www.phpguru.org/downloads/HTML5_radar/ - FF required), but that not
> exactly difficult.
>
> Cheers.
>
> --
> Richard Heyes
>
> Employ me:
> http://www.phpguru.org/cv
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] IPv6 validation

2008-07-12 Thread Bernhard Kohl
Doesnt filter_var() require PHP5+ ?

I have quite some systems still running 4.4.8.

On 7/12/08, Kevin Waterson <[EMAIL PROTECTED]> wrote:
>
> This one time, at band camp, Yeti <[EMAIL PROTECTED]> wrote:
>
> > Now i was wondering of what there might be the best way to validate an
> IPv6
> > address.
>
>
> from this url..
> http://phpro.org/tutorials/Filtering-Data-with-PHP.html#9
>
> 
> /*** an IP address ***/
> $ip = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
>
> /*** try to validate as IPV6 address ***/
> if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE)
> {
> echo "$ip is not a valid IP";
> }
> else
> {
> echo "$ip is valid";
> }
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>