php-general Digest 7 Apr 2008 15:30:56 -0000 Issue 5391

2008-04-07 Thread php-general-digest-help

php-general Digest 7 Apr 2008 15:30:56 - Issue 5391

Topics (messages 272608 through 272644):

Re: Arbitrary mathematical relations, not just hashes
272608 by: Casey
272610 by: Mark J. Reed
272626 by: Jenda Krynicky
272627 by: Jenda Krynicky
272644 by: Paul Johnson

php application send mouse click
272609 by: Daniel Kolbo

Re: objects stored in sessions
272611 by: Julien Pauli
272613 by: Richard Heyes

PHP gives session error on remote server, but not local test machine
272612 by: Dave M G

string
272614 by: John Taylor-Johnston
272615 by: Stut
272617 by: Thiago Pojda
272618 by: admin.buskirkgraphics.com
272619 by: Stut
272620 by: Thiago Pojda
272622 by: Daniel Brown
272624 by: John Taylor-Johnston
272632 by: Mark J. Reed
272633 by: Jim Lucas
272635 by: Daniel Brown

Search engines and cookies
272616 by: Emil Edeholt
272625 by: Daniel Brown
272630 by: Evert Lammerts

PHP ssh2 problem
272621 by: Michael Stroh
272623 by: Daniel Brown
272642 by: Michael Stroh
272643 by: Daniel Brown

included file var scope
272628 by: Evert Lammerts
272636 by: Stut
272637 by: Evert Lammerts
272638 by: Stut
272640 by: Evert Lammerts

Re: opening a big file
272629 by: Daniel Brown

Re: Include fails when ./ is in front of file name
272631 by: Daniel Brown
272639 by: Philip Thompson
272641 by: Stut

Re: Dynamic dropdown lists (select)
272634 by: Daniel Brown

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
On Sun, Apr 6, 2008 at 4:52 PM, Kelly Jones [EMAIL PROTECTED] wrote:
 Many programming languages (including Perl, Ruby, and PHP) support hashes:

  $color['apple'] = 'red';
  $color['ruby'] = 'red';

  $type['apple'] = 'fruit';
  $type['ruby'] = 'gem';

  This quickly lets me find the color or type of a given item.

  In this sense, color() and type() are like mathematical functions.

  However, I can't easily find all items whose $color is 'red', nor all
  items whose $type is 'fruit'. In other words, color() and type()
  aren't full mathematical relations.

  Of course, I could create the inverse function as I go along:

  $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to value

  and there are many other ways to do this, but they all seem kludgey.

  Is there a clean way to add 'relation' support to Perl, Ruby, or PHP?

  Is there a language that handles mathematical relations naturally/natively?

  I realize SQL does all this and more, but that seems like overkill for
  something this simple?

  --
  We're just a Bunch Of Regular Guys, a collective group that's trying
  to understand and assimilate technology. We feel that resistance to
  new ideas and technology is unwise and ultimately futile.

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



I hit reply-all... now am I suddenly subscribed to Perl and Ruby lists!?!

-- 
-Casey
---End Message---
---BeginMessage---
On Sun, Apr 6, 2008 at 11:51 PM, Casey [EMAIL PROTECTED] wrote:
  I hit reply-all... now am I suddenly subscribed to Perl and Ruby lists!?!

Huh, didn't notice the cross-posting.  But no, you're not subscribed
to any new lists.

Since we're cross-posting, the translation of my sample would be
apropos.  Here are a few different takes on a loopless versions in
Ruby.  Given:

color = { :apple = :red, :ruby = :red, :banana = :yellow }

This is, I think, the most straightforward:

color.keys.find_all { |k| color[k] == :red }

But having to repeat the hash name is inelegant.  Which leads us to this:

 color.find_all { |k,v| v == :red }.collect { |p| p[0] }

Building up a list from the elements of a Hash would seem to be a
natural application of Hash#inject, although the fact that the inject
block has to return the accumulator makes it a little less elegant
than it could be, IMO:

 color.inject([]) { |a,p| a  p[0] if p[1] == :red; a }

In Perl5 I don't have a better solution than the first one above:

my %color = ( apple = 'red', ruby = 'red', banana = 'yellow');
grep { $color{$_} eq 'red' } keys %color;

-- 
Mark J. Reed [EMAIL PROTECTED]
---End Message---
---BeginMessage---
From: Julian Leviston [EMAIL PROTECTED]
 You could use ActiveRecord.

Without a database? I guess not. You'd still need at least SQLite. 
But you are right, you could use ActiveRecord to obtain a nice object 
oriented wrapper around the database so that it doesn't scare you.

Or, assuming you do store that data into a database table (of course 
using indexes on both columns) you 

Re: [PHP] objects stored in sessions

2008-04-07 Thread Richard Heyes

Have you seen how PHP makes difference between private, protected and public
attributes of an object, into the session file ?
There are special caracters before them to recognize them.

So the question is : is PHP4 able to read such a session file ?
And how will it interpret them when we ask him to unserialize data ?


The question(s) should be Why would you want PHP4 to read a PHP5 
session? and Why would you expect it to work?. If you want to 
transfer data between versions you may want to investigate XMLRPC. Or 
perhaps the somewhat more verbose SOAP.


--
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] objects stored in sessions

2008-04-07 Thread Julien Pauli
Have you seen how PHP makes difference between private, protected and public
attributes of an object, into the session file ?
There are special caracters before them to recognize them.

So the question is : is PHP4 able to read such a session file ?
And how will it interpret them when we ask him to unserialize data ?

Cheers.
Julien.P

2008/4/7 Kevin Waterson [EMAIL PROTECTED]:

 On Sun, 2008-04-06 at 11:02 -0400, Mark Weaver wrote:

  So, if I create a user object, set the properties of said user object
  and store that object in the user session will that object be available
  throughout the application from the session?


 http://phpro.org/tutorials/Introduction-To-PHP-Sessions.html#8


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




[PHP] PHP gives session error on remote server, but not local test machine

2008-04-07 Thread Dave M G

PHP list,

I have a large set of PHP scripts of my own design that outputs any 
errors to text log files.


These scripts are deployed on a few different sites, at different 
virtual hosting services. On one, I keep seeing this error in my log files:


Error Handler message: session_start() [a 
href='function.session-start'function.session-start/a]: The session 
id contains illegal characters, valid characters are a-z, A-Z, 0-9 and 
'-,'  /home/domains/mydomainname.com/public_html/index.php 107


Before I show the content of index.php, I want to emphasize that no 
other virtual host produces this error. My home testing environment 
doesn't either. I have doubly ensured that the scripts are the same 
across all environments. So there must be something in the interaction 
of my scripts on that hosting service that is causing this error.


Here are the contents of index.php, trimmed of most comments for 
brevity. Line 107 is where the last session_start() call is.


My question is why would this code trip an error on one server, but not all?

Thank you for any advice.

--- code ---

include_once '+site/Settings.php';
include_once 'Global.php';
set_error_handler(array('ErrorHandler','handleError'), E_ALL);
// initialize the output tree. This is the structure that receives all 
the ouput and stores it in a tree form

// based on the HTML structure
HTML::initializeTree();
$userRequest = trim($_SERVER['REQUEST_URI'], /);
if (Browser::supportsCookies())
{
session_start();
}
else
{
if (strlen($userRequest) != 0)
{
$sessionArray = Session::decodeSessionID($userRequest);
if (is_array($sessionArray))
{
session_id($sessionArray[0]);
$userRequest = $sessionArray[1];
}
else
{
$userRequest = $sessionArray;
}
}
session_start();
}

--- code ends ---

--
Dave M G
Articlass - open source CMS
http://articlass.org

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



Re: [PHP] string

2008-04-07 Thread Stut

John Taylor-Johnston wrote:

$name = John Taylor;
I want to verify if $name contains john, if yes echo found;
Cannot remember which to use:
http://ca.php.net/manual/en/ref.strings.php


Either http://php.net/strpos or http://php.net/stripos if your version 
of PHP supports it.


-Stut

--
http://stut.net/


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



[PHP] string

2008-04-07 Thread John Taylor-Johnston

$name = John Taylor;
I want to verify if $name contains john, if yes echo found;
Cannot remember which to use:
http://ca.php.net/manual/en/ref.strings.php
Sorry,
John

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



[PHP] Search engines and cookies

2008-04-07 Thread Emil Edeholt

Hi,

Do you guys how search engines like cookies? One site I'm working on now 
requires the user to select which region he/she is from on the start 
page. That value is stored in a cookie. So without cookies you can't get 
past the start page. Does this leave the search engines at the start 
page? Right now google only index the start pages on my site and I'm 
trying to figure out why.


If I can't use cookies, how would you force users to select a region but 
letting the search engine spiders in on the site somehow?


Hope this wasn't too off topic.

Kind Regards Emil

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



RES: [PHP] string

2008-04-07 Thread Thiago Pojda
?php
$name = John Taylor;
if (strpos($name,'John')  0){ 
//you could use stripos for case insensitive search
echo found;
}
?

-Mensagem original-
De: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Enviada em: segunda-feira, 7 de abril de 2008 10:25
Para: PHP-General
Assunto: [PHP] string

$name = John Taylor;
I want to verify if $name contains john, if yes echo found; 
Cannot remember which to use:
http://ca.php.net/manual/en/ref.strings.php
Sorry,
John

--
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] string

2008-04-07 Thread admin
Do a preg match to find one or preg_match_all to find all the john in the 
string. 

?php
$name = John Taylor;
$pattern = '/^John/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);
? 





