php-general Digest 7 Apr 2008 15:30:56 -0000 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]


----------------------------------------------------------------------
--- Begin Message ---
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 ---
--- Begin Message ---
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 ---
--- Begin Message ---
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 (horrrrrrors).

> 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


--- End Message ---
--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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.

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

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,

--- End Message ---
--- Begin Message ---
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
>
>

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
$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

--- End Message ---
--- Begin Message ---
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/


--- End Message ---
--- Begin Message ---
<?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



--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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





--- End Message ---
--- Begin Message ---
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
> 
> 
> 



--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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.


--- End Message ---
--- Begin Message ---
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]>

--- End Message ---
--- Begin Message ---
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 = 10000;
        $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 = 10000;

        $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


--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message --- 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.
}
?>



--- End Message ---
--- Begin Message ---
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


--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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
>
>



--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---

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

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---

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.



--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
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');
?>

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---
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!

--- End Message ---

Reply via email to