|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help
lists.php.net
Date: Wed May 02 2007 - 15:58:45 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 2 May 2007 20:58:45 -0000 Issue 4769
Topics (messages 254217 through 254274):
Re: Sending the results of a query without using a file
254217 by: clive
254220 by: Tijnema !
254262 by: Richard Lynch
Re: Split string
254218 by: Fredrik Thunberg
254221 by: Lester Caine
254222 by: Stut
254223 by: Stut
254244 by: Al
254259 by: Richard Lynch
254261 by: Richard Lynch
Re: PHP Command line script
254219 by: Peter Lauri
254247 by: Nathaniel Hall
254265 by: Richard Lynch
Sockets as a module or a separate PHP CLI instance?
254224 by: list3.truswan.com
254226 by: Man-wai Chang
254227 by: Oliver Block
254228 by: Oliver Block
254258 by: Richard Lynch
Extract and verify SSL signature form x509 certificate.
254225 by: "D.EIiM - Lluís Pàmies i Juarez"
Re: Deviation? Distribution? OT?
254229 by: tedd
254263 by: Richard Lynch
254264 by: Richard Lynch
[X-POST] Fastest way to dump this huge table
254230 by: Brian Dunning
254231 by: Jay Blanchard
254232 by: Richard Davey
254233 by: David Giragosian
254234 by: clive
254241 by: Colin Guthrie
254256 by: Richard Lynch
Re: About resource of popen
254235 by: Fernando chucre
PHP's ldap_sasl_bind tries to authenticate with KRB5CCNAME other than the one provided by mod_auth_kerb
254236 by: gil ran
254255 by: Richard Lynch
excel macro into php
254237 by: Anton Krall
INSERT Array Values into mySQL Table
254238 by: Rahul S. Johari
254239 by: Brad Fuller
254240 by: David Giragosian
254242 by: Jim Moseby
254243 by: Rahul Sitaram Johari
254245 by: Brad Fuller
254253 by: Richard Lynch
254254 by: Richard Lynch
Re: INSERT Array Values into mySQL Table - SOLVED!
254246 by: Rahul Sitaram Johari
Bounce composition
254248 by: Richard Lynch
254260 by: Oliver Block
Discussion of bug #39062
254249 by: Bill Moran
254250 by: Robert Cummings
254251 by: Daevid Vincent
254252 by: Richard Lynch
MySQL change-tracking
254257 by: Richard Lynch
Re: resize image and store it to DB
254266 by: Richard Lynch
Re: newbie needs help
254267 by: Richard Lynch
Re: What does "<<<" mean?
254268 by: Richard Lynch
254269 by: Richard Lynch
254270 by: Richard Lynch
254271 by: Richard Lynch
254272 by: Richard Lynch
254273 by: Daniel Brown
254274 by: Daniel Brown
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Todd Cary wrote:
> Some shared servers do not allow the creation of a file, so I am looking
> for a way to take the results of a query (MySQL), create a CSV output
> and have it in a sendable format for the user without creating a file.
>
are you sure, then how could you say ftp the files to the server, are
you not trying to create files in the wrong directory?
hmm if you want to allow the user to download the file, then just send
the correct headers, using the header() function, for the csv format and
then echo the contents of the file.
remember your application may spit out some other bits of text and this
will interfere with sending the headers so you may also need to look at
the output control functions to clean the outout buffer and then send
your headers and data:
http://www.php.net/manual/en/ref.outcontrol.php
Regards,
Clive.
{No electrons were harmed in the creation, transmission or reading of
this email. However, many were excited and some may well have enjoyed
the experience.}
attached mail follows:
On 5/2/07, clive <clive
rttc.co.za> wrote:
> Todd Cary wrote:
> > Some shared servers do not allow the creation of a file, so I am looking
> > for a way to take the results of a query (MySQL), create a CSV output
> > and have it in a sendable format for the user without creating a file.
>
> >
> are you sure, then how could you say ftp the files to the server, are
> you not trying to create files in the wrong directory?
I have that too on one of my shared hosts, I can't create any files in
my home directory, because the PHP user doesn't have access rights
there, chmodding all directories did fix, (done through SSH). Before i
figured out that I could chmod all directories, I found out that it
does allow me to write in /tmp, and so i stored my files there, but
only temporary of course, because /tmp is cleaned regularly
>
> hmm if you want to allow the user to download the file, then just send
> the correct headers, using the header() function, for the csv format and
> then echo the contents of the file.
Yep, that's the correct way.
>
> remember your application may spit out some other bits of text and this
> will interfere with sending the headers so you may also need to look at
> the output control functions to clean the outout buffer and then send
> your headers and data:
> http://www.php.net/manual/en/ref.outcontrol.php
>
> Regards,
>
> Clive.
I don't think that you will need output buffering, most functions
allow you (or only) return values.
Tijnema
>
>
attached mail follows:
On Wed, May 2, 2007 2:17 am, Todd Cary wrote:
> Some shared servers do not allow the creation of a file, so I am
> looking for a way to take the results of a query (MySQL), create
> a CSV output and have it in a sendable format for the user
> without creating a file.
$result = mysql_query("select * from something");
$output = fopen('php://output', 'w') or die("I messed up the php://
bit");
header("Content-type: application/octet-stream"); //force download
while ($row = mysql_fetch_row($result)){
fputcsv($output, $row);
}
//Look ma, no file!
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
Lester Caine skrev:
> Can someone with a few more working grey cells prompt me with the
> correct command to split a string.
>
> The entered data is names, but I need to split the text up to the first
> space or comma into one string, and the rest of the string into a
> second. It's the 'first either space or comma' that eludes me at the
> moment :(
>
> In know it's probably obvious, but it always is when you know the answer.
>
$myString = "John Doe";
$pos = strpos($myString, " ") < strpos($myString, ",") ?
strpos($myString, " ") : strpos($myString, ",");
$part1 = substr($myString, 0, $pos);
$part2 = substr($myString, $pos);
/T
attached mail follows:
Fredrik Thunberg wrote:
> Lester Caine skrev:
>> Can someone with a few more working grey cells prompt me with the
>> correct command to split a string.
>>
>> The entered data is names, but I need to split the text up to the
>> first space or comma into one string, and the rest of the string into
>> a second. It's the 'first either space or comma' that eludes me at the
>> moment :(
>>
>> In know it's probably obvious, but it always is when you know the answer.
>
> $myString = "John Doe";
>
> $pos = strpos($myString, " ") < strpos($myString, ",") ?
> strpos($myString, " ") : strpos($myString, ",");
>
> $part1 = substr($myString, 0, $pos);
> $part2 = substr($myString, $pos);
I'm glad I asked now, that is a lot nicer than trying to get the preg_split
thing working :)
--
Lester Caine - G8HFL
-----------------------------
Contact - http://home.lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://home.lsces.co.uk
MEDW - http://home.lsces.co.uk/ModelEngineersDigitalWorkshop/
Firebird Foundation Inc. - http://www.firebirdsql.org/index.php
attached mail follows:
Fredrik Thunberg wrote:
> Lester Caine skrev:
>> Can someone with a few more working grey cells prompt me with the
>> correct command to split a string.
>>
>> The entered data is names, but I need to split the text up to the
>> first space or comma into one string, and the rest of the string into
>> a second. It's the 'first either space or comma' that eludes me at the
>> moment :(
>>
>> In know it's probably obvious, but it always is when you know the answer.
>>
>
> $myString = "John Doe";
>
> $pos = strpos($myString, " ") < strpos($myString, ",") ?
> strpos($myString, " ") : strpos($myString, ",");
Suggest the following as being more efficient (half the strpos calls)...
$pos = min(strpos($myString, " "), strpos($myString, ","));
Alternatively you could use split to break the string into the two
parts, which is probably more efficient...
list($part1, $part2) = split('[ ,]', $myString);
-Stut
attached mail follows:
Stut wrote:
> Alternatively you could use split to break the string into the two
> parts, which is probably more efficient...
>
> list($part1, $part2) = split('[ ,]', $myString);
Oops, this should have a third parameter...
list($part1, $part2) = split('[ ,]', $myString, 2);
-Stut
attached mail follows:
Look at split() and explode().
Lester Caine wrote:
> Can someone with a few more working grey cells prompt me with the
> correct command to split a string.
>
> The entered data is names, but I need to split the text up to the first
> space or comma into one string, and the rest of the string into a
> second. It's the 'first either space or comma' that eludes me at the
> moment :(
>
> In know it's probably obvious, but it always is when you know the answer.
>
attached mail follows:
On Wed, May 2, 2007 3:55 am, Lester Caine wrote:
> Can someone with a few more working grey cells prompt me with the
> correct
> command to split a string.
>
> The entered data is names, but I need to split the text up to the
> first space
> or comma into one string, and the rest of the string into a second.
> It's the
> 'first either space or comma' that eludes me at the moment :(
>
> In know it's probably obvious, but it always is when you know the
> answer.
One of these should have an example to get you where you need to be:
http://php.net/split
http://php.net/preg_split
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Wed, May 2, 2007 4:55 am, Lester Caine wrote:
> Fredrik Thunberg wrote:
>> Lester Caine skrev:
>>> Can someone with a few more working grey cells prompt me with the
>>> correct command to split a string.
>>>
>>> The entered data is names, but I need to split the text up to the
>>> first space or comma into one string, and the rest of the string
>>> into
>>> a second. It's the 'first either space or comma' that eludes me at
>>> the
>>> moment :(
>>>
>>> In know it's probably obvious, but it always is when you know the
>>> answer.
>>
>> $myString = "John Doe";
>>
>> $pos = strpos($myString, " ") < strpos($myString, ",") ?
>> strpos($myString, " ") : strpos($myString, ",");
>>
>> $part1 = substr($myString, 0, $pos);
>> $part2 = substr($myString, $pos);
>
> I'm glad I asked now, that is a lot nicer than trying to get the
> preg_split
> thing working :)
Hnmmm. Okay, I'll take a shot at it:
$answer = preg_split('|[, ]|', $myString);
var_dump($answer);
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
Check the error from mysqli:
http://fi.php.net/manual/en/function.mysqli-error.php
Best regards,
Peter Lauri
www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free
> -----Original Message-----
> From: Nathaniel Hall [mailto:lists
spider-security.net]
> Sent: Tuesday, May 01, 2007 10:13 PM
> To: php-general
lists.php.net
> Subject: [PHP] PHP Command line script
>
> I am attempting to run a script that will run from the command line
> nightly to update a field in a database. I already created a script
> that would access the database and insert most of the information when a
> webpage is visited and I had no problems with it. The command line
> script appears to fail on the prepare. I have echo'ed the SQL statement
> to the screen, copied it, and run it on the MySQL server with no
> problems. Any ideas?
>
> <?php
> $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
> if (mysqli_connect_errno()) {
> echo "Unable to connect to database.\n";
> exit;
> } else {
> $login = date('m\-d\-Y');
> if ($logout = $mysqli->prepare("UPDATE `mydb`.`authlog`
> SET `logout` = ? WHERE `login` LIKE '$login%'")) { // <--- Will not go
> any further than here, even when hard coding the information.
> $logout->bind_param("s", date('m\-d\-
> Y\TH\:i\:s'));
> $logout->execute();
> $logout->close();
> }
> }
> $mysqli->close();
> ?>
>
> --
> Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
> Spider Security
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Greg Donald wrote:
>
> On 5/1/07, Nathaniel Hall <lists
spider-security.net> wrote:
> > I am attempting to run a script that will run from the command line
> > nightly to update a field in a database. I already created a script
> > that would access the database and insert most of the information when a
> > webpage is visited and I had no problems with it. The command line
> > script appears to fail on the prepare. I have echo'ed the SQL statement
> > to the screen, copied it, and run it on the MySQL server with no
> > problems. Any ideas?
> >
> > <?php
> > $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
> > if (mysqli_connect_errno()) {
> > echo "Unable to connect to database.\n";
> > exit;
> > } else {
> > $login = date('m\-d\-Y');
> > if ($logout = $mysqli->prepare("UPDATE `mydb`.`authlog`
> > SET `logout` = ? WHERE `login` LIKE '$login%'")) { // <--- Will not go
> > any further than here, even when hard coding the information.
> > $logout->bind_param("s",
> date('m\-d\-Y\TH\:i\:s'));
> > $logout->execute();
> > $logout->close();
> > }
> > }
> > $mysqli->close();
> > ?>
>
>
> Add full error reporting, then make sure you can see the errors, then
> test to see if you have the mysqli extension:
>
> error_reporting( E_ALL );
> ini_set( 'display_errors', 1 );
> ini_set( 'log_errors', 1 );
>
> if( !in_array( 'mysqli', get_loaded_extensions() ) )
> {
> die( 'no mysqli found' );
> }
>
I get no errors and I have verified that mysqli is loaded.
>
> Also, why do you need to escape the dashes in the date() calls?
>
> > php -r 'echo date("Y-m-d");'
> 2007-05-01
>
Habit.
--
Nathaniel Hall, GSEC GCFW GCIA GCIH GCFA
Spider Security
attached mail follows:
On Tue, May 1, 2007 3:13 pm, Nathaniel Hall wrote:
> <?php
> $mysqli = new mysqli('localhost', 'root', 'abc123', 'mydb');
> if (mysqli_connect_errno()) {
> echo "Unable to connect to database.\n";
> exit;
> } else {
> $login = date('m\-d\-Y');
> if ($logout = $mysqli->prepare("UPDATE
> `mydb`.`authlog`
> SET `logout` = ? WHERE `login` LIKE '$login%'")) { // <--- Will not
> go
> any further than here, even when hard coding the information.
> $logout->bind_param("s",
> date('m\-d\-Y\TH\:i\:s'));
> $logout->execute();
> $logout->close();
> }
//ALWAYS do your error-checking!!!
else{
die(mysqli_error());
}
//You may want to put the query in $query so you can print that
//as part of the 'die' output
> }
> $mysqli->close();
> ?>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
I need to do some socket work on a production machine that is constantly
busy so I don't dare re-compile php. Anybody know if it's possible to load
the socket functions dynamically, maybe as if they were in a module?
Alternatively, would it be possible to compile PHP without apache and with
sockets for command line use only? If I do that I would like to give the
resulting object a different name than PHP because I do have some cmd line
pgms running on the machine. Is that difficult?
Tx,
Paul W
attached mail follows:
list3
truswan.com wrote:
> I need to do some socket work on a production machine that is constantly
> busy so I don't dare re-compile php. Anybody know if it's possible to load
> the socket functions dynamically, maybe as if they were in a module?
I think both Fedora Core and Ubuntu do it. Check out their RPM/DEB spec
file for compiling the packages.
--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10) Linux 2.6.21.1
^ ^ 19:58:01 up 4 days 4:51 0 users load average: 0.06 0.11 0.04
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk
attached mail follows:
Am Mittwoch, 2. Mai 2007 13:29 schrieb list3
truswan.com:
> I need to do some socket work on a production machine that is constantly
> busy so I don't dare re-compile php. Anybody know if it's possible to load
> the socket functions dynamically, maybe as if they were in a module?
It's possible if it's possible to compile it as shared object. It is, as far
as I know.
--with-socket=shared
There might be some obstacles with threaded servers. I am not sure.
> Alternatively, would it be possible to compile PHP without apache and with
> sockets for command line use only?
--enable-cli
Regards,
Oliver
attached mail follows:
Am Mittwoch, 2. Mai 2007 14:36 schrieb Oliver Block:
> --with-socket=shared
Actually it should be --enable-sockets=shared
Regards,
Oliver
attached mail follows:
On Wed, May 2, 2007 6:29 am, list3
truswan.com wrote:
> I need to do some socket work on a production machine that is
> constantly
> busy so I don't dare re-compile php. Anybody know if it's possible to
> load
> the socket functions dynamically, maybe as if they were in a module?
If you can do --with-sockets=shared, for the configure, you should end
up with a sockets.so file that you can then use http://php.net/dl to
load into your scripts that need sockets...
At least, *some* extensions this works...
> Alternatively, would it be possible to compile PHP without apache and
> with
> sockets for command line use only?
Definitely.
Just compile it as CLI or CGI, without the --with-apxs or --with-apxs2
or whatever pulls in Apache.
> If I do that I would like to give
> the
> resulting object a different name than PHP because I do have some cmd
> line
> pgms running on the machine. Is that difficult?
Then don't do 'make install' but just copy the bin/php over to
/usr/local/bin/php-with-sockets
Then you can do php-with-sockets -q whatever.php to run that one
special PHP binary.
Alternatively, you can download the PHP source to a whole new fresh
directory, compile it for CLI, and then leave it there, and use:
/path/to/php/src/php/bin/php -q whatever.php
so that you are running the special php binary from that source
directory instead of the usual one in /usr/local/bin (or wherever
yours lives)
I did that for a CVS version when I needed a patched PHP on a shared
host, and it worked pretty well for a cron job.
It would be kind of cumbersome for something you wanted to run by hand
from the shell a lot, but for a set it and forget it cron job, it was
fine for me.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
I've a x509 certificate from my CA self-signed:
$res_ca_cert=openssl_csr_sign($res_ca_csr,NULL,$res_ca_key,365);
Then, I've an user certificate signed by the CA:
$res_usr_cert=openssl_csr_sign($txt_usr_csr,$txt_ca_cert,$res_ca_key,1);
Exists in the PHP API any function to check if the user certificate is
really signed by the CA ? Like this operation :
$res_ca_public = openssl_get_publickey($txt_ca_cert);
$txt_usr_sign = fakessl_x509_getsignature($txt_usr_cert);
openssl_public_decrypt($txt_usr_sign,$txt_usr_public,$res_ca_public);
Check that $txt_usr_public == fakessl_gettxt_publickey($txt_usr_cert)
I've found openssl_pkcs7_verify, but this doesn't work for me because I
can access to the file system.
Another solutions is to parse the human-readable x509 certificates in
order to get the public keys and certificates and verify it by hand.
Any idea ?
Thanks for all !
attached mail follows:
At 4:42 PM -0500 5/1/07, Richard Lynch wrote:
>Little help here?
Richard:
Let me estate the problem. From your dB of things (the population),
you're going to pull out the top 100 most popular items and then
divide them into five groups using labels t1 through t5. Considering
that it's css guy asking for this, he's probably making a "tag
cloud". They are kind of neat, you can look it up.
In any event, any population can be measured by it's distribution
about it's mean (i.e., the average of the population).
Some distributions are gathered close to the mean while others are
spread out from the mean. The measurement we use to describe this
dispersion from the mean is standard deviation.
In your problem, I believe by using the standard deviation as a
measure, you can break your population into divisions based how many
fall with the first standard deviation, the second standard
deviation, the third standard deviation, and so on.
Here's a demo I prepared for you:
http://sperling.com/a/stdev.php
It shows a simple population and it's standard deviation. From there
you should be able see how you can use the standard deviation to do
your divisions. I would be interested in reviewing your solution.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Tue, May 1, 2007 4:48 pm, Daniel Brown wrote:
> I don't think I'm quite following why you wouldn't just want to
> break it
> up into groups of 20....
Because in the real world, it's not an even distribution of popularity.
There are only 1 or 2 Legends, and a handful of Rock Stars, and a
couple dozen Household Names, and then lots and lots of Famous in the
Top 100.
I need the relative popularity as a weighted distribution thingie,
like that.
I don't know what the actual scores will be, as they will change over
time with more users -- but I know the relativistic popularity is not
an even distribution curve.
Damn I wish I remembered this crap from 20 years ago better.
I so do *not* want to run through those textbooks again. I hated it
the first time around... :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Wed, May 2, 2007 7:55 am, tedd wrote:
> Let me estate the problem. From your dB of things (the population),
> you're going to pull out the top 100 most popular items and then
> divide them into five groups using labels t1 through t5. Considering
> that it's css guy asking for this, he's probably making a "tag
> cloud". They are kind of neat, you can look it up.
It is DEFINITELY a tag cloud.
That's precisely what it is, actually...
Now if I can just see how to relate your sample web page to what I'm
looking for, I'm all set... :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
I have a huge MySQL table, 2.1 million records, 200MB. Once a week I
need to dump it in CSV format and zip the file.
This is not on my server, and it's in production, so I don't want to
risk testing different methods and possibly hanging up their server
for a period of time, so I wanted to seek advice here first to find
what's the best way to proceed.
I can easily use PHP to query the table for the results I want and
write a file line by line and then zip it, but I'm worried that might
take too long and hang up the machine. The other way to go is some
kind of sql dump command, which I guess would be faster, but not sure
how much control I'd have over the exact format of the file. Any
suggestions which way I should proceed? Not hanging up their server
is my prime concern.
attached mail follows:
[snip]
I have a huge MySQL table, 2.1 million records, 200MB. Once a week I
need to dump it in CSV format and zip the file.
This is not on my server, and it's in production, so I don't want to
risk testing different methods and possibly hanging up their server
for a period of time, so I wanted to seek advice here first to find
what's the best way to proceed.
I can easily use PHP to query the table for the results I want and
write a file line by line and then zip it, but I'm worried that might
take too long and hang up the machine. The other way to go is some
kind of sql dump command, which I guess would be faster, but not sure
how much control I'd have over the exact format of the file. Any
suggestions which way I should proceed? Not hanging up their server
is my prime concern.
[/snip]
SELECT * INTO OUTFILE "/directory/myfile.csv"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM table;
attached mail follows:
Brian Dunning wrote:
> I have a huge MySQL table, 2.1 million records, 200MB. Once a week I
> need to dump it in CSV format and zip the file.
>
> This is not on my server, and it's in production, so I don't want to
> risk testing different methods and possibly hanging up their server for
> a period of time, so I wanted to seek advice here first to find what's
> the best way to proceed.
>
> I can easily use PHP to query the table for the results I want and write
> a file line by line and then zip it, but I'm worried that might take too
> long and hang up the machine. The other way to go is some kind of sql
> dump command, which I guess would be faster, but not sure how much
> control I'd have over the exact format of the file. Any suggestions
> which way I should proceed? Not hanging up their server is my prime
> concern.
If hogging their server is of prime concern then ideally you either need
to (a) schedule down time for the site while the back-up happens, or (b)
replicate the data to another MySQL server, and back-up that.
I can't see any reason why you need to bring PHP into the equation here,
MySQL has more than enough native tools to do exactly what you need -
and probably a butt-load faster too.
Cheers,
Rich
--
Zend Certified Engineer
http://www.corephp.co.uk
"Never trust a computer you can't throw out of a window"
attached mail follows:
On 5/2/07, Richard Davey <rich
corephp.co.uk> wrote:
>
> Brian Dunning wrote:
>
> > I have a huge MySQL table, 2.1 million records, 200MB. Once a week I
> > need to dump it in CSV format and zip the file.
> >
> > This is not on my server, and it's in production, so I don't want to
> > risk testing different methods and possibly hanging up their server for
> > a period of time, so I wanted to seek advice here first to find what's
> > the best way to proceed.
> >
> > I can easily use PHP to query the table for the results I want and write
> > a file line by line and then zip it, but I'm worried that might take too
> > long and hang up the machine. The other way to go is some kind of sql
> > dump command, which I guess would be faster, but not sure how much
> > control I'd have over the exact format of the file. Any suggestions
> > which way I should proceed? Not hanging up their server is my prime
> > concern.
>
> If hogging their server is of prime concern then ideally you either need
> to (a) schedule down time for the site while the back-up happens, or (b)
> replicate the data to another MySQL server, and back-up that.
>
> I can't see any reason why you need to bring PHP into the equation here,
> MySQL has more than enough native tools to do exactly what you need -
> and probably a butt-load faster too.
>
> Cheers,
>
> Rich
Brian,
As a comparison, on a *nix master/slave configuration, I'm mysqldumping
nightly a database that's always growing and now is over a 1GB in size. The
dump takes about 20 seconds to finish. Assuming a linear relationship, your
200MB backup should only tie up the db server for around 5 seconds.
Bzipping the .sql file takes infinitiely longer, almost an hour, but a lower
compression ratio should take only 1/4 to 1/3 as long.
I'd say give some attention to the zip method you use.
HTH,
David
attached mail follows:
> I'd say give some attention to the zip method you use.
or better yet rsync the file, send only what has changed.
--
Regards,
Clive.
Real Time Travel Connections
{No electrons were harmed in the creation, transmission or reading of
this email. However, many were excited and some may well have enjoyed
the experience.}
attached mail follows:
clive wrote:
>
>> I'd say give some attention to the zip method you use.
>
> or better yet rsync the file, send only what has changed.
Good advice but may not work as well with extended insert syntax which
results in smaller dump files and much faster import too.
I guess with CSV it could work well tho' (my mind is stuck in mysql dump
output mode ;))
COl
attached mail follows:
On Wed, May 2, 2007 8:54 am, Brian Dunning wrote:
> I have a huge MySQL table, 2.1 million records, 200MB. Once a week I
> need to dump it in CSV format and zip the file.
You could run mysql_dump once by hand and test just how bad it is, and
be ready to kill -9 it if the server gets hurt...
But, really, as a long-term SAFE solution, the best bet would probably
be do set up a master/slave replication in MySQL, and have the *slave*
be something non-production that you mysql_dump.
There are some caveats to the replication, such as making SURE you
have enough hard drive space for the log files, and enough bandwidth
that the log files never grow too large.
But once you get that working well, you can pretty much do whatever
you want to the slave and not risk the master being bogged down.
This is also a VERY common way to set up a "reporting" server, so your
marketing weenies can write the ad hoc queries they love that tend to
bring down a server... :-v
> I can easily use PHP to query the table for the results I want and
> write a file line by line and then zip it, but I'm worried that might
> take too long and hang up the machine. The other way to go is some
> kind of sql dump command, which I guess would be faster, but not sure
> how much control I'd have over the exact format of the file. Any
> suggestions which way I should proceed? Not hanging up their server
> is my prime concern.
If you can't do a replication setup, or the budget is ridiculously
low, running a PHP script with a sleep call and a set_time_limit to
make sure it never dies, you can slowly and surely dump out a few
records at a time.
The risk there is inconsistencies in your dump, for related keys
between tables...
It will *NOT* be faster than mysql_dump, ever, by any means, almost
for sure, but you'll be able to control how much it pounds the server
more easily.
mysql_dump *may* have some kind of command line flag to limit the
resources it consumes so you don't drag down the DB...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
Somebody? help me!!
:D
2007/4/30, Fernando chucre <fernandochucre
gmail.com>:
>
> Hello all,
>
> I make a script for read and interprete the stdout of cmd `ip monitor`.
> And I use signal_handler, the script is like this:
> <?
> declare(ticks = 1);
> pcntl_signal(SIGHUP,"sig_handler",false);
>
>
> $fh = popen('ip monitor','r');
>
> while (!feof($fh))
> {
> $line = fgets($fh);
> analize($line);
> }
>
> function analize($line) { ... } ;
> function sig_handler($signo) { ... };
> ?>
>
> this script run in infine loop, or when to cmd 'ip monitor' exist. The
> script ever whait the next line of 'ip monitor', ever. Then when I send the
> signal SIGHUP to pid of script. In this point the instruction '$line =
> fgets($fh);' is aborted and return false to $line. The $fh is modified and
> the function feof($fh) return true and I have not access to $fh agaim. But
> the kid process 'ip monitor' is not kill.
>
> This is wanted?
>
> --
> Fernando Chure
> PSL/CE
--
Fernando Chure
PSL/CE
attached mail follows:
Hi.
I am using Apache-2.2.2 with mod_auth_kerb-5.3, php-5.2.1,
openldap-2.3.27 cyrus-sasl-2.1.21 and heindal-0.7.2 on a
Linux-from-scratch based system.
The problem I'm presenting is probably a PHP issue or an Apache issue,
or a mod_auth_kerb issue. I could not understand which one causes the
problem.
I am trying to connect using SASL and GSSAPI to the LDAP server from a
PHP script that runs on the Apache server.
The script (in short) does the following:
putenv("KRB5CCNAME=" . $_SERVER['KRB5CCNAME']);
echo getenv("KRB5CCNAME");
system("klist");
$ldapconn = ldap_connect("ldap://example.org") || die(...);
ldap_sasl_bind($ldapconn, NULL, NULL, "GSSAPI") || die(...);
When I run the script manually from a shell that has a proper
KRB5CCNAME environment variable, both the system("klist") and the
ldap_sasl_bind(...) work as they should.
When I run `restart Apache' and then enter to the PHP page for the
first time both work as well. The KRB5CCNAME written is
/tmp/krb5ccname_apache_<something>
After that, each time I enter the page I get some other KRB5CCNAME
(other than the one I got before), the system("klist") command works
as it should, but ldap_sasl_bind returns "Local error". In this case I
also get an error written to /var/log/auth. This error says that the
file /tmp/krb5ccname_apache_<something> could not be found (this is
the same <something> that was written by PHP after I restarted
Apache). This means that the authentication process tries to use the
previous file-name.
I added a debug print to PHP's ldap_sasl_bind function that prints
`getenv("KRB5CCNAME")' to Apache's error-log. The KRB5CCNAME written
to the error-log is the same as the one PHP outputs. Not the one
written to the auth log.
Why isn't the KRB5CCNAME variable passed on?
Which of the three (PHP, Apache, mod_auth_kerb) keeps the first KRB5CCNAME?
How do I cause the new KRB5CCNAME to be used for authentication?
Any ideas?
Thanks,
Gil Ran.
P.S.
I am not on the list, please cc me.
attached mail follows:
On Wed, May 2, 2007 9:41 am, gil ran wrote:
> I am using Apache-2.2.2 with mod_auth_kerb-5.3, php-5.2.1,
> openldap-2.3.27 cyrus-sasl-2.1.21 and heindal-0.7.2 on a
> Linux-from-scratch based system.
>
> The problem I'm presenting is probably a PHP issue or an Apache issue,
> or a mod_auth_kerb issue. I could not understand which one causes the
> problem.
>
> I am trying to connect using SASL and GSSAPI to the LDAP server from a
> PHP script that runs on the Apache server.
>
> The script (in short) does the following:
> putenv("KRB5CCNAME=" . $_SERVER['KRB5CCNAME']);
> echo getenv("KRB5CCNAME");
> system("klist");
Always use 'exec' instead, and ALWAYS get the output and the error
code and ALWAYS ALWAYS ALWAYS check the error code!
> $ldapconn = ldap_connect("ldap://example.org") || die(...);
> ldap_sasl_bind($ldapconn, NULL, NULL, "GSSAPI") || die(...);
>
> When I run the script manually from a shell that has a proper
> KRB5CCNAME environment variable, both the system("klist") and the
> ldap_sasl_bind(...) work as they should.
When you run the script manually from a shell, you are probably NOT
the same User as PHP runs as, and you are probably NOT using the same
shell either, and you therefore almost certainly do NOT have the same
environment for your test as for Reality.
This is like stunt-driving a car on a Closed Course with a
Professional Driver, and then pretending that it's safe to do that
same stunt on a busy city street... :-)
99.9% of the time, this problem boils down to:
paths and permissions
Use a FULL PATH for any file/program in your exec call:
NOT klist
/usr/bin/klist
/usr/local/bin/klist
/sharedhost/example.com/usr/local/i/compiled/it/myself/bin/klist
NOT somefile.txt
/full/path/to/wherever/it/lives/somefile.txt
> When I run `restart Apache' and then enter to the PHP page for the
> first time both work as well. The KRB5CCNAME written is
> /tmp/krb5ccname_apache_<something>
I dunno what klist does, nor what any of the KRB stuff is, but if you
want to preserve this KRB thingie from page to page, it looks like you
will need to do more than just run 'klist'...
You'll need to store the setting somewhere, transmit that storage
location through the stateless HTTP protocol (just like
GET/POST/COOKIE is used) and then retrieve it if it's already been
stored, or make a new one, as appropriate for whatever you are trying
to do, which I also don't really understand, but there it is.
> After that, each time I enter the page I get some other KRB5CCNAME
> (other than the one I got before), the system("klist") command works
> as it should, but ldap_sasl_bind returns "Local error". In this case I
> also get an error written to /var/log/auth. This error says that the
> file /tmp/krb5ccname_apache_<something> could not be found (this is
> the same <something> that was written by PHP after I restarted
> Apache). This means that the authentication process tries to use the
> previous file-name.
See above.
> I added a debug print to PHP's ldap_sasl_bind function that prints
> `getenv("KRB5CCNAME")' to Apache's error-log. The KRB5CCNAME written
> to the error-log is the same as the one PHP outputs. Not the one
> written to the auth log.
>
> Why isn't the KRB5CCNAME variable passed on?
Why should it be passed on?
Each "run" of your script is a totally separate process, and if you
have multiple Apache children, they each have their own process.
So unless you've got some magic wand to get them all to share (e.g., a
cross-process storage/communcation) they are not going to share.
> Which of the three (PHP, Apache, mod_auth_kerb) keeps the first
> KRB5CCNAME?
Yes.
:-)
If you are running PHP as CGI, it will never have the same KRB twice,
I suspect.
If you run PHP as Apache module, each Apache child and the related PHP
environment could easily keep its own KRB, I suspect.
I got no idea whatsoever what the kerb thing is doing, but as a
mod_xxx, it is also tied to the Apache child process, of which there
might be HUNDREDS.
If you are setting the ENV in the Apache startup with something in
httpd.conf or your Apache startup script, that would maybe share the
KRB across all children, but just setting it with PHP script won't
touch other children.
> How do I cause the new KRB5CCNAME to be used for authentication?
Hopefully I've outlined the issues enough above for you to know the
answer, even though I have no idea what the answer really is...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
Guys.. I have a problem and I was wondering if somebody with good php
knowledge could help.
I have this excel macro that converts number currency (mexican) into a
string and I was wondering if somebody could help translating it to php...
Her eis the macro, if you could help, I would really appreciate it.
Thanks guys!
Function CantidadEnLetra(tyCantidad As Currency) As String
Dim lyCantidad As Currency, lyCentavos As Currency, lnDigito As Byte,
lnPrimerDigito As Byte, lnSegundoDigito As Byte, lnTercerDigito As Byte,
lcBloque As String, lnNumeroBloques As Byte, lnBloqueCero
tyCantidad = Round(tyCantidad, 2)
lyCantidad = Int(tyCantidad)
lyCentavos = (tyCantidad - lyCantidad) * 100
laUnidades = Array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE",
"OCHO", "NUEVE", "DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE",
"DIESISEIS", "DIESISIETE", "DIESIOCHO", "DIESINUEVE", "VEINTE", "VEINTIUN",
"VEINTIDOS", "VEINTITRES", "VEINTICUATRO", "VEINTICINCO", "VEINTISEIS",
"VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE")
laDecenas = Array("DIEZ", "VEINTE", "TREINTA", "CUARENTA", "CINCUENTA",
"SESENTA", "SETENTA", "OCHENTA", "NOVENTA")
laCentenas = Array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", "CUATROCIENTOS",
"QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", "NOVECIENTOS")
lnNumeroBloques = 1
Do
lnPrimerDigito = 0
lnSegundoDigito = 0
lnTercerDigito = 0
lcBloque = ""
lnBloqueCero = 0
For i = 1 To 3
lnDigito = lyCantidad Mod 10
If lnDigito <> 0 Then
Select Case i
Case 1
lcBloque = " " & laUnidades(lnDigito - 1)
lnPrimerDigito = lnDigito
Case 2
If lnDigito <= 2 Then
lcBloque = " " & laUnidades((lnDigito * 10) + lnPrimerDigito - 1)
Else
lcBloque = " " & laDecenas(lnDigito - 1) & IIf(lnPrimerDigito <> 0, " Y",
Null) & lcBloque
End If
lnSegundoDigito = lnDigito
Case 3
lcBloque = " " & IIf(lnDigito = 1 And lnPrimerDigito = 0 And lnSegundoDigito
= 0, "CIEN", laCentenas(lnDigito - 1)) & lcBloque
lnTercerDigito = lnDigito
End Select
Else
lnBloqueCero = lnBloqueCero + 1
End If
lyCantidad = Int(lyCantidad / 10)
If lyCantidad = 0 Then
Exit For
End If
Next i
Select Case lnNumeroBloques
Case 1
CantidadEnLetra = lcBloque
Case 2
CantidadEnLetra = lcBloque & IIf(lnBloqueCero = 3, Null, " MIL") &
CantidadEnLetra
Case 3
CantidadEnLetra = lcBloque & IIf(lnPrimerDigito = 1 And lnSegundoDigito = 0
And lnTercerDigito = 0, " MILLON", " MILLONES") & CantidadEnLetra
End Select
lnNumeroBloques = lnNumeroBloques + 1
Loop Until lyCantidad = 0
CantidadEnLetra = "(" & CantidadEnLetra & IIf(tyCantidad > 1, " PESOS ", "
PESO ") & Format(Str(lyCentavos), "00") & "/100 M.N. )"
End Function
attached mail follows:
Ave,
Hereıs the thing, Iıve got an Array which has itıs own set of Keys =>
Values. Iım using foreach() to read the Keys => Values like this:
function pr1($var) {
foreach ($var as $k => $v) {
echo ³$k => $v²;
}
I need to INSERT the Values from this array into a mySQL table. The problem
is, There is other data that is going into the same row of that mySQL Table
as well.
So I have to basically insert 3 fields and then the rest of values I have to
insert using this Array. In other words, this is what I have to do:
INSERT into table (f1, f2, f3, f4, f5) VALUES ($1ı, $2ı, $3ı, //and the
rest of the values from from the $v Values from that Array $var.....
Iım not able to formulate a code to do this. Any help would be really
appreciated.
Thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.
W: http://www.rahulsjohari.com
E: sleepwalker
rahulsjohari.com
³I morti non sono piu soli ... The dead are no longer lonely²
attached mail follows:
Rahul S. Johari wrote:
> Ave,
>
> Hereıs the thing, Iıve got an Array which has itıs own set of
> Keys => Values. Iım using foreach() to read the Keys => Values like
> this:
>
> function pr1($var) {
> foreach ($var as $k => $v) {
> echo ³$k => $v²;
> }
>
> I need to INSERT the Values from this array into a mySQL
> table. The problem is, There is other data that is going into
> the same row of that mySQL Table as well.
>
> So I have to basically insert 3 fields and then the rest of
> values I have to insert using this Array. In other words, this is
> what I have to do:
>
> INSERT into table (f1, f2, f3, f4, f5) VALUES ($1ı, $2ı,
> $3ı, //and the rest of the values from from the $v Values from that
> Array $var.....
>
> Iım not able to formulate a code to do this. Any help would be really
> appreciated.
>
> Thanks.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Rahul Sitaram Johari
> CEO, Twenty Four Seventy Nine Inc.
>
> W: http://www.rahulsjohari.com
> E: sleepwalker
rahulsjohari.com
>
> ³I morti non sono piu soli ... The dead are no longer lonely²
$sql = "INSERT INTO table (f1, f2, f3, ". implode(",", array_keys($pr1)) .")
VALUES ('abc', '123', '456', ". implode(",", array_values($pr1))
.")";
HTH,
Brad
attached mail follows:
On 5/2/07, Rahul S. Johari <rjohari
nycap.rr.com> wrote:
>
>
> Ave,
>
> Hereıs the thing, Iıve got an Array which has itıs own set of Keys =>
> Values. Iım using foreach() to read the Keys => Values like this:
>
> function pr1($var) {
> foreach ($var as $k => $v) {
> echo ³$k => $v²;
> }
>
> I need to INSERT the Values from this array into a mySQL table. The
> problem
> is, There is other data that is going into the same row of that mySQL
> Table
> as well.
>
> So I have to basically insert 3 fields and then the rest of values I have
> to
> insert using this Array. In other words, this is what I have to do:
>
> INSERT into table (f1, f2, f3, f4, f5) VALUES ($1ı, $2ı, $3ı, //and
> the
> rest of the values from from the $v Values from that Array $var.....
>
> Iım not able to formulate a code to do this. Any help would be really
> appreciated.
Either gather all the data together first, and then do an insert, or do an
insert on the 1st part, then update the record with the remaining data with
a where clause (Use last_insert_id() to track a primary key, or pass some
unique identifier from the insert to the update query). Personally, I'd find
a way to gather all the data first and do it all with one insert.
David
attached mail follows:
>
> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
> array_keys($pr1)) .")
> VALUES ('abc', '123', '456', ". implode(",",
> array_values($pr1))
> .")";
>
> HTH,
>
> Brad
Might not work if the array values need to be enclosed in quotes. I would
build the query string in a foreach loop and execute the query afterwards.
JM
attached mail follows:
Ave,
I was just about to post when I saw your message. I think what you're saying
is exactly what is happening. The values have Spaces and stuff so Quotes are
Required - cannot have values not enclosed in Quotes. Other then that it was
actually working.
Is there a way to enclose in Quotes using the implode statement?
On 5/2/07 12:03 PM, "Jim Moseby" <JMoseby
nrbindustries.com> wrote:
>>
>> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
>> array_keys($pr1)) .")
>> VALUES ('abc', '123', '456', ". implode(",",
>> array_values($pr1))
>> .")";
>>
>> HTH,
>>
>> Brad
>
>
> Might not work if the array values need to be enclosed in quotes. I would
> build the query string in a foreach loop and execute the query afterwards.
>
> JM
attached mail follows:
Jim Moseby wrote:
>> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
>> array_keys($pr1)) .") VALUES ('abc', '123', '456', ". implode(",",
>> array_values($pr1))
>> .")";
>>
>> HTH,
>>
>> Brad
>
>
> Might not work if the array values need to be enclosed in
> quotes. I would build the query string in a foreach loop and execute
> the query afterwards.
>
> JM
Good point, Jim. I just realized that. I actually use this method in one
of my scripts; in my case all of the fields are varchar and the code below
works perfectly. This is updated to quote all values.
$sql = "INSERT INTO coreg_lead (".implode(",", array_keys($dbFields)).")
VALUES ('".implode("','", array_values($dbFields))."')";
-Brad
attached mail follows:
On Wed, May 2, 2007 11:03 am, Jim Moseby wrote:
>>
>> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
>> array_keys($pr1)) .")
>> VALUES ('abc', '123', '456', ". implode(",",
>> array_values($pr1))
>> .")";
>>
>> HTH,
>>
>> Brad
>
>
> Might not work if the array values need to be enclosed in quotes. I
> would
> build the query string in a foreach loop and execute the query
> afterwards.
It's pretty trivial to convert to:
VALUE ('abc', '123', '456', '" . implode("','", $array_values($pr1)) .
"')";
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Wed, May 2, 2007 10:42 am, Rahul S. Johari wrote:
> Hereıs the thing, Iıve got an Array which has itıs own set of Keys =>
> Values. Iım using foreach() to read the Keys => Values like this:
>
//note added arguments!
> function pr1($var, $var2, $var3) {
> foreach ($var as $k => $v) {
> echo ³$k => $v²;
echo "$var2[$k] $var3[$k]";
//DID YOU USE mysql_real_escape_string YET?!
$query = "insert into whatever (v1, v2, v3) ";
$query .= " values('$v', '$var2[$k]', '$var3[$k]') ";
Or maybe $v is an array itself?
//perhaps you want:
list($v1, $v2, $v3) = each($v);
> }
>
> I need to INSERT the Values from this array into a mySQL table. The
> problem
> is, There is other data that is going into the same row of that mySQL
> Table
> as well.
>
> So I have to basically insert 3 fields and then the rest of values I
> have to
> insert using this Array. In other words, this is what I have to do:
>
> INSERT into table (f1, f2, f3, f4, f5) VALUES ($1ı, $2ı, $3ı,
> //and the
> rest of the values from from the $v Values from that Array $var.....
>
> Iım not able to formulate a code to do this. Any help would be really
> appreciated.
>
> Thanks.
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Rahul Sitaram Johari
> CEO, Twenty Four Seventy Nine Inc.
>
> W: http://www.rahulsjohari.com
> E: sleepwalker
rahulsjohari.com
>
> ³I morti non sono piu soli ... The dead are no longer lonely²
>
>
>
>
>
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
WORKS Like A Charm!! :)
Thanks.
On 5/2/07 12:14 PM, "Brad Fuller" <bfuller
cpacampaigns.com> wrote:
> Jim Moseby wrote:
>>> $sql = "INSERT INTO table (f1, f2, f3, ". implode(",",
>>> array_keys($pr1)) .") VALUES ('abc', '123', '456', ". implode(",",
>>> array_values($pr1))
>>> .")";
>>>
>>> HTH,
>>>
>>> Brad
>>
>>
>> Might not work if the array values need to be enclosed in
>> quotes. I would build the query string in a foreach loop and execute
>> the query afterwards.
>>
>> JM
>
> Good point, Jim. I just realized that. I actually use this method in one
> of my scripts; in my case all of the fields are varchar and the code below
> works perfectly. This is updated to quote all values.
>
> $sql = "INSERT INTO coreg_lead (".implode(",", array_keys($dbFields)).")
> VALUES ('".implode("','", array_values($dbFields))."')";
>
> -Brad
attached mail follows:
Does anybody have or know of a good simple PHP script that can take an
email as an input, and compose a "Bounce" email as output?
I need something that does just that, without a huge framework or a
zillion other "features"...
attached mail follows:
Am Mittwoch, 2. Mai 2007 20:11 schrieb Richard Lynch:
> Does anybody have or know of a good simple PHP script that can take an
> email as an input, and compose a "Bounce" email as output?
>
> I need something that does just that, without a huge framework or a
> zillion other "features"...
please try this:
$env['from'] = 'ceo
l-i-e.com';
$env['to'] = 'ceo
t-r-u-t-h.com';
$env['remail'] = imap_fetchheader($stream, $msgno);
$part0['contents.data'] = imap_body($stream, $msgno);
$body[0] = $part0;
$bounce_msg = imap_mail_compose($env, $body);
Not you should get rid of the 'Received-' headers.
I did not test it. If something goes wrong, please post again.
Regards,
Oliver
attached mail follows:
http://bugs.php.net/bug.php?id=39062
I'm requesting that this bug be reopened and reconsidered.
I'm completely befuddled by the handling of this bug. The message text
suggests a workaround, then the bug is marked bogus. If the bug is
bogus, why is there a workaround required?
Additionally, the suggested workaround doesn't even work. dechex()
reliably returns 64 hex bits for 64-bit numbers and 32 hex bits for
32-bit numbers, which still results in incorrect comparisons, for
example fffffffff34c690a != f34c690a.
--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/
wmoran
collaborativefusion.com
Phone: 412-422-3463x4023
attached mail follows:
On Wed, 2007-05-02 at 14:14 -0400, Bill Moran wrote:
> http://bugs.php.net/bug.php?id=39062
>
> I'm requesting that this bug be reopened and reconsidered.
>
> I'm completely befuddled by the handling of this bug. The message text
> suggests a workaround, then the bug is marked bogus. If the bug is
> bogus, why is there a workaround required?
>
> Additionally, the suggested workaround doesn't even work. dechex()
> reliably returns 64 hex bits for 64-bit numbers and 32 hex bits for
> 32-bit numbers, which still results in incorrect comparisons, for
> example fffffffff34c690a != f34c690a.
Sounds like you have everything you need to create a wrapper function to
produce exactly what YOU need :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
While I'm not using this particular function, I do agree with you, it's
kinda sucky that they just dismissed their broken-ass method. It should
return -2G..2G as advertised and as all other POSIX systems do. And you are
also correct about the "work around" that is erroneous too.
IMHO, this is a genuine bug and needs a genuine fix.
> -----Original Message-----
> From: Bill Moran [mailto:wmoran
collaborativefusion.com]
> Sent: Wednesday, May 02, 2007 11:14 AM
> To: php-general
lists.php.net
> Subject: [PHP] Discussion of bug #39062
>
>
> http://bugs.php.net/bug.php?id=39062
>
> I'm requesting that this bug be reopened and reconsidered.
>
> I'm completely befuddled by the handling of this bug. The
> message text
> suggests a workaround, then the bug is marked bogus. If the bug is
> bogus, why is there a workaround required?
>
> Additionally, the suggested workaround doesn't even work. dechex()
> reliably returns 64 hex bits for 64-bit numbers and 32 hex bits for
> 32-bit numbers, which still results in incorrect comparisons, for
> example fffffffff34c690a != f34c690a.
>
> --
> Bill Moran
> Collaborative Fusion Inc.
> http://people.collaborativefusion.com/~wmoran/
>
> wmoran
collaborativefusion.com
> Phone: 412-422-3463x4023
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
On Wed, May 2, 2007 1:14 pm, Bill Moran wrote:
>
> http://bugs.php.net/bug.php?id=39062
>
> I'm requesting that this bug be reopened and reconsidered.
>
> I'm completely befuddled by the handling of this bug. The message
> text
> suggests a workaround, then the bug is marked bogus. If the bug is
> bogus, why is there a workaround required?
>
> Additionally, the suggested workaround doesn't even work. dechex()
> reliably returns 64 hex bits for 64-bit numbers and 32 hex bits for
> 32-bit numbers, which still results in incorrect comparisons, for
> example fffffffff34c690a != f34c690a.
This discussion may be better placed on "Internals" where the people
who make these decisions hang out more...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
I have this simple database and I'm going to have a handful of people
editing it...
I'd like to track each and every edit with username, and, ideally,
provide myself an easy "Undo" if I decide [bleep] is an idiot and
shouldn't have done that.
Now, I'm not real concerned about the relational foreign key aspect
here, and I'd like to keep this as simple as possible...
I've considered doing a dump and putting the output into subversion,
even...
I realize there may be some nifty MySQL tool that does this, so I'll
be researching that shortly, but I'm wondering if there's a nifty
change-management php package out there that I should check out.
The users are currently slated to be logging in via HTTP Basic
Authentication, but I could change that, I guess.
K.I.S.S. is definitely the motto around here -- If it takes more than
a day or two to figure out, install, and implement; then forget it, as
I can just hack something together myself in that time-frame.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Tue, May 1, 2007 5:54 am, Alain Roger wrote:
>> else // both $width and $height are smaller than max, so we need to
>> zoom
Zooming an image is RARELY satisfactory in appearance...
I'd say just leave it alone, personally.
>> $escaped = pg_escape_bytea($thumb); // does not work and it's normal
>
> $thumb is an image, so ho can i make it useful for pg_escape_bytea
> function
> ?
$thumb isn't the actual JPEG image.
It's just a PHP resource number, pointing to the image.
So, essentially, you are cramming the number "3" (or "2" or "4" or
whatever) into PostgreSQL.
You would need to do something not unlike:
ob_start();
imagejpeg($thumb);
$image = ob_get_contents();
ob_end_clean();
$escaped = pg_escape_bytea($image);
//Insert obligatory "don't store images in DB flame-war here" :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 3:37 pm, Ben Clapp wrote:
> I am new to PHP programming and need some help. I have an image that i
> have show up each May for the month with $mymonth = date("m",
> mktime()),
> but i want to set up a date range for it to show up. Ex. 4-13 to 5-13
> each year. How can I do that? Any help would be great.
$now = time();
//leave the year off for 'annual' calculations:
if (mktime(1, 0, 0, 4, 13) <= $time && $time <= mktime(1, 0, 0, 5, 13)){
//do something to show your May image.
}
else{
//show the usual image, or nothing, or whatever
}
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 6:33 pm, Daevid Vincent wrote:
>> echo "BROWSER: " . $_SERVER['HTTP_USER_AGENT'] . "\n";
>
> I've always had problems with heredoc when I try using arrays like
> that. I
> will either pull them into a straight $foo, or use the ${} thing.
It probably won't do 2-D arrays, but 1-D should be fine.
>> echo <<<EOF
>> BROWSER: $_SERVER[HTTP_USER_AGENT]
>> EOF;
>
> Isn't that form (sans quote marks) deprecated and frowned upon?
I think it was for a brief period, but the masses revolted and said
they LIKED the non-apostrophe embedded arrays with no extra syntax...
The preceding is a gross-oversimplifaction and biased interpretation
of historical events in the PHP Community. Apologies to all involved.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 7:19 pm, Richard Davey wrote:
> Greg Donald wrote:
>
>> On 4/30/07, Daevid Vincent <daevid
daevid.com> wrote:
>>> > echo <<<EOF
>>> > BROWSER: $_SERVER[HTTP_USER_AGENT]
>>> > EOF;
>>>
>>> Isn't that form (sans quote marks) deprecated and frowned upon?
>>
>> <?php
>>
>> error_reporting( E_ALL );
>>
>> echo <<<EOF
>> BROWSER: $_SERVER[HTTP_USER_AGENT]
>> EOF;
>>
>> Why would cleaner, perfectly error free code be frowned upon?
>
> I'm not dissing heredoc syntax, it has its uses (now and again) but
> it's
> far from "clean", especially when embedded deep in classes - the major
> cause being the delimeters insistance on being at the very start of
> the
> line. It's just *not* pretty IMHO. Certainly not girl code [1]
>
> The frowning surely would be at the mixing of logic and presentation,
> regardless how that mix happens (heredoc, echo, jumping in and out of
> PHP tags, sprintf, etc).
There's some folks that take this presentation/logic separation ideal
a bit TOO far, imho...
I mean, some of the "logic" is all ABOUT presentation, and there's no
actual business/algorithm to it.
Call it GUI logic. (Or even girl-logic, if you want to push the
metaphor above way too far...) :-)
Choosing heredoc or echo or sprintf in a rigid
thou-shalt-always-use-this fashion as some do often ends up with what
I consider code "cruft".
You end up with:
sprintf("%d", $d);
or
echo <<<EOFOO
Foo!
EOFOO;
and so on, which are just plain silly, really...
I tend to use the right weapon (imho) for the task at hand, and freely
inter-mingle MINOR calculations and GUI-logic in the HTML.
But any heavy lifting or algorithm/business logic goes way at the top
before any <HTML> output.
Works okay for me, for most of a decade now, but drives some folks
nuts. Oh well. They don't like my code, they don't have to steal it.
:-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 7:44 pm, Greg Donald wrote:
> On 4/30/07, Greg Donald <gdonald
gmail.com> wrote:
>> All parts of a heredoc statement do not have to be right justified,
>> only the closing line.
>
> I meant my other right, the one on my left. Sorry.
You don't *HAVE* to left-justify the rest either, but, really, the
results are not the same if you don't...
<?php
//pretend I have LOTS of code here with proper indentation:
if ($foo){
$output1 = <<<EOFOO
This is a test.
This is only a test.
EOFOO;
$output2 = <<<EOBAR;
This is a test.
This is only a test.
EOBAR; //I wish!
}
?>
Now, if you want to put $output1 and $output2 into an email and dash
it off to somebody, you ain't gonna get quite the same results with
them both...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 3:41 pm, Micky Hulse wrote:
> Daniel Brown wrote:
>> Actually, that should be directed at the OP who said that. I was
>> able
>> to bring up the heredoc, too. ;-P
>
> Ooops! Sorry Daniel, I meant to reply to Nick... My mistake. :(
Cool!
They fixed
http://php.net/<<<
to go to the strings page!
Just wish it jumped to the anchor as well... :-)
I'm greedy. :-) :-) :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On Mon, April 30, 2007 7:18 pm, Paul Novitski wrote:
> When I first started using PHP I thought that each heredoc label had
> to be unique. Turns out that's not true, and now I use the simple
> shorthand:
>
> $sResult = <<<_
> Some text.
> _;
I suspect earlier versions of PHP required unique labels...
At least, I *still* thought they had to be unique... :-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
attached mail follows:
On 5/2/07, Richard Lynch <ceo
l-i-e.com> wrote:
>
> Cool!
>
> They fixed
> http://php.net/<<<
> to go to the strings page!
>
> Just wish it jumped to the anchor as well... :-)
>
> I'm greedy. :-) :-) :-)
I'll say you are! Next you'll want all of the links on the site to point to
the correct spots!
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
attached mail follows:
No, to my knowledge, even PHP3 (I honestly don't remember if it was in
PHP/FI, but I don't think so) allowed you to use the same name for multiple
heredoc's. It just works like the for/next concept in BASIC.... for this =
this to that (do something), next this. Meaning that as soon as the
condition is met (this = that), release this.
And as far as I know, Perl is the same, as are any other languages where
heredoc syntax is present.
That's kind of dumbing it down to the point of changing it, perhaps, but
I hope I'm at least speaking English.
On 5/2/07, Richard Lynch <ceo
l-i-e.com> wrote:
>
> On Mon, April 30, 2007 7:18 pm, Paul Novitski wrote:
> > When I first started using PHP I thought that each heredoc label had
> > to be unique. Turns out that's not true, and now I use the simple
> > shorthand:
> >
> > $sResult = <<<_
> > Some text.
> > _;
>
> I suspect earlier versions of PHP required unique labels...
>
> At least, I *still* thought they had to be unique... :-)
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]