php-general Digest 6 Apr 2009 13:50:34 -0000 Issue 6052

Topics (messages 291107 through 291124):

[solved] Re: [PHP] phpMyAdmin, suhosin, proper solutions
        291107 by: Michael A. Peters

PHP bandwidth control
        291108 by: JD
        291109 by: Paul M Foster
        291110 by: 9el
        291122 by: Yannick Mortier
        291123 by: Michael A. Peters

Re: PHP class or functions to manipulate PDF metadata?
        291111 by: Peter Ford

[php] while loop failure
        291112 by: Andrew Williams
        291114 by: Chetan Rane
        291115 by: Andrew Williams
        291116 by: Andrew Williams

kill php.exe window
        291113 by: Andrew Williams
        291117 by: Marc
        291118 by: Andrew Williams
        291121 by: Stuart

php and =&
        291119 by: Michael A. Peters
        291120 by: Marc
        291124 by: Michael A. Peters

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 ---
Michael A. Peters wrote:
Chris wrote:
Yes, I read the documentation on how to make them play nice, and to me it is unacceptable to change suhosin settings intended to protect my users and my site from a malicious user so that I can use a web app that is not open to the public.

No idea what the problems are (couldn't find a list of what the problems are) but

Can you change the suhosin settings with a .htaccess? With the apache htpasswd protection it should be ok to disable some stuff for a particular directory.


I don't think you can change suhosin directive in a .htaccess file.

Yes - you can (well, I didn't try in .htaccess - I did so in the apache config file itself).

That solves everything :)


<Directory "/srv/shastaherps/phpMyAdmin-3.1.3.1-english">
  AuthUserFile /somesecretpath/.htpasswd
  AuthType basic
  Require valid-user
  AuthName "Authentication Required"
  php_flag suhosin.executor.disable_eval Off
</Directory>

At least that works (allowing me to disable eval everywhere else) - so I'm guessing it should work with the other stuff as well.

Thanks for the suggestion, I just assumed it wouldn't work as changing suhosin stuff via ini_set doesn't seem to work (understandably).
--- End Message ---
--- Begin Message ---
Hello,

I am relatively new to PHP and am trying to make a video/image sharing site for 
my family to upload and share family videos and pictures. My concern is that 
because I'm hosting this site at my house, I will quickly exceed my bandwidth 
limitations each month if all the family members I think will use the site do 
actually end up using it. What I'd like to do is set up each family member with 
their own login and track how much bandwidth they use and cap it after a 
certain amount. The login stuff is easy and I have that figured out, but I 
haven't been able to figure out a good way to track the bandwidth used by each 
user that logs in. Is there a good way to do this with PHP?

Thanks,
Dave

____________________________________________________________
Click here for free information on how to reduce your debt by filing for 
bankruptcy.
http://thirdpartyoffers.netzero.net/TGL2231/fc/BLSrjnxXKInZ3kl2SDnqN7ifO3PSaE96m9RMpRCn9agvvsomFpM5Y0grTAM/

--- End Message ---
--- Begin Message ---
On Mon, Apr 06, 2009 at 03:58:45AM +0000, JD wrote:

> Hello,
> 
> I am relatively new to PHP and am trying to make a video/image sharing site 
> for my family to upload and share family videos and pictures. My concern is 
> that because I'm hosting this site at my house, I will quickly exceed my 
> bandwidth limitations each month if all the family members I think will use 
> the site do actually end up using it. What I'd like to do is set up each 
> family member with their own login and track how much bandwidth they use and 
> cap it after a certain amount. The login stuff is easy and I have that 
> figured out, but I haven't been able to figure out a good way to track the 
> bandwidth used by each user that logs in. Is there a good way to do this with 
> PHP?
> 
> Thanks,
> Dave

I don't have the answer to your question, but why not do this over
YouTube or some site like that? There are no bandwidth limitations, you
can make videos private, etc.

Paul
-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Mon, Apr 6, 2009 at 10:09 AM, Paul M Foster <[email protected]>wrote:

> On Mon, Apr 06, 2009 at 03:58:45AM +0000, JD wrote:
>
> > Hello,
> >
> > I am relatively new to PHP and am trying to make a video/image sharing
> site for my family to upload and share family videos and pictures. My
> concern is that because I'm hosting this site at my house, I will quickly
> exceed my bandwidth limitations each month if all the family members I think
> will use the site do actually end up using it. What I'd like to do is set up
> each family member with their own login and track how much bandwidth they
> use and cap it after a certain amount. The login stuff is easy and I have
> that figured out, but I haven't been able to figure out a good way to track
> the bandwidth used by each user that logs in. Is there a good way to do this
> with PHP?
> >
>
 Modlogan, Awestats, webalizer these are some tools for measuring such. Also
there's cPanel software which tracks per account.

and why dont you use services like Youtube/Viddler for that purpose?

--- End Message ---
--- Begin Message ---
2009/4/6 JD <[email protected]>:
> Hello,
>
> I am relatively new to PHP and am trying to make a video/image sharing site 
> for my family to upload and share family videos and pictures. My concern is 
> that because I'm hosting this site at my house, I will quickly exceed my 
> bandwidth limitations each month if all the family members I think will use 
> the site do actually end up using it. What I'd like to do is set up each 
> family member with their own login and track how much bandwidth they use and 
> cap it after a certain amount. The login stuff is easy and I have that 
> figured out, but I haven't been able to figure out a good way to track the 
> bandwidth used by each user that logs in. Is there a good way to do this with 
> PHP?
>
> Thanks,
> Dave
>
> ____________________________________________________________
> Click here for free information on how to reduce your debt by filing for 
> bankruptcy.
> http://thirdpartyoffers.netzero.net/TGL2231/fc/BLSrjnxXKInZ3kl2SDnqN7ifO3PSaE96m9RMpRCn9agvvsomFpM5Y0grTAM/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

I guess there are multiple ways to engage this problem. It depends how
"deep" you want to log the traffic. If you just want to count the
traffic of each image, video etc you could just wrap up each image and
video to go through php first with file_get_contents() (look in the
php manual there are some examples how to work with this), count how
many bytes of data will be sent out and log this in a database or
however you want to do this.
If the bandwith limit is exceeded you don't deliver the image anymore
and display an error message instead.

If you want to catch all traffic you must parse the log files from you
webserver. To do this you could save the IP with which the login of
the user was performed and connect all traffic that was done by that
IP to the User. If the traffic limit is exceeded you display an error
message.

I guess for some family-internal sharing the first approach should be
good enough. Just make sure you take some bandwith for the html pages
into your calculations.

-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me on twitter!
http://twitter.com/moortier

--- End Message ---
--- Begin Message ---
Yannick Mortier wrote:
2009/4/6 JD <[email protected]>:
Hello,

I am relatively new to PHP and am trying to make a video/image sharing site for 
my family to upload and share family videos and pictures. My concern is that 
because I'm hosting this site at my house, I will quickly exceed my bandwidth 
limitations each month if all the family members I think will use the site do 
actually end up using it. What I'd like to do is set up each family member with 
their own login and track how much bandwidth they use and cap it after a 
certain amount. The login stuff is easy and I have that figured out, but I 
haven't been able to figure out a good way to track the bandwidth used by each 
user that logs in. Is there a good way to do this with PHP?

Thanks,
Dave

____________________________________________________________
Click here for free information on how to reduce your debt by filing for 
bankruptcy.
http://thirdpartyoffers.netzero.net/TGL2231/fc/BLSrjnxXKInZ3kl2SDnqN7ifO3PSaE96m9RMpRCn9agvvsomFpM5Y0grTAM/

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



I guess there are multiple ways to engage this problem. It depends how
"deep" you want to log the traffic. If you just want to count the
traffic of each image, video etc you could just wrap up each image and
video to go through php first with file_get_contents() (look in the
php manual there are some examples how to work with this), count how
many bytes of data will be sent out and log this in a database or
however you want to do this.
If the bandwith limit is exceeded you don't deliver the image anymore
and display an error message instead.

If you want to catch all traffic you must parse the log files from you
webserver. To do this you could save the IP with which the login of
the user was performed and connect all traffic that was done by that
IP to the User. If the traffic limit is exceeded you display an error
message.

I guess for some family-internal sharing the first approach should be
good enough. Just make sure you take some bandwith for the html pages
into your calculations.


My suggestion would be to do it on a real server and avoid any and all ISP restrictions, present and future.

Don't register your domain with your host though, I found it to be a real PITA to switch hosts when you use them as your registrar, getting them to relinquish control of the domain can be a PITA.

Instead register with someone like godaddy that lets you specify the nameservers and host elsewhere. Then if you feel like you need to move it to a different host, your current host can't be jerks about it.
--- End Message ---
--- Begin Message ---
O. Lavell wrote:
> Hi group,
> 
> I am looking for an easy way to manipulate (read, write) the metadata 
> (title, subject, keywords, author) in PDF files through PHP.
> 
> Most PHP/PDF solutions I have found so far (through Google) are aimed at 
> constructing PDFs from text and graphics, with lots of fancy features, 
> but most of them omit metadata functions altogether.
> 
> I would also prefer something extremely lightweight that I could just 
> include_once() into my script, i.e. not a module or external program. I 
> am currently using pdfinfo from xpdf-utils, but it has to go.
> 
> My use case is I want to build a database with the metadata of a bunch 
> (many hundreds, perhaps thousands) of PDF files in a directory on the 
> server for easy search, statistics and retrieval. I also want users to be 
> able to make edits to any PDF's metadata from the web.
> 
> If it can be at all avoided, I would rather not have to invent the wheel 
> myself here. I have looked at the Adobe PDF specification a bit and it 
> looks quite... challenging. Or should I say daunting.
> 
> Any and all suggestions are welcome. Thank you in advance.
> 

So many people ask about manipulating, editing and generally processing PDF
files. In my experience, PDF is a write-once format - any manipulation should
have been done in whatever source generated the PDF. I think of a PDF as being a
piece of paper: if you want to change the content of a piece of paper it is
usually best to chuck it away and start again...

Even more so, this would apply to the PDF metadata: metadata is supposed to
describe the nature of the document: it's author, creation time etc. That sort
of data should be maintained with the document and ideally not changed
throughout the document's lifetime (like the footer, or end-papers in a physical
book)

