php-general Digest 6 Feb 2007 15:09:21 -0000 Issue 4611

Topics (messages 248417 through 248432):

Re: who is online?
        248417 by: Richard Lynch

Re: is there socket.so file?
        248418 by: Craige Leeder

Re: PHP book reviewers wanted
        248419 by: Manuel Lemos
        248420 by: Manuel Lemos

Re: Regular Expression
        248421 by: Frank Arensmeier

file_get_contents
        248422 by: Steven Macintyre
        248431 by: Colin Guthrie

Re: Writting a simple proxy in PHP
        248423 by: Jochem Maas

Graphs
        248424 by: Kristian Erendi
        248428 by: David Blanco
        248430 by: Jay Blanchard

Re: Converting string representation of a directory to multi-dimensional array
        248425 by: Jochem Maas

All-in-one PHP Classes
        248426 by: Tim
        248429 by: setcookie

Re: Server Stall
        248427 by: Stut
        248432 by: Stut

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 ---
If you use http://php.net/session_start, I guess you could declare
that your session timeout *IS* the definition of current users...

But, really, even at 5 minutes, you may be counting a lot of people
who have LEFT your site.

There is no "real" number for this.

Do whatever you want.

On Mon, February 5, 2007 6:35 am, benifactor wrote:
> i have built a function to tell me how many users are on my site at
> any given time...
> <?
>
> //define function
>
>   function bc_who ($who, $location) {
>
>
>    //first we erase any expired entries
>    //entries will expire after 5 mins
>     $whoTime = time();
>     $whoTime = $whoTime - 300;
>     mysql_query("Delete FROM bc_who where expire < $whoTime") or
> die(mysql_error());
>
>    //here we difine the variables needed to preform the check
>     $whoExpire = time();
>     $whoIp = "$_SERVER[REMOTE_ADDR]";
>
>    //this will be changed as soon as user registration is finished
>     $whoUser= "Guest";
>    //do the actual mysql queries
>
>     mysql_query("Delete FROM bc_who where '$whoIp' = ip");
>     mysql_query("Insert INTO bc_who (id, user, ip, location, expire,
> status) VALUES (NULL, '$whoUser', '$whoIp', '$location',
> '$whoExpire', '$whoStatus')");
>
>
>   }
>
> //end who is function
>
> ?>
>
> this fuction works fine, however, i want to know if what i am about to
> ask is possible.
>
> the problem i have is, this function assumes that after five minutes
> if the user has not refreshed the page, or gone onto another page the
> user must be gone. in reality, i have pages users might be on for an
> hour or so without refreshing. i want my whos online to as acurate as
> possible so is there a way to do this on the fly? like, forgetting
> about the expire time and using a server side peice of code to
> communicate to the database, when there is no more communication the
> entry is deleted? please tell me there is a way, thank you in advance.


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

--- End Message ---
--- Begin Message ---
On 2/5/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
Unless it's PHP 4, and it's already in, or PHP 5 and it's in PECL or...

It's just not that simple.

Sorry.

Ah, I didn't realize they stopped bundling it with PHP as of PHP
5.3.0. That sucks. It used to be that simple.

- Craige

--- End Message ---
--- Begin Message ---
Hello,

on 02/06/2007 12:43 AM Richard Lynch said the following:
>> Often writing books is also not worth the effort. Many authors that
>> try
>> it, only write one book and then give up because the books do not sell
>> enough and they realize they can make more doing something else like
>> consulting.
> 
> If writing the book isn't going to get you paying gigs because you're
> the "expert" having written the book, then you're almost for sure
> going to be getting paid less than minimum wage if you account the
> hours correctly, as I understand it.

Right. Most author write books because they love what they write about.

I know very few people that wrote more than one PHP book. Dedicating
time writing books is a big sacrifice. It is not the most efficient way
to make a living.

Anyway, keep in mind that a US minimum wage is a reasonable amount of
money for people in other countries. Writing books is not such a bad
money if they get published by an US or European publisher.  The whole
PHP community that buy their books should be thankful because some
writers work very hard to make a living.

Some authors of books that I reviewed in the PHPClasses site have
written me asking if I could review their new books. If that encourages
them to keep writing good books, I am pleased to help them.
Unfortunately I do not have the time to review all books that I am asked
to review. That is why I am encouraging other people with more time than
me to work on it.


> I can state for certain that being a Tech Reviewer is even worse pay
> and little odds of it making you any money, really.  Though it is a
> nifty bullet point and gives you something to talk about in a job
> interview, where it can maybe pay off.

Right. Anyway, I am not talking about being Tech Reviewer of books that
were not yet published. I am talking about published books, so there is
not even a money compensation for people that publish reviews in the
PHPClasses site. The only compensation is that reviewers will keep the
review copies for themselves.

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
Hello,

on 02/06/2007 12:39 AM Richard Lynch said the following:
>>> Demonstrating good English writing skills and having published good
>>> book
>>> reviews in the past gets me preference.
>> "gets me preference" ???
>>
>> Me get any money for this?
> 
> Hey, go easy on the non-native speakers...
> 
> I'm betting your Spanish is worse than his English...