$name = John Taylor;
I want to verify if $name contains john, if yes echo found;
Cannot remember which to use:
http://ca.php.net/manual/en/ref.strings.php
Sorry,
John

-- 
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: RES: [PHP] string

2008-04-07 Thread Stut

Thiago Pojda wrote:

?php
$name = John Taylor;
	if (strpos($name,'John')  0){ 
	//you could use stripos for case insensitive search

echo found;
}
?


This will not do what you expect it to. Since 'John' is the first thing 
in the string strpos will return 0 causing the condition to evaluate to 
false.


As per the documentation for strpos you should compare the value *and 
type* of the variable returned by strpos against false to check for 
non-existance.


if (strpos($name, 'John') !== false) { ... }

-Stut

--
http://stut.net/


-Mensagem original-
De: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Enviada em: segunda-feira, 7 de abril de 2008 10:25

Para: PHP-General
Assunto: [PHP] string

$name = John Taylor;
I want to verify if $name contains john, if yes echo found; 
Cannot remember which to use:

http://ca.php.net/manual/en/ref.strings.php
Sorry,
John

--
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



RES: RES: [PHP] string

2008-04-07 Thread Thiago Pojda
Never late to learn new stuff, you're right Stut.

Thanks! 

-Mensagem original-
De: Stut [mailto:[EMAIL PROTECTED] 
Enviada em: segunda-feira, 7 de abril de 2008 10:42
Para: Thiago Pojda
Cc: 'John Taylor-Johnston'; 'PHP-General'
Assunto: Re: RES: [PHP] string

Thiago Pojda wrote:
 ?php
 $name = John Taylor;
   if (strpos($name,'John')  0){ 
   //you could use stripos for case insensitive search
   echo found;
   }
 ?

This will not do what you expect it to. Since 'John' is the 
first thing in the string strpos will return 0 causing the 
condition to evaluate to false.

As per the documentation for strpos you should compare the value *and
type* of the variable returned by strpos against false to check 
for non-existance.

if (strpos($name, 'John') !== false) { ... }

-Stut

--
http://stut.net/

 -Mensagem original-
 De: John Taylor-Johnston [mailto:[EMAIL PROTECTED]
 Enviada em: segunda-feira, 7 de abril de 2008 10:25
 Para: PHP-General
 Assunto: [PHP] string
 
 $name = John Taylor;
 I want to verify if $name contains john, if yes echo found; Cannot 
 remember which to use:
 http://ca.php.net/manual/en/ref.strings.php
 Sorry,
 John
 
 --
 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



[PHP] PHP ssh2 problem

2008-04-07 Thread Michael Stroh
Hello, I have run into a problem when trying to get the ssh2 bindings to
run on PHP. I have successfully installed libssh2 and have gotten version
0.11 of ssh2 to compile correctly using the patch obtained through the
'package bugs' page. However, when I load php, I get the following error:

dyld: NSLinkModule() error
dyld: Symbol not found: _zval_used_for_init
  Referenced from: /private/etc/php_modules/ssh2.so
  Expected in: flat namespace

Trace/BPT trap

I'm kind of a php novice so any advice you could give me would be greatly
appreciated. I'm running PHP v5.2.5 on Mac OS 10.5.2 and am more than
willing to provide you with any other details.

Cheers,
Michael Stroh


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



Re: [PHP] string

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 9:25 AM, John Taylor-Johnston
[EMAIL PROTECTED] wrote:
 $name = John Taylor;
  I want to verify if $name contains john, if yes echo found;
  Cannot remember which to use:
  http://ca.php.net/manual/en/ref.strings.php
  Sorry,
  John

?php
if(stristr($name,'john')) {
// True
}
?

Since you said you wanted to know if it contains 'john', this
will find if 'john' (insensitive) matches any part of the name.  So in
your case, it would match on both John and Johnston.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] PHP ssh2 problem

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 10:16 AM, Michael Stroh [EMAIL PROTECTED] wrote:
 Hello, I have run into a problem when trying to get the ssh2 bindings to
  run on PHP. I have successfully installed libssh2 and have gotten version
  0.11 of ssh2 to compile correctly using the patch obtained through the
  'package bugs' page. However, when I load php, I get the following error:

  dyld: NSLinkModule() error
  dyld: Symbol not found: _zval_used_for_init
   Referenced from: /private/etc/php_modules/ssh2.so
   Expected in: flat namespace

Re-run ./configure for libssh2 and see if there are any errors
there.  The missing symbol in the compiled .so file
(_zval_used_for_init) I believe refers to Zend Optimizer, so you may
just need to reinstall that (and maybe a newer version).

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] string

2008-04-07 Thread John Taylor-Johnston

Excellent. Thanks all!
John

Daniel Brown wrote:

On Mon, Apr 7, 2008 at 9:25 AM, John Taylor-Johnston
[EMAIL PROTECTED] wrote:
  

$name = John Taylor;
 I want to verify if $name contains john, if yes echo found;
 Cannot remember which to use:
 http://ca.php.net/manual/en/ref.strings.php
 Sorry,
 John



?php
if(stristr($name,'john')) {
// True
}
?

Since you said you wanted to know if it contains 'john', this
will find if 'john' (insensitive) matches any part of the name.  So in
your case, it would match on both John and Johnston.

  


Re: [PHP] Search engines and cookies

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt [EMAIL PROTECTED] wrote:
 Hi,

  Do you guys how search engines like cookies? One site I'm working on now
 requires the user to select which region he/she is from on the start page.
 That value is stored in a cookie. So without cookies you can't get past the
 start page. Does this leave the search engines at the start page? Right now
 google only index the start pages on my site and I'm trying to figure out
 why.

  If I can't use cookies, how would you force users to select a region but
 letting the search engine spiders in on the site somehow?

One way to do it would be to allow Google (and/or other search
engines) to access the site by bypassing the region-selection
entirely.

?php
if(preg_match('/Google/Uis',$_SERVER['HTTP_USER_AGENT'])) {
// Allow Google to pass through.
}
?

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



[PHP] Re: Arbitrary mathematical relations, not just hashes

2008-04-07 Thread Jenda Krynicky
From: Julian Leviston [EMAIL PROTECTED]
 You could use ActiveRecord.

Without a database? I guess not. You'd still need at least SQLite. 
But you are right, you could use ActiveRecord to obtain a nice object 
oriented wrapper around the database so that it doesn't scare you.

Or, assuming you do store that data into a database table (of course 
using indexes on both columns) you could use Perl and choose how to 
access the data. With OO or without OO (horrors).

 Julian.
 
 Learn Ruby on Rails!

I always wondered what happens to a ruby lying on rails when a train 
finaly comes ...
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



[PHP] Re: Arbitrary mathematical relations, not just hashes

2008-04-07 Thread Jenda Krynicky
From: Kelly Jones [EMAIL PROTECTED]
 Many programming languages (including Perl, Ruby, and PHP) support hashes:
 
 $color['apple'] = 'red';
 $color['ruby'] = 'red';
 
 $type['apple'] = 'fruit';
 $type['ruby'] = 'gem';
 
 This quickly lets me find the color or type of a given item.
 
 In this sense, color() and type() are like mathematical functions.
 
 However, I can't easily find all items whose $color is 'red', nor all
 items whose $type is 'fruit'. In other words, color() and type()
 aren't full mathematical relations.

One of the reasons why you can't find them as easily is efficiency. 
If people could ask for all items in %color whose value is 'red', 
they would. Without noticing that it's much more expensive than the 
other way around.

@items = grep {$color{$_} eq 'red'} keys %color;

is not too complex, but it complex enough to suggest that there is 
more work involved. The only way both the direction could be equaly 
complex would be to keep two hash tables internaly instead of one. 
Which would double the memory consumption.

If you do need to do this more often you can build an inverse data 
structure. Which if it was a one-to-one relation would be just

 %inv_color = reverse %color;

in Perl, of course once the relation is many to one than the inverse 
one will be more complex to build.

  my %inv_color;
  while (my ($k,$v) = each %color) {
push @{$inv_color{$v}}, $k;
  }

and of course will be harder to work with. But there is no way around 
that.


What is it you are actually trying to acomplish?

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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



[PHP] included file var scope

2008-04-07 Thread Evert Lammerts

Hi all,

My system is accessible through an index.php file. This file does a 
bunch of includes to include global variables, which in function context 
become available through the global keyword:


index.php

?php
require_once global_vars.php;

function f() {
   global $global_var;
   var_dump($global_var);
}

f();

?

However, apart from access through the index.php file I want to be able 
to include my index.php file from a function context:


?php

   function includeIndex() {
  require_once (index.php);
   }

?

The logical result is that variables that are globally accessible to 
functions when the system is accessed through index.php are now in the 
context of includeIndex() - so they're not global.


I want to fix this problem by not having the include inside of the 
function context. How to go upon this?


Evert

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



Re: [PHP] opening a big file

2008-04-07 Thread Daniel Brown
On Sun, Apr 6, 2008 at 10:36 PM, Richard Lee [EMAIL PROTECTED] wrote:
 I am trying to open a big file and go through line by line while limiting
 the resource on the system.
  What is the best way to do it?

  Does below read the entire file and store them in memory(not good if that's
 the case)..

  open(SOURCE, /tmp/file) || die not there: $!\n;
  while (SOURCE) {
  ## do something
  }

Was there a reason this was sent to the PHP list as well?  Maybe
just a typo?

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Search engines and cookies

2008-04-07 Thread Evert Lammerts
Search engines won't come past that page. How about setting a default 
region when a user enters a different page then your main page?