I do accept that the metadata should be machine-readable: that part of your
project is reasonable and I'm fairly sure that ought to be possible with
something simple. The best bet I found so far is PDFTK
(http://www.pdfhacks.com/pdftk/) which is a command-line tool that you could
presumably call with exec or whatever...


-- 
Peter Ford                              phone: 01580 893333
Developer                               fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

--- End Message ---
--- Begin Message ---
Does any one knows why while loop below ends after few loops when it meant
to keep in loop?

File name: while_loop_script.php

define('run', 0);
define('START', 10);

while(START >run){

$ch = curl_init("mydomain/update_script.php?action=run");
curl_exec($ch);
curl_close($ch);

}

using php.exe to scheldule task it every 5 minutes:

C:\php.exe D:\update\while_loop_script.php

-- 
www.willandy.co.uk

--- End Message ---
--- Begin Message ---
I think its exceeding the max execution time set in PHP.ini
Either set yoru cron to run after every 60 seconds, or change the setting in 
PHP.ini

Chetan Dattaram Rane | Software Engineer | Persistent Systems
[email protected]  | Cell: +91 94033 66714 | Tel: +91 (0832) 30 79014
Innovation in software product design, development and delivery- 
www.persistentsys.com




-----Original Message-----
From: Andrew Williams [mailto:[email protected]]
Sent: Monday, April 06, 2009 3:51 PM
To: [email protected]
Subject: [PHP] [php] while loop failure

Does any one knows why while loop below ends after few loops when it meant
to keep in loop?

File name: while_loop_script.php

define('run', 0);
define('START', 10);

while(START >run){

$ch = curl_init("mydomain/update_script.php?action=run");
curl_exec($ch);
curl_close($ch);

}

using php.exe to scheldule task it every 5 minutes:

C:\php.exe D:\update\while_loop_script.php

--
www.willandy.co.uk

DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.

--- End Message ---
--- Begin Message ---
The php.ini maximum time is set to -1 which is infinity

On Mon, Apr 6, 2009 at 11:27 AM, Chetan Rane
<[email protected]>wrote:

> I think its exceeding the max execution time set in PHP.ini
> Either set yoru cron to run after every 60 seconds, or change the setting
> in PHP.ini
>
> Chetan Dattaram Rane | Software Engineer | Persistent Systems
> [email protected]  | Cell: +91 94033 66714 | Tel: +91 (0832) 30
> 79014
> Innovation in software product design, development and delivery-
> www.persistentsys.com
>
>
>
>
> -----Original Message-----
> From: Andrew Williams [mailto:[email protected]]
> Sent: Monday, April 06, 2009 3:51 PM
> To: [email protected]
> Subject: [PHP] [php] while loop failure
>
> Does any one knows why while loop below ends after few loops when it meant
> to keep in loop?
>
> File name: while_loop_script.php
>
> define('run', 0);
> define('START', 10);
>
> while(START >run){
>
> $ch = curl_init("mydomain/update_script.php?action=run");
> curl_exec($ch);
> curl_close($ch);
>
> }
>
> using php.exe to scheldule task it every 5 minutes:
>
> C:\php.exe D:\update\while_loop_script.php
>
> --
> www.willandy.co.uk
>
> DISCLAIMER
> ==========
> This e-mail may contain privileged and confidential information which is
> the property of Persistent Systems Ltd. It is intended only for the use of
> the individual or entity to which it is addressed. If you are not the
> intended recipient, you are not authorized to read, retain, copy, print,
> distribute or use this message. If you have received this communication in
> error, please notify the sender and delete all copies of this message.
> Persistent Systems Ltd. does not accept any liability for virus infected
> mails.
>



-- 
Best Wishes
Andrew Williams

--- End Message ---
--- Begin Message ---
setting:

max_execution_time = -1     ; Maximum execution time of each script, in
seconds
max_input_time = -1    ; Maximum amount of time each script may spend
parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 2036M      ; Maximum amount of memory a script may consume
(128MB)

the above setting should allowed script to execute indefinitely. is't it?

On Mon, Apr 6, 2009 at 11:29 AM, Andrew Williams
<[email protected]>wrote:

> The php.ini maximum time is set to -1 which is infinity
>
>
> On Mon, Apr 6, 2009 at 11:27 AM, Chetan Rane <[email protected]
> > wrote:
>
>> I think its exceeding the max execution time set in PHP.ini
>> Either set yoru cron to run after every 60 seconds, or change the setting
>> in PHP.ini
>>
>> Chetan Dattaram Rane | Software Engineer | Persistent Systems
>> [email protected]  | Cell: +91 94033 66714 | Tel: +91 (0832)
>> 30 79014
>> Innovation in software product design, development and delivery-
>> www.persistentsys.com
>>
>>
>>
>>
>> -----Original Message-----
>> From: Andrew Williams [mailto:[email protected]]
>> Sent: Monday, April 06, 2009 3:51 PM
>> To: [email protected]
>> Subject: [PHP] [php] while loop failure
>>
>> Does any one knows why while loop below ends after few loops when it meant
>> to keep in loop?
>>
>> File name: while_loop_script.php
>>
>> define('run', 0);
>> define('START', 10);
>>
>> while(START >run){
>>
>> $ch = curl_init("mydomain/update_script.php?action=run");
>> curl_exec($ch);
>> curl_close($ch);
>>
>> }
>>
>> using php.exe to scheldule task it every 5 minutes:
>>
>> C:\php.exe D:\update\while_loop_script.php
>>
>> --
>> www.willandy.co.uk
>>
>> DISCLAIMER
>> ==========
>> This e-mail may contain privileged and confidential information which is
>> the property of Persistent Systems Ltd. It is intended only for the use of
>> the individual or entity to which it is addressed. If you are not the
>> intended recipient, you are not authorized to read, retain, copy, print,
>> distribute or use this message. If you have received this communication in
>> error, please notify the sender and delete all copies of this message.
>> Persistent Systems Ltd. does not accept any liability for virus infected
>> mails.
>>
>
>
>
> --
> Best Wishes
> Andrew Williams
>
>
>


-- 
Best Wishes
Andrew Williams

--- End Message ---
--- Begin Message ---
I need to exit php.exe window after completing an assigned task. Does anyone
knows how to close, exit,  kill or stop the window

-- 
willandy.co.uk

--- End Message ---
--- Begin Message ---
>I need to exit php.exe window after completing an assigned task. Does anyone
>knows how to close, exit,  kill or stop the window

Run your PHP.exe by using appending "& exit" to your command. For instance:

php.exe [YOUR COMMAND ARGS] & exit

Greetings from Germany

Marc

--
Sync and share your files over the web for free
http://bithub.net/

My Twitter feed
http://twitter.com/MarcSteinert


--- End Message ---
--- Begin Message ---
I mean How do I kill it automatically via script and not command line:

File name: while_loop_script.php


$ch = curl_init("mydomain/update_script.php?action=run");
curl_exec($ch);
curl_close($ch);

{exit or kill  script}

window schedule task:
run box: php.exe to scheldule task it every 5 minutes:

C:\php.exe D:\update\while_loop_script.php


On Mon, Apr 6, 2009 at 11:39 AM, Marc <[email protected]> wrote:

> >I need to exit php.exe window after completing an assigned task. Does
> anyone
> >knows how to close, exit,  kill or stop the window
>
> Run your PHP.exe by using appending "& exit" to your command. For instance:
>
> php.exe [YOUR COMMAND ARGS] & exit
>
> Greetings from Germany
>
> Marc
>
> --
> Sync and share your files over the web for free
> http://bithub.net/
>
> My Twitter feed
> http://twitter.com/MarcSteinert
>
>


-- 
Best Wishes
Andrew Williams

--- End Message ---
--- Begin Message ---
2009/4/6 Andrew Williams <[email protected]>:
> I mean How do I kill it automatically via script and not command line:
>
> File name: while_loop_script.php
>
>
> $ch = curl_init("mydomain/update_script.php?action=run");
> curl_exec($ch);
> curl_close($ch);
>
> {exit or kill  script}
>
> window schedule task:
> run box: php.exe to scheldule task it every 5 minutes:
>
> C:\php.exe D:\update\while_loop_script.php

It's been a while since I've used PHP on Windows but IIRC you want to
be using php-cli.exe not php.exe.

-Stuart

-- 
http://stut.net/

> On Mon, Apr 6, 2009 at 11:39 AM, Marc <[email protected]> wrote:
>
>> >I need to exit php.exe window after completing an assigned task. Does
>> anyone
>> >knows how to close, exit,  kill or stop the window
>>
>> Run your PHP.exe by using appending "& exit" to your command. For instance:
>>
>> php.exe [YOUR COMMAND ARGS] & exit
>>
>> Greetings from Germany
>>
>> Marc
>>
>> --
>> Sync and share your files over the web for free
>> http://bithub.net/
>>
>> My Twitter feed
>> http://twitter.com/MarcSteinert
>>
>>
>
>
> --
> Best Wishes
> Andrew Williams
>

--- End Message ---
--- Begin Message ---
I'm looking through various documentation on MDB2

In some examples the assignment operator looks like it is mixed with a bitwise or logic operator - IE

$mdb2 =& MDB2::factory($dsn);

Other examples though just have

$mdb2 = MDB2::factory($dsn);

I'm trying to figure out exactly what =& does, why people would use it, and when it is appropriate to use, but I haven't found anything and I think my google skills need some practice as I don't know how to search for =& in google.

In the php manual on operators I did fine &= discussed but that's the flip and it's use makes no sense in the context of setting a database handle.

Any tips would be appreciated.

--- End Message ---
--- Begin Message ---
>I'm looking through various documentation on MDB2
>
>In some examples the assignment operator looks like it is mixed with a 
>bitwise or logic operator - IE
>
>$mdb2 =& MDB2::factory($dsn);
>
>Other examples though just have
>
>$mdb2 = MDB2::factory($dsn);
>
>I'm trying to figure out exactly what =& does, why people would use it, 
>and when it is appropriate to use, but I haven't found anything and I 
>think my google skills need some practice as I don't know how to search 
>for =& in google.
>
>In the php manual on operators I did fine &= discussed but that's the 
>flip and it's use makes no sense in the context of setting a database 
>handle.
>
>Any tips would be appreciated.

With the =& operator, PHP creates references:

http://phpbuilder.com/manual/en/language.references.whatdo.php

Greetings from Germany

Marc

--
Sync and share your files over the web for free
http://bithub.net/

My Twitter feed
http://twitter.com/MarcSteinert

--- End Message ---
--- Begin Message ---
Marc wrote:
I'm looking through various documentation on MDB2

In some examples the assignment operator looks like it is mixed with a bitwise or logic operator - IE

$mdb2 =& MDB2::factory($dsn);

Other examples though just have

$mdb2 = MDB2::factory($dsn);

With the =& operator, PHP creates references:

http://phpbuilder.com/manual/en/language.references.whatdo.php

Ah thank you!
I guess I have a lot of reading to do.
It looks like it acts somewhat like hard links on a filesystem, but not always.


Greetings from Germany

My mother was born there :)

--- End Message ---

Reply via email to