Thanks for helping to clarify the "native speakers". Just a minor
correction. My Spanish is not better than my English. I am a native
Portuguese speaker. ;-)

<cultural_moment>Portuguese is also a latin based language like Spanish,
French, Italian and Romanian, but it is a distinct idiom.</cultural_moment>


> [This is aside from the ads jabs some are taking, which is easy to
> solve -- don't use his site.]

Right. After all everybody is free to go anywhere you want or not, with
or without ads.

Anyway, since you brought that up, I would like to clarify that this is
often misunderstood issue. Nobody likes ads, including myself. Ads are
obviously necessary to keep the site viable. Otherwise it would have
been closed a long time ago.

Anyway, for those very intolerant to ads, at least there is an option in
the user options page that the can check to disable pop under and
interstitial ads. This was never a secret, but I am not encouraging
anybody to use that option either. The site needs the ad revenue
generated by all the advertisiment. That option does not disable all
ads, but at least disables probably the most annoying.

For those that would like to see no ads at all and benefit from full
site loading speed, after almost 5 years of promises, in the next months
I will finally launch the package of premium services that among several
other interesting benefits, it will provide an ad free site navigation,
for a small monthly fee.

I know that only those that real care about the site will adhere. But at
least there will finally be an option for all those that avoid visiting
the site because of the ads.

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

--- End Message ---
--- Begin Message ---
5 feb 2007 kl. 22.12 skrev H.T:

Do you know good regular expression editor or something simialar?

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

Regex online: www.regextester.com
//frank

--- End Message ---
--- Begin Message ---
Hiya,

I need to be able to read a file into a string - I have used the above
command and it works ... now ... I need to read a file into a string - that
requires a username and password to access the authentication is normal HTTP
basic realm

Any ideas?



Kind Regards


Steven Macintyre

--

www.friends4friends.co.za 

--- End Message ---
--- Begin Message ---
Steven Macintyre wrote:
> Hiya,
> 
> I need to be able to read a file into a string - I have used the above
> command and it works ... now ... I need to read a file into a string - that
> requires a username and password to access the authentication is normal HTTP
> basic realm
> 
> Any ideas?

$var =
file_get_contents('http://username:[EMAIL PROTECTED]/path/to/secret/file.txt');

This is standard web syntax - e.g. it will work in a web browser, wget,
curl, etc.

Col.

--- End Message ---
--- Begin Message ---
Alessandro Vernet wrote:
> I would like to forward on the server side (also called "proxy" or
> "server-side redirect") some queries that get to my PHP script. A naive
> approach is to do:
> 
> print(implode("", file("http://localhost:8090"; . $REQUEST_URI)));
> 
> Where http://localhost:8090 is the address I want to proxy to. But of
> course, this only works for simple GET requests. It does not forward headers
> (like Authentication), and won't work if the request is a POST.
> 
> Has anyone a suggestion on how I could implement a better proxy? I am not
> looking for a perfect solution. Something that would forward headers and
> handle posts would be good enough.

if your using apache then you should look at the ProxyPass directive - very 
hand,
STW or STA for more detailed info.

> 
> Alex

--- End Message ---
--- Begin Message ---
Hi,

I wish to draw graphs on a web page.
Can someone tell me which extension or package I should use?
Any examples?

TIA Krillo

--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Kristian Erendi escribió:

> I wish to draw graphs on a web page.
> Can someone tell me which extension or package I should use?
> Any examples?

I suppose you mean "Statistical graphs". If such a case, try jpgraph

http://www.aditus.nu/jpgraph/

For a "lower-level interface" you could try the bundled GD extension
and draw lines, point, fill them all, etc. ;)


Greetings from Spain

- --
David Blanco - Programación y sistemas
Publicinet (Publicidad-Cine-Internet, S.L.)
Urzaiz, 71, entlo, izda. -- 36204 Vigo
Telf 902.014.606 -- http://www.publicinet.net


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFyGvSdbgIy1SiWTARArwCAJ488Bg5Rzxdxrab++gfIFkApirNigCbBtcr
jJytDvKzXia7wa3MphI+PfU=
=2dZ9
-----END PGP SIGNATURE-----

--- End Message ---
--- Begin Message ---
[snip]
I wish to draw graphs on a web page.
Can someone tell me which extension or package I should use?
Any examples?
[/snip]