Daniel Brown wrote:

On Mon, Apr 7, 2008 at 9:29 AM, Emil Edeholt [EMAIL PROTECTED] wrote:
  

Hi,

 Do you guys how search engines like cookies? One site I'm working on now
requires the user to select which region he/she is from on the start page.
That value is stored in a cookie. So without cookies you can't get past the
start page. Does this leave the search engines at the start page? Right now
google only index the start pages on my site and I'm trying to figure out
why.

 If I can't use cookies, how would you force users to select a region but
letting the search engine spiders in on the site somehow?



One way to do it would be to allow Google (and/or other search
engines) to access the site by bypassing the region-selection
entirely.

?php
if(preg_match('/Google/Uis',$_SERVER['HTTP_USER_AGENT'])) {
// Allow Google to pass through.
}
?

  



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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] wrote:
 This works:
include(file.inc.php);

  This doesn't:
include(./file.inc.php);

That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?

Also, what happens if you create two simple files in the same
directory like so:
?php
// file1.php
echo Okay.\n;
?

?php
// file2.php
include(dirname(__FILE__).'/file1.php');
?

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] string

2008-04-07 Thread Mark J. Reed
On Mon, Apr 7, 2008 at 9:30 AM,  [EMAIL PROTECTED] wrote:
 Do a preg match to find one or preg_match_all to find all the john in the 
 string.

preg_* is overkill if you're just searching for a literal string.  use
it if you're searching for any strings matching a pattern, part of
which you don't know.  If you know the entire string you're looking
for,  strstr() is both more efficient and easier to use.

Now, strpos() is more efficient still, but arguably more annoying to
use because of the 0 but true issue that necessitates checking for
!== false.

Besides efficiency, the only difference between strstr() and strpos()
is what they return.  strpos() returns the index of the first match,
while strstr() returns the entire string starting from that point;
it's the building of the copy of the string that causes strstr() to be
less efficient.

Both functions have case-insensitive variants stristr and stripos.

In each case, if the substring occurs more than once within the outer
string, the return value is based on the *first* occurrence. strpos()
(but not strstr()) has a variant that uses the *last* one instead:
strrpos() (r=reverse), which also has a case-insensitive version
strripos().  You can easily define a strrstr() though:

function strrstr($where, $what) {
   $pos = strrpos($where, $what);
   return $pos === false ? false : substr($where, $pos);
}

And for good measure, a strristr:

function strristr($where, $what) {
  $pos = strripos($where, $what);
  return $pos === false ? false : substr($where, $pos);
}





  ?php
  $name = John Taylor;
  $pattern = '/^John/';
  preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
  print_r($matches);
  ?







  $name = John Taylor;
  I want to verify if $name contains john, if yes echo found;
  Cannot remember which to use:
  http://ca.php.net/manual/en/ref.strings.php
  Sorry,
  John

  --
  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





-- 
Mark J. Reed [EMAIL PROTECTED]

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



Re: [PHP] string

2008-04-07 Thread Jim Lucas

Daniel Brown wrote:

On Mon, Apr 7, 2008 at 9:25 AM, John Taylor-Johnston
[EMAIL PROTECTED] wrote:

$name = John Taylor;
 I want to verify if $name contains john, if yes echo found;
 Cannot remember which to use:
 http://ca.php.net/manual/en/ref.strings.php
 Sorry,
 John


?php
if(stristr($name,'john')) {
// True
}
?

Since you said you wanted to know if it contains 'john', this
will find if 'john' (insensitive) matches any part of the name.  So in
your case, it would match on both John and Johnston.



I wonder if using strstr() with strtolower() would be faster or slower.

?php

$max = 10;
$it = 0;
while ( $it++  $max ) {
echo Attempt #{$it}br /;

$string = 'John Doe';
$counter = 1;
$new_string = strtolower($string);
$start_time_1 = microtime(true);
while ( $counter-- ) {
if ( strstr($new_string, 'john') ) {
###  Found it
}
}
echo microtime(true) - $start_time_1.br /;

$counter = 1;

$start_time = microtime(true);

while ( $counter-- ) {
if ( stristr($string, 'john') ) {
###  Found it
}
}
echo microtime(true) - $start_time.br /;

}

?

Results:
Attempt #1
0.015728950500488
0.022881031036377
Attempt #2
0.015363931655884
0.022166967391968
Attempt #3
0.015865087509155
0.022243022918701
Attempt #4
0.015905857086182
0.022934198379517
Attempt #5
0.015322208404541
0.022816181182861
Attempt #6
0.015490055084229
0.021909952163696
Attempt #7
0.015805959701538
0.021935939788818
Attempt #8
0.01572585105896
0.022881984710693
Attempt #9
0.015491008758545
0.022812128067017
Attempt #10
0.015367031097412
0.02212119102478


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-07 Thread Daniel Brown
On Fri, Apr 4, 2008 at 6:51 AM, Angelo Zanetti [EMAIL PROTECTED] wrote:
 Hi all,

  I am looking at options for creating a dynamic dropdown list.

  Ok here is the scenario:

  All values in the dropdown list (select/option field) are coming from the
  database.

  So there will be 2 dropdown lists. First one say gets (for example) a list
  of cars,

  Then once the car is choosen the second list is populated with the list of
  models for the car choosen.

Pay no attention to the design or any of the other stuff, but this
is a development site on which I lay out tests and new things for my
employer:

http://www.brokenauto.com/

It has a vehicle drop-down list (AJAX).

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] string

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 10:42 AM, Jim Lucas [EMAIL PROTECTED] wrote:

  I wonder if using strstr() with strtolower() would be faster or slower.
[snip=code]

  Results:
  Attempt #1
  0.015728950500488
  0.022881031036377
[snip!]

While I don't really care much for a single selection about the
difference of less than 7/1,000's of one second, that's still good
information to keep in mind - especially when dealing with large-scale
sites.  Nice work, Jim.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] included file var scope

2008-04-07 Thread Stut

Evert Lammerts wrote:
My system is accessible through an index.php file. This file does a 
bunch of includes to include global variables, which in function context 
become available through the global keyword:


index.php

?php
require_once global_vars.php;

function f() {
   global $global_var;
   var_dump($global_var);
}

f();

?

However, apart from access through the index.php file I want to be able 
to include my index.php file from a function context:


?php

   function includeIndex() {
  require_once (index.php);
   }

?

The logical result is that variables that are globally accessible to 
functions when the system is accessed through index.php are now in the 
context of includeIndex() - so they're not global.


I want to fix this problem by not having the include inside of the 
function context. How to go upon this?


In index.php rather than declaring vars like so...

$var = 'value';

...declare them in the $GLOBALS array like so...

$GLOBALS['var'] = 'value';

$var is then in the global scope regardless of where it was set.

-Stut

--
http://stut.net/

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



Re: [PHP] included file var scope

2008-04-07 Thread Evert Lammerts



In index.php rather than declaring vars like so...

$var = 'value';

...declare them in the $GLOBALS array like so...

$GLOBALS['var'] = 'value';

$var is then in the global scope regardless of where it was set.

-Stut



That would work. However I'm looking for a more generic solution, 
independent of the system that is being included. So basically I want to 
be able to include a file in my function while stepping out of the 
context of the function itself.


E

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



Re: [PHP] included file var scope

2008-04-07 Thread Stut

Evert Lammerts wrote:



In index.php rather than declaring vars like so...

$var = 'value';

...declare them in the $GLOBALS array like so...

$GLOBALS['var'] = 'value';

$var is then in the global scope regardless of where it was set.

-Stut



That would work. However I'm looking for a more generic solution, 
independent of the system that is being included. So basically I want to 
be able to include a file in my function while stepping out of the 
context of the function itself.


I'm not sure what you mean. If you're saying you want to include a file 
from inside a function but for all parts of it to behave as if it were 
being included at the global scope then I don't believe there's a way to 
do it.


Maybe it would be better if you tell us exactly what you're trying to 
achieve. I don't really see why my solution above would not work so I 
probably don't fully understand what you're trying to do.


-Stut

--
http://stut.net/

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Philip Thompson

On Apr 7, 2008, at 9:36 AM, Daniel Brown wrote:
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
 wrote:

This works:
  include(file.inc.php);

This doesn't:
  include(./file.inc.php);


   That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?


It's Windows. From experience, I know that it provides little to no  
error reporting in some instances. For example, if you're missing a  
semi-colon and you have error reporting turned on, all you get is a  
blank page - no other info. So, odds are is that he isn't receiving an  
error message.


~Phil


   Also, what happens if you create two simple files in the same
directory like so:
?php
// file1.php
echo Okay.\n;
?

?php
// file2.php
include(dirname(__FILE__).'/file1.php');
?


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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Stut

Philip Thompson wrote:

On Apr 7, 2008, at 9:36 AM, Daniel Brown wrote:
On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams 
[EMAIL PROTECTED] wrote:

This works:
  include(file.inc.php);

This doesn't:
  include(./file.inc.php);


   That's pretty vague, Noah.  Is it unable to locate the file?
What's the error message you're receiving?


It's Windows. From experience, I know that it provides little to no 
error reporting in some instances. For example, if you're missing a 
semi-colon and you have error reporting turned on, all you get is a 
blank page - no other info. So, odds are is that he isn't receiving an 
error message.


I'm not sure where you got that from, error reporting does not differ 
between Windows and other platforms except where platform-specific 
differences exist in the implementation (of which there are few).


What you're experiencing is probably the effect of the display_errors 
configuration option. Look it up in the manual for details.


To the OP: Check that your include_path contains '.', if it doesn't add 
it and see if that fixes your problem.


-Stut

--
http://stut.net/

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



Re: [PHP] PHP ssh2 problem

2008-04-07 Thread Michael Stroh
Thanks for your advice Daniel.

I installed the new version of Zend Optimizer but then received the
following error:

dyld: NSLinkModule() error
dyld: Symbol not found: _zend_extensions
  Referenced from: /usr/local/Zend/lib/ZendExtensionManager.so
  Expected in: flat namespace

Trace/BPT trap

I checked the Zend forums and it is believed that they will not support
Mac OS 10.5 and thus the error. Is there another package I can use to
replace Zend for the purpose of ssh2?

Cheers,
Michael



On Mon, April 7, 2008 10:21 am, Daniel Brown wrote:
 On Mon, Apr 7, 2008 at 10:16 AM, Michael Stroh [EMAIL PROTECTED] wrote:
 Hello, I have run into a problem when trying to get the ssh2 bindings to
  run on PHP. I have successfully installed libssh2 and have gotten
 version
  0.11 of ssh2 to compile correctly using the patch obtained through the
  'package bugs' page. However, when I load php, I get the following
 error:

  dyld: NSLinkModule() error
  dyld: Symbol not found: _zval_used_for_init
   Referenced from: /private/etc/php_modules/ssh2.so
   Expected in: flat namespace

 Re-run ./configure for libssh2 and see if there are any errors
 there.  The missing symbol in the compiled .so file
 (_zval_used_for_init) I believe refers to Zend Optimizer, so you may
 just need to reinstall that (and maybe a newer version).

 --
 /Daniel P. Brown
 Ask me about:
 Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
 and shared hosting starting @ $2.50/mo.
 Unmanaged, managed, and fully-managed!

 --
 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] included file var scope

2008-04-07 Thread Evert Lammerts


I'm not sure what you mean. If you're saying you want to include a 
file from inside a function but for all parts of it to behave as if it 
were being included at the global scope then I don't believe there's a 
way to do it.


Maybe it would be better if you tell us exactly what you're trying to 
achieve. I don't really see why my solution above would not work so I 
probably don't fully understand what you're trying to do.


-Stut



Some operations in the system are expensive or just take very long. As a 
solution, every time such a request is made the system schedules itself 
to be executed at a different moment. A cron job runs every night and 
checks if there are any scheduled processes, and if so it executes them. 
A process is defined by the state of the system when the process was 
delayed (all super global variables make up for the state). The 
scheduler restores the state and then includes the index.php file so 
that the process can be executed.


Your solution would definitely work, however, the problem is that the 
system is huge and designed in a terrible way. To search the code and 
find all variables that have been defined in the global scope would be a 
monstrous task that would take days.


Apart from that, it would be great if we can reuse this scheduler for 
different systems without having to touch the actual system.


I do see a couple of solutions, but none are very elegant. You could, 
for example, have all work done outside of a function. However, this 
means uncoupling the functionality from the Scheduler object, which 
means we get scattered functionality that belongs to the same logical 
group - scheduling a process and invoking a process is done in different 
files.




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



Re: [PHP] PHP ssh2 problem

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:25 AM, Michael Stroh [EMAIL PROTECTED] wrote:
 Thanks for your advice Daniel.


  I checked the Zend forums and it is believed that they will not support
  Mac OS 10.5 and thus the error. Is there another package I can use to
  replace Zend for the purpose of ssh2?

If you're using it for Zend Encoder-encoded files, the answer is
no.  If you just have it installed because it seems like a good idea,
then your best bet would be to comment-out the [Zend] section of your
php.ini and restart your HTTP server (Apache?) so that the changes
take effect.  Then try the SSH code again.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Arbitrary mathematical relations, not just hashes

2008-04-07 Thread Paul Johnson
On Sun, Apr 06, 2008 at 08:51:00PM -0700, Casey wrote:

 I hit reply-all... now am I suddenly subscribed to Perl and Ruby lists!?!

Be careful.  Next time you do it you'll be subscribed to Haskell, OCaml
and Smalltalk lists.

Bwahahaha!

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:20 AM, Philip Thompson [EMAIL PROTECTED] wrote:

  It's Windows. From experience, I know that it provides little to no error
 reporting in some instances. For example, if you're missing a semi-colon and
 you have error reporting turned on, all you get is a blank page - no other
 info. So, odds are is that he isn't receiving an error message.

error_reporting() == error_reporting() !platform

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



[PHP] Date comparison Question

2008-04-07 Thread admin
I am having a date time comparison issue. 
I have statically set the values here. But the data is fed from the database, 
CaldTime is timestamp and since it will not allow me to have 2 timestamps in 
the same table I set the CallEnd varchar(12). Storing the data they seem to be 
the same for output. I checked hexadecimal and binary to look for obscurities.


$sqldata['CaldTime']  = 2008-04-07 11:15:32;
$sqldata['CallEnd'] = 2008-04-07 11:17:17;

$time1 = strtotime($sqldata[CaldTime]);
$time2 = strtotime($sqldata[CallEnd]);
$interval = $time2 - $time1;

echo $interval;

+++
Displays like 1.75:0
I am looking for a more precise time like 1:45 instead.
Am I looking at this all wrong for time difference?

Richard L. Buskirk
Sorry my murloc got pawned in AV, and ever since I cant think right!

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



Re: [PHP] opening a big file

2008-04-07 Thread Richard Lee

Daniel Brown wrote:

On Sun, Apr 6, 2008 at 10:36 PM, Richard Lee [EMAIL PROTECTED] wrote:
  

I am trying to open a big file and go through line by line while limiting
the resource on the system.
 What is the best way to do it?

 Does below read the entire file and store them in memory(not good if that's
the case)..

 open(SOURCE, /tmp/file) || die not there: $!\n;
 while (SOURCE) {
 ## do something
 }



Was there a reason this was sent to the PHP list as well?  Maybe
just a typo?

  

def a typo..  sorry about that

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



Re: [PHP] opening a big file

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:44 AM, Richard Lee [EMAIL PROTECTED] wrote:
 Daniel Brown wrote:
 
 Was there a reason this was sent to the PHP list as well?  Maybe
  just a typo?
 
  def a typo..  sorry about that


No problem at all.  Just checking in case the PHP question was
missed or something.  I know all about typos.  I keep typing funeral
instead of wedding for June 28th.

Yes, dear, it was just a typo seventeen times

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Dan Joseph
On Mon, Apr 7, 2008 at 11:52 AM, Wolf [EMAIL PROTECTED] wrote:

 Noah,

 Looks like you need to be deciding on whether or not you are on windoze or
 *Nix.

 If on Windoze, your include path is \
 If on *Nix, your include path is /

 Notice the direction of the slashes and code appropriately in all
 locations.

 Wolf


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



I'm working with a Windows server and able to use ./ in all my includes.
Example - require_once( ./library/urs/URS.Framework.php );  His should
work fine also.

-- 
-Dan Joseph

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Wolf

 Daniel Brown [EMAIL PROTECTED] wrote: 
 On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
 wrote:
  This works:
 include(file.inc.php);
 
   This doesn't:
 include(./file.inc.php);
 
 That's pretty vague, Noah.  Is it unable to locate the file?
 What's the error message you're receiving?
 
 Also, what happens if you create two simple files in the same
 directory like so:
 ?php
 // file1.php
 echo Okay.\n;
 ?
 
 ?php
 // file2.php
 include(dirname(__FILE__).'/file1.php');
 ?

Noah,

Looks like you need to be deciding on whether or not you are on windoze or *Nix.

If on Windoze, your include path is \
If on *Nix, your include path is /

Notice the direction of the slashes and code appropriately in all locations.

Wolf


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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:24 AM, Stut [EMAIL PROTECTED] wrote:

  To the OP: Check that your include_path contains '.', if it doesn't add it
 and see if that fixes your problem.

He has . in the include path

On Sun, Apr 6, 2008 at 2:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED] wrote:
PHP.ini's include path is:  include_path = .;.\includes;.\pear

 but even if it weren't, explicitly-calling ./ forces the
include to the local directory.  You're right to point it out that it
should be included, though I've actually seen some boxes where .
was not in the path.  I've even seen some cases where .. was
erroneously included instead.  There's treachery afoot!

However, take a look at his include path

Noah, I see no reason why PHP's include path should have .\pear in
there.  Not sure about .\includes, but .\pear likely doesn't exist in
every CWD/PWD (depending on your preference in system semantics) from
where it's called, and the same would go for .\includes.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Date comparison Question

2008-04-07 Thread Nathan Nobbe
On Mon, Apr 7, 2008 at 9:42 AM, [EMAIL PROTECTED] wrote:

 I am having a date time comparison issue.
 I have statically set the values here. But the data is fed from the
 database, CaldTime is timestamp and since it will not allow me to have 2
 timestamps in the same table I set the CallEnd varchar(12). Storing the data
 they seem to be the same for output. I checked hexadecimal and binary to
 look for obscurities.


 $sqldata['CaldTime']  = 2008-04-07 11:15:32;
 $sqldata['CallEnd'] = 2008-04-07 11:17:17;

 $time1 = strtotime($sqldata[CaldTime]);
 $time2 = strtotime($sqldata[CallEnd]);
 $interval = $time2 - $time1;

 echo $interval;

 +++
 Displays like 1.75:0
 I am looking for a more precise time like 1:45 instead.
 Am I looking at this all wrong for time difference?