Google for jpgraph

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
> On Mon, February 5, 2007 12:27 pm, Matt Carlson wrote:
>> Over the weekend, I was tasked with taking a string representation of
>> a directory ('\Interface\Addons\<some dir>\<some file>'), which can
>> vary in length (no set number of depths) to a multi-dimensional array
>> (i.e.  array('Interface' => array('Addons' => array('<some dir>' =>
>> <somefile>)));).
>>
>> We came up with a very ugly hack to do it, but I'm curious if anyone
>> can help us wrap our head around a better solution, without using eval
>> (which we were able to find that solution quickly, but do not want to
>> use eval).
>>
>> Our situation is a little unique in the fact that these files don't
>> actually exist on a filesystem, so it makes it a bit more tough to
>> actually create this array.
>>
>> Thanks for any help you can give in cleaning this up somewhat.
>>
>> Here is the function we currently use:
>>
>> <?php
>>
>> $array = array();
>>
>> addToList('\interface\addons\clearfont\clearfont.toc2', $array);
>> addToList('\interface\addons\clearfont\clearfont.toc3', $array);
>> addToList('\interface\addons\clearfont\clearfont.toc4', $array);
>> addToList('\interface\addons\clearfont\clearfont.toc5', $array);
>> addToList('\interface\addons\clearfont\subdir\something.toc', $array);
> 
> function addToList($path){
>   $parts = explode('\\', $path);
>   $result = array();
>   $parts = array_reverse($parts);
>   foreach($parts as $part){
>     //something with array_splice here...
>     $result = array_splice(array($result), $part); //???

array_splice won't cut it as it only splices at 1 level, unless I misunderstood
the OP is looking to dynamically build a multilevel array - which means
either using recursion or 'reference based array digging' (as I like to call it 
;-)

there may also be some kind of solution based on
ArrayArrayArrayIteratorIteratorRecursiveArrayIteratorIteratorRecursiveIterator 
but
personally I don't grok those exotic forms of SPL interface well enough to tell 
you.

>   }
> }
> 

--- End Message ---
--- Begin Message ---
Hello folks,

Have been reading posts daily for two months now on the list, and am very
pleased at how informative these can be.
I have noticed, many examples where one is pointed to using classes
downloadable on the internet. 

Not a very big user of these classes my self (maybe a bit naïf in this
sense, but i just can't have unnecessary code loaded on an include() i like
to keep things clean and to a minimal)I decided to go through and look at
how they are built and what kind of "code load" we are talking about.
This is when i realized how often these classes that do "everything" are
very BIG. Now I realize how many functions this type of class can have and
how handy it can be for someone who does not want to code his own, and yes I
hear all the "reinventing the wheel" comments comming forth as well as
security etc, BUT (yes THE "but") are general classes like this pushing to
using bigger, more bloated web application which require more and more
bandwidth/processor/ram, server-side?

Here, it's the programmer who is confronted with loading huge files into
memory to use just one perhaps two function in a 300+ functionality class..

At what moment does one decide to use an all-in-one "bloated" with "out of
context" functionality, php class, knowing how powerfull only several
functions in this class can be to him?

Shouldn't these classes be perhaps broken down into usefull "parts".

Thanks for any input.

Regards,

Tim

--- End Message ---
--- Begin Message ---
there are special design patterns for autoloading  classes and subclasses to
use only we needed at runtime! this together with singeltons pattern will
prevent any memory overflows. problem is that almost nobody implements these
patterns when designing "standalone" classes

fra*

Hello folks,

Have been reading posts daily for two months now on the list, and am very
pleased at how informative these can be.
I have noticed, many examples where one is pointed to using classes
downloadable on the internet.

Not a very big user of these classes my self (maybe a bit naïf in this
sense, but i just can't have unnecessary code loaded on an include() i like
to keep things clean and to a minimal)I decided to go through and look at
how they are built and what kind of "code load" we are talking about.
This is when i realized how often these classes that do "everything" are
very BIG. Now I realize how many functions this type of class can have and
how handy it can be for someone who does not want to code his own, and yes I
hear all the "reinventing the wheel" comments comming forth as well as
security etc, BUT (yes THE "but") are general classes like this pushing to
using bigger, more bloated web application which require more and more
bandwidth/processor/ram, server-side?

Here, it's the programmer who is confronted with loading huge files into
memory to use just one perhaps two function in a 300+ functionality class..

At what moment does one decide to use an all-in-one "bloated" with "out of
context" functionality, php class, knowing how powerfull only several
functions in this class can be to him?

Shouldn't these classes be perhaps broken down into usefull "parts".

Thanks for any input.

Regards,

Tim

--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
I think php does not open second thread for same session...

Does your script use sessions? If so, then your problem has nothing to do with anything the script is doing and everything to do with PHP locking sessions.

* Request 1 does a start_session(), and PHP locks the session to that request.

* Request 2 comes in and does a start_session(), and PHP finds the session already locked. It will block until the session is unlocked, which will happen when request 1 completes.

Of course if you're not using sessions this message has been a waste of energy and I should go out and plant a tree.

-Stut

--- End Message ---
--- Begin Message ---
Sancar Saran wrote:
Yes you are absolute right.
Session was locked...

Thanks for info  :)

No problem, but please include the list in replies especially when you're confirming a possible explanation. It helps improve the usefulness of the archives.

-Stut

On Tuesday 06 February 2007 13:54, you wrote:
Sancar Saran wrote:
I think php does not open second thread for same session...
Does your script use sessions? If so, then your problem has nothing to
do with anything the script is doing and everything to do with PHP
locking sessions.

* Request 1 does a start_session(), and PHP locks the session to that
request.

* Request 2 comes in and does a start_session(), and PHP finds the
session already locked. It will block until the session is unlocked,
which will happen when request 1 completes.

Of course if you're not using sessions this message has been a waste of
energy and I should go out and plant a tree.

-Stut

--- End Message ---

Reply via email to