hmm.
different results for me w/ this code

?php
$time1 = strtotime('2008-04-07 11:15:32');
$time2 = strtotime('2008-04-07 11:17:17');

echo time1: $time1 . PHP_EOL;
echo time2: $time2 . PHP_EOL;

$interval =  $time2 - $time1;
echo $interval . PHP_EOL;
?

time1: 1207588532
time2: 1207588637
105

-nathan


[PHP] Conditional popup driven from server-side

2008-04-07 Thread Arno Kuhl
I know popup windows are a client-side issue, but I can't figure how to
create and close a popup window from the server side only on condition,
otherwise display normal browser page. 

What I want is to accept a form, check the input, if there are errors return
them to the browser, if there aren't errors then popup a modal window and
start processing (a possibly long process) while displaying results in the
popup window, then automatically close the popup after processing is
complete and redirect to normal browser page with the final results. I want
to use the popup to (a) feedback ongoing progress to the user, and (b) keep
the browser side alive because the process could take several minutes. 

Googling for +php +popup is getting me nowhere, all the results are for
javascript. I know how to create a link or button that when clicked will
create a popup that will display the results of a php script, but I need to
do it the other way round. Can anyone please suggest some pointers on how to
generate a conditional popup from the server, and then get the server to
close it when done.

Thanks
Arno


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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Wolf

 Daniel Brown [EMAIL PROTECTED] wrote: 
 On Mon, Apr 7, 2008 at 11:52 AM, Wolf [EMAIL PROTECTED] wrote:
 
   Noah,
 
   Looks like you need to be deciding on whether or not you are on windoze or 
  *Nix.
 
   If on Windoze, your include path is \
   If on *Nix, your include path is /
 
   Notice the direction of the slashes and code appropriately in all 
  locations.
 
 Actually, PHP is smart enough to allow both on Windows.
 Otherwise, everyone would need to update their code for each different
 system, which destroys PHP's cross-platform nature.
 
 -- 

I've heard that to be the case, but sometimes it's not just the PHP but the 
underlying server doing the serving...

At any rate, how hard is it to convert slashes if you have to convert your OSs 
if you use a managed include file or keep the includes directive in the 
.htaccess folder.  ;)

YMMV, but I always just change them to be on the safe side, but that's just how 
I roll...

Wolf

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Stut

Wolf wrote:
 Daniel Brown [EMAIL PROTECTED] wrote: 

On Mon, Apr 7, 2008 at 11:52 AM, Wolf [EMAIL PROTECTED] wrote:

 Noah,

 Looks like you need to be deciding on whether or not you are on windoze or 
*Nix.

 If on Windoze, your include path is \
 If on *Nix, your include path is /

 Notice the direction of the slashes and code appropriately in all locations.

Actually, PHP is smart enough to allow both on Windows.
Otherwise, everyone would need to update their code for each different
system, which destroys PHP's cross-platform nature.

--


I've heard that to be the case, but sometimes it's not just the PHP but the 
underlying server doing the serving...

At any rate, how hard is it to convert slashes if you have to convert your OSs 
if you use a managed include file or keep the includes directive in the 
.htaccess folder.  ;)

YMMV, but I always just change them to be on the safe side, but that's just how 
I roll...


If you're worried about is use DIRECTORY_SEPARATOR rather than 
hard-coding it. Writing portable code is not difficult in PHP.


-Stut

--
http://stut.net/

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



Re: [PHP] Conditional popup driven from server-side

2008-04-07 Thread Wolf

 Arno Kuhl [EMAIL PROTECTED] wrote: 
 I know popup windows are a client-side issue, but I can't figure how to
 create and close a popup window from the server side only on condition,
 otherwise display normal browser page. 
 
 What I want is to accept a form, check the input, if there are errors return
 them to the browser, if there aren't errors then popup a modal window and
 start processing (a possibly long process) while displaying results in the
 popup window, then automatically close the popup after processing is
 complete and redirect to normal browser page with the final results. I want
 to use the popup to (a) feedback ongoing progress to the user, and (b) keep
 the browser side alive because the process could take several minutes. 
 
 Googling for +php +popup is getting me nowhere, all the results are for
 javascript. I know how to create a link or button that when clicked will
 create a popup that will display the results of a php script, but I need to
 do it the other way round. Can anyone please suggest some pointers on how to
 generate a conditional popup from the server, and then get the server to
 close it when done.
 
 Thanks
 Arno

That's because it is a CLIENT side issue, the server isn't able to do it.

If you want to provide feedback on the form, then look into Ajax or use output 
buffering and flushing to push out a status message as the form is processed.  
You could do this in a javascripted pop-up window or on the window they 
submitted the form.

If it takes your script minutes to process a form  you need to look into your 
processes.  I'd suggest verifying the form had all the pieces and then advising 
them you will email them when the registration or what-not is complete.

HTH,
Wolf

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



Re: [PHP] How to make a directory / file only available to registered users using PHP code?

2008-04-07 Thread Jason Pruim


On Apr 7, 2008, at 11:56 AM, Rian Hidayanto wrote:

hi,

I put a file setup.exe in a directory downloaddir\

I want to build PHP code, so that only registered users are able to
download the file.

How to make the directory / files only available to registered users  
using

PHP code?

(So that other users cannot download the file using direct url
http:\\www.abcd.org\downloaddir\setup.exe )



I can give you the basics of this and hopefully someone can fill in  
the gaps... What you need to do is put the actual file above the  
webroot... and then set the include path to include that, then you  
have your script go and fetch it.


Maybe this way makes more sense:
HD
Web
Downloads
mydispatchscript.php
INC
setup.exe
/HD

so basically, in your php.ini file make sure you include the INC  
directory and include the whole path to it. and you will be able to  
access it but no one will be able to access the file directly.





TIA
Rian


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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Noah Spitzer-Williams
Here's the error I get:

*Warning*: include(.\file.inc.php)
[function.includehttp://www.emsplannertest.com/function.include]:
failed to open stream: No such file or directory in *
C:\Inetpub\httpdocs\test.php* on line *3*

*Warning*: include()
[function.includehttp://www.emsplannertest.com/function.include]:
Failed opening '.\file.inc.php' for inclusion
(include_path='.;.\includes;.\pear') in *C:\Inetpub\httpdocs\test.php* on
line *3*

This works fine on my old server which is running PHP 4.3.9.

I honestly feel like I'm overlooking some stupid tiny thing.  Are my
permissions correct?  Is it possible to debug this and look at the full path
of file.inc.php that PHP is trying to load?

Thanks!


On Mon, Apr 7, 2008 at 7:36 AM, Daniel Brown [EMAIL PROTECTED] wrote:

 On Sun, Apr 6, 2008 at 5:17 PM, Noah Spitzer-Williams [EMAIL PROTECTED]
 wrote:
  This works:
 include(file.inc.php);
 
   This doesn't:
 include(./file.inc.php);

That's pretty vague, Noah.  Is it unable to locate the file?
 What's the error message you're receiving?

Also, what happens if you create two simple files in the same
 directory like so:
 ?php
 // file1.php
 echo Okay.\n;
 ?

 ?php
 // file2.php
 include(dirname(__FILE__).'/file1.php');
 ?

 --
 /Daniel P. Brown
 Ask me about:
 Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
 and shared hosting starting @ $2.50/mo.
 Unmanaged, managed, and fully-managed!



Re: [PHP] How to make a directory / file only available to registered users using PHP code?

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:56 AM, Rian Hidayanto [EMAIL PROTECTED] wrote:
 hi,

  I want to build PHP code, so that only registered users are able to
  download the file.

  (So that other users cannot download the file using direct url
  http:\\www.abcd.org\downloaddir\setup.exe )

This is just to get you started.  Polishing,
modifying/customizing, and sanitizing, you're on your own.

?php
// download.php
session_start();

if(!isset($_SESSION['username'])) {
die(Unauthorized access.);
}

// Keep the directory out of the web root.
$download = '../downloads/download.exe';

$filename = basename($download);

header(Pragma: public)
header(Expires: 0);
header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
header(Cache-Control: public);
header(Content-Description: File Transfer);
header(Content-Type: application/octet-stream);
header(Content-Disposition: attachment; filename=.$filename.;);
header(Content-Transfer-Encoding: binary);
header(Content-Length: .sizeof($download);
readfile($download);
exit(0);

?


-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] How to make a directory / file only available to registered users using PHP code?

2008-04-07 Thread Wolf

 Jason Pruim [EMAIL PROTECTED] wrote: 
 
 On Apr 7, 2008, at 11:56 AM, Rian Hidayanto wrote:
  hi,
 
  I put a file setup.exe in a directory downloaddir\
 
  I want to build PHP code, so that only registered users are able to
  download the file.
 
  How to make the directory / files only available to registered users  
  using
  PHP code?
 
  (So that other users cannot download the file using direct url
  http:\\www.abcd.org\downloaddir\setup.exe )
 
 
 I can give you the basics of this and hopefully someone can fill in  
 the gaps... What you need to do is put the actual file above the  
 webroot... and then set the include path to include that, then you  
 have your script go and fetch it.
 
 Maybe this way makes more sense:
 HD
   Web
   Downloads
   mydispatchscript.php
   INC
   setup.exe
 /HD
 
 so basically, in your php.ini file make sure you include the INC  
 directory and include the whole path to it. and you will be able to  
 access it but no one will be able to access the file directly.
 

You could also just use the inherent apache .htaccess pieces to disable access 
unless they are logged in people, and allow the internal verifiers to work.

But if you aren't running on Apache, then you'll need to work along Jason's 
suggestion and put the files in other locations and use the scripts to access 
them, just build a login checker to check the user is logged in first.

HTH,
Wolf

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



Re: [PHP] Date comparison Question

2008-04-07 Thread Mark J. Reed
On Mon, Apr 7, 2008 at 11:42 AM,  [EMAIL PROTECTED] wrote:
t the data is fed from the database, CaldTime is timestamp and since
it will not allow me to have 2 timestamps in
 the same table

?? What database are you using?  It sounds like it has a specific
meaning of timestamp - probably the last time this row was
modified - and you want an arbitrary date column, which would
probably be a different column type.  Not a string, though.  An actual
date type.  possible names are date, datetime, datestamp...


, and you  I set the CallEnd varchar(12). Storing the data they seem
to be the same for output. I checked hexadecimal and binary to look
for obscurities.


  $sqldata['CaldTime']  = 2008-04-07 11:15:32;
  $sqldata['CallEnd'] = 2008-04-07 11:17:17;

  $time1 = strtotime($sqldata[CaldTime]);
  $time2 = strtotime($sqldata[CallEnd]);
  $interval = $time2 - $time1;

  echo $interval;

  +++
  Displays like 1.75:0
  I am looking for a more precise time like 1:45 instead.
  Am I looking at this all wrong for time difference?

strtotime returns an integer number of seconds.  The difference
between $time1 and $time2 is 105.  If you want minutes and seconds,
you have to do the math yourself.

$interval_min = floor($interval/60);
$interval_sec = $interval % 60;

echo $interval_min:$interval_sec;

-- 
Mark J. Reed [EMAIL PROTECTED]

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



Re: [PHP] Date comparison Question

2008-04-07 Thread admin
Yes my mistake was looking at another record and published another.
But I figured it out now i can publish 1:45 like i wanted. Having a moment 
there.
Thank you 
Richard L. Buskirk 




 
On Mon, Apr 7, 2008 at 9:42 AM, [EMAIL PROTECTED] wrote:

I am having a date time comparison issue.
I have statically set the values here. But the data is fed from the database, 
CaldTime is timestamp and since it will not allow me to have 2 timestamps in 
the same table I set the CallEnd varchar(12). Storing the data they seem to be 
the same for output. I checked hexadecimal and binary to look for obscurities.


$sqldata['CaldTime']  = 2008-04-07 11:15:32;
$sqldata['CallEnd'] = 2008-04-07 11:17:17;

$time1 = strtotime($sqldata[CaldTime]);
$time2 = strtotime($sqldata[CallEnd]);
$interval = $time2 - $time1;

echo $interval;

+++
Displays like 1.75:0
I am looking for a more precise time like 1:45 instead.
Am I looking at this all wrong for time difference?

hmm.
different results for me w/ this code

?php
$time1 = strtotime('2008-04-07 11:15:32');
$time2 = strtotime('2008-04-07 11:17:17');

echo time1: $time1 . PHP_EOL;
echo time2: $time2 . PHP_EOL;

$interval =  $time2 - $time1;
echo $interval . PHP_EOL;
?

time1: 1207588532
time2: 1207588637
105
 -nathan

Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:52 AM, Wolf [EMAIL PROTECTED] wrote:

  Noah,

  Looks like you need to be deciding on whether or not you are on windoze or 
 *Nix.

  If on Windoze, your include path is \
  If on *Nix, your include path is /

  Notice the direction of the slashes and code appropriately in all locations.

Actually, PHP is smart enough to allow both on Windows.
Otherwise, everyone would need to update their code for each different
system, which destroys PHP's cross-platform nature.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Date comparison Question

2008-04-07 Thread admin
Thank you that is exactly what i did to figure it out.
Just was having a brain fart there for a minute.



On Mon, Apr 7, 2008 at 11:42 AM,  [EMAIL PROTECTED] wrote:
t the data is fed from the database, CaldTime is timestamp and since
it will not allow me to have 2 timestamps in
 the same table

?? What database are you using?  It sounds like it has a specific
meaning of timestamp - probably the last time this row was
modified - and you want an arbitrary date column, which would
probably be a different column type.  Not a string, though.  An actual
date type.  possible names are date, datetime, datestamp...


, and you  I set the CallEnd varchar(12). Storing the data they seem
to be the same for output. I checked hexadecimal and binary to look
for obscurities.


  $sqldata['CaldTime']  = 2008-04-07 11:15:32;
  $sqldata['CallEnd'] = 2008-04-07 11:17:17;

  $time1 = strtotime($sqldata[CaldTime]);
  $time2 = strtotime($sqldata[CallEnd]);
  $interval = $time2 - $time1;

  echo $interval;

  +++
  Displays like 1.75:0
  I am looking for a more precise time like 1:45 instead.
  Am I looking at this all wrong for time difference?

strtotime returns an integer number of seconds.  The difference
between $time1 and $time2 is 105.  If you want minutes and seconds,
you have to do the math yourself.

$interval_min = floor($interval/60);
$interval_sec = $interval % 60;

echo $interval_min:$interval_sec;

-- 
Mark J. Reed [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] Date comparison Question

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 11:42 AM,  [EMAIL PROTECTED] wrote:
 I am having a date time comparison issue.
  I have statically set the values here. But the data is fed from the 
 database, CaldTime is timestamp and since it will not allow me to have 2 
 timestamps in the same table I set the CallEnd varchar(12). Storing the data 
 they seem to be the same for output. I checked hexadecimal and binary to look 
 for obscurities.


  $sqldata['CaldTime']  = 2008-04-07 11:15:32;
  $sqldata['CallEnd'] = 2008-04-07 11:17:17;

  $time1 = strtotime($sqldata[CaldTime]);
  $time2 = strtotime($sqldata[CallEnd]);
  $interval = $time2 - $time1;

  echo $interval;

  +++
  Displays like 1.75:0
  I am looking for a more precise time like 1:45 instead.
  Am I looking at this all wrong for time difference?

  Richard L. Buskirk
  Sorry my murloc got pawned in AV, and ever since I cant think right!

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



This could be simplified to a function, but using some basic math

?php
$sqldata['CaldTime'] = 2008-04-07 11:15:32;
$sqldata['CallEnd'] = 2008-04-07 11:17:17;

$converted = explode('.',((strtotime($sqldata['CallEnd']) -
strtotime($sqldata['CaldTime'])) / 60));
$converted[1] = (($converted[1] / 6) * 3.6);
echo implode(':',$converted).\n;

?


-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Search engines and cookies

2008-04-07 Thread tedd

At 3:29 PM +0200 4/7/08, Emil Edeholt wrote:

Hi,

Do you guys how search engines like cookies? One site I'm working on 
now requires the user to select which region he/she is from on the 
start page. That value is stored in a cookie. So without cookies you 
can't get past the start page. Does this leave the search engines at 
the start page? Right now google only index the start pages on my 
site and I'm trying to figure out why.


If I can't use cookies, how would you force users to select a region 
but letting the search engine spiders in on the site somehow?


Hope this wasn't too off topic.

Kind Regards Emil


Emil:

My advice -- give the SE what it's looking for. Place a description 
of what your site is about on the start page. If you don't want users 
to see it, then place the text off-left via css position. This would 
also help those with assistive technologies and thus SE's shouldn't 
complain.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 12:24 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
wrote:
 Here's the error I get:

 Warning: include(.\file.inc.php) [function.include]: failed to open stream:
 No such file or directory in C:\Inetpub\httpdocs\test.php on line 3

 Warning: include() [function.include]: Failed opening '.\file.inc.php' for
 inclusion (include_path='.;.\includes;.\pear') in
 C:\Inetpub\httpdocs\test.php on line 3

If you're going to use Windows-style paths, try escaping your
slashes and see what happens.

?php
include(.\\file.inc.php);
?

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] PHP ssh2 problem

2008-04-07 Thread Michael Stroh
Thanks so much! That seems to have done the trick. I commented out those
files in my php.ini file and then a reinstallation of ssh2 worked. Zend
must have been installed by some default setting.

Thanks again for your help Daniel!

Cheers,
Michael



On Mon, April 7, 2008 11:29 am, Daniel Brown wrote:
 On Mon, Apr 7, 2008 at 11:25 AM, Michael Stroh [EMAIL PROTECTED] wrote:
 Thanks for your advice Daniel.


  I checked the Zend forums and it is believed that they will not support
  Mac OS 10.5 and thus the error. Is there another package I can use to
  replace Zend for the purpose of ssh2?

 If you're using it for Zend Encoder-encoded files, the answer is
 no.  If you just have it installed because it seems like a good idea,
 then your best bet would be to comment-out the [Zend] section of your
 php.ini and restart your HTTP server (Apache?) so that the changes
 take effect.  Then try the SSH code again.

 --
 /Daniel P. Brown
 Ask me about:
 Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
 and shared hosting starting @ $2.50/mo.
 Unmanaged, managed, and fully-managed!




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



Re: [PHP] Date comparison Question

2008-04-07 Thread admin
Dan I made a solution as below.

$time1 = strtotime($sqldata[CaldTime]);
$time2 = strtotime($sqldata[CallEnd]);
$interval = $time2 - $time1;
$TLength = date(i:s, strtotime(2008-01-01 01:00:$interval));

Result 01:45

Works perfect for me. Do you agree or disagree dan?




On Mon, Apr 7, 2008 at 11:42 AM,  [EMAIL PROTECTED] wrote:
 I am having a date time comparison issue.
  I have statically set the values here. But the data is fed from the 
database, CaldTime is timestamp and since it will not allow me to have 2 
timestamps in the same table I set the CallEnd varchar(12). Storing the data 
they seem to be the same for output. I checked hexadecimal and binary to look 
for obscurities.


  $sqldata['CaldTime']  = 2008-04-07 11:15:32;
  $sqldata['CallEnd'] = 2008-04-07 11:17:17;

  $time1 = strtotime($sqldata[CaldTime]);
  $time2 = strtotime($sqldata[CallEnd]);
  $interval = $time2 - $time1;

  echo $interval;

  +++
  Displays like 1.75:0
  I am looking for a more precise time like 1:45 instead.
  Am I looking at this all wrong for time difference?

  Richard L. Buskirk
  Sorry my murloc got pawned in AV, and ever since I cant think right!

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



This could be simplified to a function, but using some basic math

?php
$sqldata['CaldTime'] = 2008-04-07 11:15:32;
$sqldata['CallEnd'] = 2008-04-07 11:17:17;

$converted = explode('.',((strtotime($sqldata['CallEnd']) -
strtotime($sqldata['CaldTime'])) / 60));
$converted[1] = (($converted[1] / 6) * 3.6);
echo implode(':',$converted).\n;

?


-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

-- 
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



[PHP] How to make a directory / file only available to registered users using PHP code?

2008-04-07 Thread Rian Hidayanto

hi,

I put a file setup.exe in a directory downloaddir\

I want to build PHP code, so that only registered users are able to
download the file.

How to make the directory / files only available to registered users using
PHP code?

(So that other users cannot download the file using direct url
http:\\www.abcd.org\downloaddir\setup.exe )


TIA
Rian


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



Re: [PHP] Date comparison Question

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 1:03 PM,  [EMAIL PROTECTED] wrote:
 Dan I made a solution as below.


  $time1 = strtotime($sqldata[CaldTime]);
  $time2 = strtotime($sqldata[CallEnd]);
  $interval = $time2 - $time1;
  $TLength = date(i:s, strtotime(2008-01-01 01:00:$interval));

  Result 01:45

  Works perfect for me. Do you agree or disagree dan?

There ya' go!

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Lester Caine

Daniel Brown wrote:

On Mon, Apr 7, 2008 at 12:24 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
wrote:

Here's the error I get:

Warning: include(.\file.inc.php) [function.include]: failed to open stream:
No such file or directory in C:\Inetpub\httpdocs\test.php on line 3

Warning: include() [function.include]: Failed opening '.\file.inc.php' for
inclusion (include_path='.;.\includes;.\pear') in
C:\Inetpub\httpdocs\test.php on line 3


If you're going to use Windows-style paths, try escaping your
slashes and see what happens.

?php
include(.\\file.inc.php);
?


People seem to be missing the point here. These are PUBLIC applications that 
are failing to work for Noah. He should not need to re-write PHPMyAdmin in 
order to get it to work?


Next people will be saying that we should re-write PHP if it does not work for 
us.


Noah - I know that some 'security' has been added to the include function, but 
I'm not sure why you are having problems. I'm running applications on windows 
and Linux and the ./otherdir/ select is working fine.


--
Lester Caine - G8HFL
-
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Daniel Brown
On Mon, Apr 7, 2008 at 1:05 PM, Lester Caine [EMAIL PROTECTED] wrote:

  People seem to be missing the point here. These are PUBLIC applications
 that are failing to work for Noah. He should not need to re-write PHPMyAdmin
 in order to get it to work?

  Next people will be saying that we should re-write PHP if it does not work
 for us.

Oh, did I say that?  Must not have been paying attention as I
typed in words to that effect.  Sorry.

I'm giving steps to debug and recreate the issue, not to rewrite
anyone else's code.  You may have noticed where I mentioned
cross-platform portability.

-- 
/Daniel P. Brown
Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Include fails when ./ is in front of file name

2008-04-07 Thread Wolf

 Lester Caine [EMAIL PROTECTED] wrote: 
 Daniel Brown wrote:
  On Mon, Apr 7, 2008 at 12:24 PM, Noah Spitzer-Williams [EMAIL PROTECTED] 
  wrote:
  Here's the error I get:
 
  Warning: include(.\file.inc.php) [function.include]: failed to open stream:
  No such file or directory in C:\Inetpub\httpdocs\test.php on line 3
 
  Warning: include() [function.include]: Failed opening '.\file.inc.php' for
  inclusion (include_path='.;.\includes;.\pear') in
  C:\Inetpub\httpdocs\test.php on line 3
  
  If you're going to use Windows-style paths, try escaping your
  slashes and see what happens.
  
  ?php
  include(.\\file.inc.php);
  ?
 
 People seem to be missing the point here. These are PUBLIC applications that 
 are failing to work for Noah. He should not need to re-write PHPMyAdmin in 
 order to get it to work?
 
 Next people will be saying that we should re-write PHP if it does not work 
 for 
 us.
 
 Noah - I know that some 'security' has been added to the include function, 
 but 
 I'm not sure why you are having problems. I'm running applications on windows 
 and Linux and the ./otherdir/ select is working fine.
 
 -- 

Funny, none of the code *I* have seen posted to the list looks like it it 
phpMyAdmin or anything else public  And since when did basic debugging mean 
you look past the basics?

Noah-  Change the includes to REQUIRE and see if the path that it outputs helps 
you out any with trying to figure out where things have gone wrong.

HTH,
Wolf

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



Re: [PHP] date CDT CST UTC

2008-04-07 Thread Dee Ayy
  Daylight Savings Time must die!

Oh, by the way, thanks for your reply.

So last night my clock went forward an hour on this cool DST-aware
dual alarm clock radio I bought in 1999.  Apparently DST rules have
changed http://en.wikipedia.org/wiki/Year_2007_problem so now my clock
isn't as cool anymore.  Luckily I found out before I went to sleep.

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



Re: [PHP] generate images of register definitions

2008-04-07 Thread Mike Frysinger
On Mon, Jun 18, 2007 at 9:49 PM, Mike Frysinger [EMAIL PROTECTED] wrote:
 On 6/9/07, Richard Lynch [EMAIL PROTECTED] wrote:
  On Sat, June 9, 2007 4:27 pm, Mike Frysinger wrote:
   anyone know of some software to generate images like this:
   http://wh0rd.org/register.png
   idea is i have a list of registers and their bit meanings, and i want
   to automatically generate images like the above one from this data
  
   yes, i can write some custom code in PHP using GD, but i'd much rather
   use someone else's work than start from scratch
 
  It's remotely possible that you could hack something from JP Graph to
  look not completely unlike that...
 
  Though I suspect you might find it easier to start from scratch,
  honestly...

  yeah ive just started from scratch ... here's what ive got so far in
  case anyone happens to wander across this ...

  $reg = new register(WDOG_CTL, Watchdog Control Register,
  0xFFC00200, 0x0AD0, 16,
array(
array(15, 15, WDRO, 0 - Watchdog timer has not expired\n1 -
  Watchdog timer has expired, W1C),
array(11, 4, WDEN, 0xAD - Counter disabled\nAll other
  values - Counter enabled),
array(2, 1, WDEV, 00 - Generate reset event\n01 - Generate
  NMI\n10 - Generate GP interrupt\n11 - Disable event generation)
)
  );
  register_to_png($reg);

  http://wh0rd.org/register2.png

  maybe i'll start a cheesy sf project for it

anyone who is interested in such a beast:
http://docs.blackfin.uclinux.org/lib/plugins/register/register.phps

and some examples:
http://docs.blackfin.uclinux.org/lib/plugins/register/register/pll_ctl.png
http://docs.blackfin.uclinux.org/lib/plugins/register/register/seqstat.png
http://docs.blackfin.uclinux.org/lib/exe/fetch.php?cache=media=register%3A4141379fb2519eb98ab596d6d08f4e1e.png

hopefully someone else will find it useful
-mike

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



[PHP] RES: [PHP-INSTALL] Can't enable use_trans_sid

2008-04-07 Thread Thiago Pojda
{sorry for top-posting, but outlook can't do better}

I executed cat /usr/local/lib/php.ini | grep -i session and found out that
there was already one entry for that conf option by default, and it was set
to 0.

It fixed it, sorry I was that dumb.

Just saw the source and it is adding the phpsessid hidden input field, now
have to find out why my app does not let me login :)


Another question:

Is there a way to make php use these fields instead of cookies for
session control? I still want to let cookies enabled for other stuff, but as
it's messing up with multiple sessions because of poor cookie handling.


Thanks!!

-Mensagem original-
De: Keith Roberts [mailto:[EMAIL PROTECTED] 
Enviada em: segunda-feira, 7 de abril de 2008 17:38
Para: [EMAIL PROTECTED]
Assunto: Re: [PHP-INSTALL] Can't enable use_trans_sid

On Mon, 7 Apr 2008, Thiago Pojda wrote:

 To: [EMAIL PROTECTED]
 From: Thiago Pojda [EMAIL PROTECTED]
 Subject: [PHP-INSTALL] Can't enable use_trans_sid
 
 Guys,

 I can't enable trans_sid, I've tried set these to php.ini :

 session.use_trans_sid = On [tried 1 also] url_rewriter.tags = 
 a=href,area=href,frame=src,input=src,form=fakeentry,fieldset=

 Tried recompile it with --enable-trans-sid but still doesn't work. I 
 just realized that my phpinfo spits session.use_trans_sid Off.

 Any hints?

 -- VERSIONS --

 PHP Version 4.4.8


 SystemLinux debian 2.6.18-6-486 #1 Sun Feb 10 
22:06:33 UTC 2008 i686
 Build DateApr 7 2008 10:46:06
 Configure Command './configure' '--with-apxs2=/usr/bin/apxs2'
 '--with-oci8-instant-client=/oracle/instantclient/' '--disable-zts'
 Server APIApache 2.0 Handler
 Virtual Directory Support enabled
 Configuration File (php.ini) Path /usr/local/lib/php.ini

Are you sure you are editing the correct php.ini file Thiago?

Can you also post the section from your php.ini that has all 
the session.* directives in it?

It maybe that there are other session.* configuration options 
that need to be set as well to enable you to use PHP sessions.

Kind Regards,

Keith Roberts

-
Websites:
http://www.php-debuggers.net
http://www.karsites.net
http://www.raised-from-the-dead.org.uk

All email addresses are challenge-response protected with TMDA 
[http://tmda.net]
-




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



[PHP] php local application send mouse click

2008-04-07 Thread Daniel Kolbo

Hello,

I am mostly familiar with php for serving up web pages; however, 
recently I have been writing a local command line script on my WinXP 
machine.  I have spent the better part of this last week and all of 
today trying to figure out a way to send a mouse click to a particular 
window on the screen.


I first saw w32api.dll on the php.net site.  However, I cannot find this 
dll, but this searching took me to winbinder and php-gtk2.  It seems 
that I can only get winbinder to get (not send) mouse information: event 
type and x,y positions.  I am not too familiar with php-gtk nor creating 
dlls.


I want to use my local php command line script on my winXP machine to 
send mouse events (click) to a window.  I am open to any ideas on how to 
do this.


For C++ and VB there seems to be the SendMessage() function.  Is there a 
way to tap into that function from my php script?


winbinder has a function that wraps the SendMessage() function called 
wb_send_message, but after literally 9 hours i quit.


on the MSDN.microsoft site, I saw the functions mouse_event() and 
SendInput() of the user32.dll


http://msdn2.microsoft.com/en-us/library/ms646310.aspx
http://msdn2.microsoft.com/en-us/library/aa932376.aspx

I copied the user32.dll to my php/ext folder and tried loading the 
user32.dll both as an extension directive in php.ini and by using the 
dl() function in my script (dl() is enabled).  However, both methods 
gave me a PHP warning:


as an extension in php.ini it gives the following error:

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 
'user32.dll

'  in Unknown on line 0

get_loaded_extensions() confirms user32.dll never gets loaded.

invoking dl(user32.dll) yields the warning:

PHP Warning:  dl(): Invalid library (maybe not a PHP library) 
'user32.dll'  in [my script]


Possible ideas:
-Load a dll with the dl() function?  (Write the dll with VB or C++)
-use the w32api_register_function() in php somehow to 'tap' into windows 
api functions.

-use a project that can assist me in this like php-gtk2 or winbinder
-maybe someone has a copy of w32api.dll
-something about COM objects, though i am really not familiar

It seems as though the C languages and VB languages can do this. 
Perhaps I could write and compile a dll in that language, somehow load 
it up in php (even though i am having errors doing that currently), then 
I can use those functions in my dll to send my mouse clicks through php.



I am throwing out this question to the community and wondering what your 
suggestions would be for how to go about sending a mouse click event to 
my windows api from a php script.


I am not interested in writing javascript as this is not a web application.

Any thoughts, comments, suggestions, about how to do send mouse events 
from a php script will be much appreciated.


Thanks in advance,


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



Re: [PHP] PHP gives session error on remote server, but not local test machine [SOLVED]

2008-04-07 Thread Dave M G

PHP list,

Solving my own issue:

It turns out that some PHP scripts had an extra carriage return 
character at the end of the file. Once I removed these, the problem went 
away.


Strange that it only happened on some servers, not others, but there it is.

--
Dave M G
Articlass - open source CMS
http://articlass.org

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



Re: [PHP] php local application send mouse click

2008-04-07 Thread Wolf



Daniel Kolbo wrote:

Hello,

I am mostly familiar with php for serving up web pages; however, 
recently I have been writing a local command line script on my WinXP 
machine.  I have spent the better part of this last week and all of 
today trying to figure out a way to send a mouse click to a particular 
window on the screen.


I first saw w32api.dll on the php.net site.  However, I cannot find this 
dll, but this searching took me to winbinder and php-gtk2.  It seems 
that I can only get winbinder to get (not send) mouse information: event 
type and x,y positions.  I am not too familiar with php-gtk nor creating 
dlls.


I want to use my local php command line script on my winXP machine to 
send mouse events (click) to a window.  I am open to any ideas on how to 
do this.


For C++ and VB there seems to be the SendMessage() function.  Is there a 
way to tap into that function from my php script?


winbinder has a function that wraps the SendMessage() function called 
wb_send_message, but after literally 9 hours i quit.


on the MSDN.microsoft site, I saw the functions mouse_event() and 
SendInput() of the user32.dll


http://msdn2.microsoft.com/en-us/library/ms646310.aspx
http://msdn2.microsoft.com/en-us/library/aa932376.aspx

I copied the user32.dll to my php/ext folder and tried loading the 
user32.dll both as an extension directive in php.ini and by using the 
dl() function in my script (dl() is enabled).  However, both methods 
gave me a PHP warning:


as an extension in php.ini it gives the following error:

PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 
'user32.dll

'  in Unknown on line 0

get_loaded_extensions() confirms user32.dll never gets loaded.

invoking dl(user32.dll) yields the warning:

PHP Warning:  dl(): Invalid library (maybe not a PHP library) 
'user32.dll'  in [my script]


Possible ideas:
-Load a dll with the dl() function?  (Write the dll with VB or C++)
-use the w32api_register_function() in php somehow to 'tap' into windows 
api functions.

-use a project that can assist me in this like php-gtk2 or winbinder
-maybe someone has a copy of w32api.dll
-something about COM objects, though i am really not familiar

It seems as though the C languages and VB languages can do this. Perhaps 
I could write and compile a dll in that language, somehow load it up in 
php (even though i am having errors doing that currently), then I can 
use those functions in my dll to send my mouse clicks through php.



I am throwing out this question to the community and wondering what your 
suggestions would be for how to go about sending a mouse click event to 
my windows api from a php script.


I am not interested in writing javascript as this is not a web application.

Any thoughts, comments, suggestions, about how to do send mouse events 
from a php script will be much appreciated.


Thanks in advance,



Trying to send one TO a screen? Good luck with that.  But you really 
should wait at least for a few days for a response from the list before 
reposting the same question with no further information...


What code have you tried?  What code works to a point but fails?

Wolf


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



Re: [PHP] Array pointer to a function

2008-04-07 Thread Nathan Nobbe
On Tue, Apr 8, 2008 at 12:00 AM, hce [EMAIL PROTECTED] wrote:

 Hi,

 Is it possible for an array to point a function:

 Asignmanet

 $ArrayPointer = $this-MyFunction;

 Invoke:

 $ArraryPointer();


i would recommend you investigate variable functions

1.  http://www.php.net/manual/en/functions.variable-functions.php

so you dont exactly get functional language behavior; but you can 'pass
around a function'.  so for example; if you have
?php
function someFunc() {}
/**
 * then you can pass around strings that refer to it; as in
 */
$someFuncPointer = 'someFunc';

/**
 * then you can call it using the variable function construct; as in
 */
$someFuncPointer();  // invoking someFunc()
?

you can pass parameters to such an invocation; as in
?php
$someFuncPointer(1, $b, $yaddaYadda);
?

and it works for object instances
?php
class MyClass { function doStuff() {} }
$b = new MyClass();
$b-doStuff();
?

and it works for static object method calls
?php
class OtherClass { static function doMoreStuff() {} }
$b = 'doMoreStuff';
?

you can also store the class name or instance in variables and it still
works.  here the output of a little php -a session

?php
class M { static function b() {} function n() {} }
$m = 'M';
$b = 'b';
$m::$b();
$n = new M();
$n-b();
$n-$b();
?

and thats just the tip of the iceberg!  there is also the php psuedo type
callback; and there are some other functions that are pertinent.
call_user_func();  // very similar to variable functions
call_user_func_array()

-nathan


Re: [PHP] Array pointer to a function

2008-04-07 Thread Robert Cummings

On Tue, 2008-04-08 at 14:00 +1000, hce wrote:
 Hi,
 
 Is it possible for an array to point a function:
 
 Asignmanet
 
 $ArrayPointer = $this-MyFunction;
 
 Invoke:
 
 $ArraryPointer();

No, you can't do what you've done above. What you can do is...

?php

$ptr = array( 'obj' = $this, 'method' = 'MyFunction' );
$ptr['obj']-$ptr['method']();

?

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



[PHP] Recommended PHP Editors?

2008-04-07 Thread Nitsan Bin-Nun
Hi,
I'm working with serveral PHP editors, each has it own restrictions.
So umm, What editors do you recommend and what special functions and
dis/adventages they have (maybe im overkilling my own back).

Thanks In Advance,
Nitsan


Re: [PHP] Recommended PHP Editors?

2008-04-07 Thread Robert Cummings

On Tue, 2008-04-08 at 07:21 +0200, Nitsan Bin-Nun wrote:
 Hi,
 I'm working with serveral PHP editors, each has it own restrictions.
 So umm, What editors do you recommend and what special functions and
 dis/adventages they have (maybe im overkilling my own back).

This comes up almost once a week. Read the archives.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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