php-general Digest 21 Apr 2009 03:49:45 -0000 Issue 6078

Topics (messages 291699 through 291715):

Re: 800 pound gorilla
        291699 by: Sancar Saran
        291713 by: Raymond Irving
        291715 by: Manuel Lemos

Re: problems with gnupg extension.
        291700 by: Ray

Time difference desired load
        291701 by: admin.buskirkgraphics.com
        291705 by: Bastien Koert

Extensions not compile
        291702 by: Joaquim Pedro França Simão
        291703 by: Joaquim Pedro França Simão

Socket connection not closing
        291704 by: Martín Marqués

Help me debug this
        291706 by: Patrick Moloney
        291708 by: Stephen
        291709 by: Patrick Moloney
        291712 by: Bastien Koert
        291714 by: kranthi

Creating A Chat?
        291707 by: Nitsan Bin-Nun

Re: Resampling images -- need lock ? SOLVED
        291710 by: Martin Zvarík

Re: escape your variables
        291711 by: Chris

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Monday 20 April 2009 16:48:42 Marc Christopher Hall wrote:
> Sun buys MySQL and now Oracle buys Sun (not final, yet). What will happen
> with the main db we PHP'ers have come to know and love especially since v 5


sudo apt-get install postgresql

--- End Message ---
--- Begin Message ---
Ok, Sun buys MySQL and now Oracle is planning on buying Sun. Who's going to buy 
Oracle in a few years from now?

Maybe it's time the PHP dev team start thinking about supporting a database 
side project of their own. I would do well to have an open source database 
engine that integrates well with the system under contact development.

So what about the other technologies? What about NetBeans, VirtualBox and Java? 
Will Oracle destroy a good thing? Or will they continue to support Open Source.

I'm not too sure what they will do but I somehow have this feeling that a lot 
will change. It might not be business as usual.

__
Raymond Irving

--- On Mon, 4/20/09, Sancar Saran <[email protected]> wrote:

From: Sancar Saran <[email protected]>
Subject: Re: [PHP] 800 pound gorilla
To: [email protected]
Date: Monday, April 20, 2009, 11:46 AM

On Monday 20 April 2009 16:48:42 Marc Christopher Hall wrote:
> Sun buys MySQL and now Oracle buys Sun (not final, yet). What will happen
> with the main db we PHP'ers have come to know and love especially since v 5


sudo apt-get install postgresql

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


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

on 04/20/2009 10:57 PM Raymond Irving said the following:
> Ok, Sun buys MySQL and now Oracle is planning on buying Sun. Who's going to 
> buy Oracle in a few years from now?
> 
> Maybe it's time the PHP dev team start thinking about supporting a database 
> side project of their own. I would do well to have an open source database 
> engine that integrates well with the system under contact development.

The PHP group already did that. They pushed SQLite when MySQL started
GPL'ing the MySQL client libraries. Then MySQL had to open an exception
for inclusion of MySQL client libraries in Open Source projects like PHP.



> So what about the other technologies? What about NetBeans, VirtualBox and 
> Java? Will Oracle destroy a good thing? Or will they continue to support Open 
> Source.
> 
> I'm not too sure what they will do but I somehow have this feeling that a lot 
> will change. It might not be business as usual.

Nah, Oracle will just charge money for somethings that were going to be
free in MySQL 6 like the online backup support of the Falcon engine. ;-(

Oracle also bought INNODB which provides online backup but it costs
money. That is business as usual, I am afraid.

PostgreSQL people are celebrating as they always had a lot of envy of
MySQL success.

-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

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

--- End Message ---
--- Begin Message ---
On Monday 13 April 2009 10:17:28 Ray wrote:
> Hello all,
>
> I'm trying to use the gnupg extension and I think everything is properly
> installed.
>
> I'm just using test data. I'm encrypting and then immediately decrypting.
> But the decryption is failing with a unhelpful error message.
>
> error message :
> Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
> /path/to/test2.php on line 18
>
> any help or suggestions would be very much appreciated. details follow.
> Ray
>
>
>
> full output:
>
> raw data: this is a test
>
>
> encoded data:
>
>  -----BEGIN PGP MESSAGE-----
> Version: GnuPG v2.0.11 (FreeBSD)
>
> hQIOA9qOyyMyQ2/bEAgArxLuVw5eShkL+/g9SCGcBm5/J1G78zrh6dWFisPFqWg1
> MP3zj/QnWiD9zEtLmGJazP51pV2TpySpEbILze8sz6c/imRBYLrHhbxO6W1LJqXq
> rALUPDIe4qKtM7mC+K9EdFdkYRzWxi45eTK1DQtQazhqelWIb1NuaVu8vUKk/pIy
> duE0juP2j+8OHIlx36sUcATkvBO5a7Ak9tGUT5T5lRqjMzKa6TPuCsZukmVh43BG
> uqpz7H83LinwOCfUnyq3R2e/vIM2cv8t7jz17acOfYslonMxNz54i8jR8COmCmLY
> NhGORZUSLauyWGxAIDvkDcTFD4Jd5KxaXcMPEE7zwAf9HUWmKtqOqn825AjlBxNj
> 7gXEOtpsRMiYiYuISzHvitpPWXQPOPsoGnPRZZBvCNJcvAgg6hMx5c4Y7tGXTsma
> 2hkC9f4959kBwiGAFnQxJqz2pMDW+N3X23f+kwSrU7KoNrhnxUV1ywcUGaebwYM8
> emIygCm6mS7T81JtXxhMto0sSqeE/zwHc3/03/KP57V7j2tHib4dN9ZOfB6yiubF
> PIwog0JYagjOfyNdGh3vRzvcYdDOqyWMgtY6XpZJwPESJlOADHVt5n844oHthRD3
> MJVjwqjEz5qQiPq+kOmd4AdkpkEkRcCweYNEXVXPxpmlrduuu8kc4wsA5v3YXZ/C
> x9JNAVKW9tdPSxDoxbEKyAhVdurQAxmYe7FaCLl74lACQaUg/Otwb86pjUBesgx6
> mXhQv+epG71sKY+LSDxGi8dSgbOOmfI2L09zy9XTEQ4=
> =85vG
> -----END PGP MESSAGE-----
>
>
> [if this line is blank, the decrypt key should have been added correctly]]
>
> Warning: gnupg::decrypt() [gnupg.decrypt]: decrypt failed in
> /path/to/test2.php on line 18
>
>
> decoded data:
>
>
>
>
> Code:
>
> <?php
> $raw_data="this is a test";
> $passphrase="test";
> $recipient="[email protected]";
>
> putenv('GNUPGHOME=/www/ohfinder/keys');
> $gpg = new gnupg();
> $gpg -> seterrormode(gnupg::ERROR_WARNING);
> echo "raw data: $raw_data<br>";
> $gpg->addencryptkey($recipient);
> $encrypted = $gpg->encrypt($raw_data);
> echo "<br><br>encoded data: <pre> $encrypted</pre><br>";
>
> $gpg->adddecryptkey($recipient, $passphrase);
> echo $gpg -> geterror();
> echo "[if this line is blank, the decrypt key should have been added
> correctly]]";
> echo '<br>';
> $plaintext = $gpg->decrypt($encrypted);
> echo $gpg -> geterror();
> echo "<br><br>decoded data: <pre> $plaintext </pre>";
> ?>


Any suggestions, Anyone?
Ray

--- End Message ---
--- Begin Message ---
Suggestion on faster solutions for extremely large database.

$ledip['started'] = '2009-04-01 13:40:34'; Example time in DB
$ledip['touchedlast'] = '2009-04-01 13:41:28'; Example time in DB


date('i:s', strtotime($ledip['touchedlast']) - strtotime($ledip['started'])); 
// Not a desired solution because of its inability to go past the minute 
correctly I AM AWARE.


or 

concat( truncate( hour( timediff($ledip['touchedlast'],$ledip['started']) ) 
/24, 0 ) , " days ", hour( timediff($ledip['touchedlast'],$ledip['started']) ) 
%24, " hours ", minute( timediff($ledip['touchedlast'],$ledip['started'] ) ) , 
" minutes ", second( timediff($ledip['touchedlast'],$ledip['started'] ) ) , " 
seconds" ) as timeleft


The results of concat truncate, allows me the flexibility or exacting time 
differences out past the minute. I am worried that the vastness of the database 
may cause me a server load or query timeframes that are undesirable as it grows 
even bigger.
Suggestions?

*********   PLEASE ....
Do not reply to this email with your 9 million page thought of how to,  or some 
custom function that you think is all that, I do not care.
I am asking for load desired results NOT your take on my code…

--- End Message ---
--- Begin Message ---
On Mon, Apr 20, 2009 at 1:38 PM, <[email protected]> wrote:

> Suggestion on faster solutions for extremely large database.
>
> $ledip['started'] = '2009-04-01 13:40:34'; Example time in DB
> $ledip['touchedlast'] = '2009-04-01 13:41:28'; Example time in DB
>
>
> date('i:s', strtotime($ledip['touchedlast']) -
> strtotime($ledip['started'])); // Not a desired solution because of its
> inability to go past the minute correctly I AM AWARE.
>
>
> or
>
> concat( truncate( hour( timediff($ledip['touchedlast'],$ledip['started']) )
> /24, 0 ) , " days ", hour( timediff($ledip['touchedlast'],$ledip['started'])
> ) %24, " hours ", minute( timediff($ledip['touchedlast'],$ledip['started'] )
> ) , " minutes ", second( timediff($ledip['touchedlast'],$ledip['started'] )
> ) , " seconds" ) as timeleft
>
>
> The results of concat truncate, allows me the flexibility or exacting time
> differences out past the minute. I am worried that the vastness of the
> database may cause me a server load or query timeframes that are undesirable
> as it grows even bigger.
> Suggestions?
>
> *********   PLEASE ....
> Do not reply to this email with your 9 million page thought of how to,  or
> some custom function that you think is all that, I do not care.
> I am asking for load desired results NOT your take on my code…
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
You are doing a lot of calculation on this combining both PHP and SQL code.
How many rows are you affecting with this query at one time?

I hate to say it, but this to me is just begging for a unix timestamps, then
you can simply deal with the seconds remaining on this counter.

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
I use cygwin (updated).
I try to compile extensions, but i only get  "extension.a"

--
# phpize

# ./configure

# make
/usr/local/src/extension/.libs/extension.a, extension.la.lnk,
extension.o (280 kB, the other 3 had few bytes, *.a, *.la, *.lai)

# make install
... created: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
one file *.a (8 bytes "!<arch>")

was expecting a dll file, but only "extension.a"

What's wrong?

--- End Message ---
--- Begin Message ---
I use cygwin (updated).
I try to compile extensions, but i only get  "extension.a"

--
# phpize

# ./configure

# make
/usr/local/src/extension/.libs/extension.a, extension.la.lnk,
extension.o (280 kB, the other 3 had few bytes, *.a, *.la, *.lai)

# make install
... created: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
one file *.a (8 bytes "!<arch>")

was expecting a dll file, but only "extension.a"

What's wrong?

--- End Message ---
--- Begin Message ---
I have a socket application written a few years ago in PHP which
receives information and does something (not relevant at the moment).
The program that connects is written in PHP with PEARs Net_Socket.

This socket is really taken from the socket example in the PHP docs.
It's been working OK for quite some time, but today I tried it out on
my development machine and I'm experiencing some problems with the
network connection not closing:

# lsof -i :9100
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
printSock 5309 root    3u  IPv4  21732      0t0  TCP
bugs.unl.edu.ar:9100 (LISTEN)
printSock 5309 root    4u  IPv4  26834      0t0  TCP
bugs.unl.edu.ar:9100->inti.unl.edu.ar:37825 (CLOSE_WAIT)
sh        8077 root    3u  IPv4  21732      0t0  TCP
bugs.unl.edu.ar:9100 (LISTEN)
sh        8077 root    4u  IPv4  26834      0t0  TCP
bugs.unl.edu.ar:9100->inti.unl.edu.ar:37825 (CLOSE_WAIT)

I sent the disconnect() from Net_Socket, and even set the connection
to not be persistent (just in case), but I can't get the connection to
close.

Any ideas on what can be wrong?

As I said before, this socket application is working OK on other machines.

-- 
Martín Marqués
select 'martin.marques' || '@' || 'gmail.com'
DBA, Programador, Administrador

--- End Message ---
--- Begin Message --- Some months ago I downloaded and installed Apache, PHP and MySql. With only light use they seem to be working. I have downloaded a Test Script from the VBulletin vendor that is supposed to determine if your setup could run their product. The Test Script is php and appears as a form that allows you to enter a Mysql database name, user and password. I fill it in and select the button. The large blue window remains but the entry boxes and a border disappear. It hasn't totally crashed and can be closed - but it has stopped.

I've tried their help forum, but they keep telling me to create an empty database. Maybe the problem has something to do with Mysql, but for a test script, I'm getting zero feedback. I have an empty database and one with a couple of tables. I don't see a problem with Mysql. So, how does one begin to debug this php test script to see what's failing? I'm kind of new to php.
--- End Message ---
--- Begin Message ---
Patrick Moloney wrote:
I've tried their help forum, but they keep telling me to create an empty database.
Have you tried creating an empty database?

Stephen


--- End Message ---
--- Begin Message ---
Stephen wrote:
Patrick Moloney wrote:
I've tried their help forum, but they keep telling me to create an empty database.
Have you tried creating an empty database?

Stephen

yes.

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


On Apr 20, 2009, at 17:23, Patrick Moloney <[email protected]> wrote:

Some months ago I downloaded and installed Apache, PHP and MySql. With only light use they seem to be working. I have downloaded a Test Script from the VBulletin vendor that is supposed to determine if your setup could run their product. The Test Script is php and appears as a form that allows you to enter a Mysql database name, user and password. I fill it in and select the button. The large blue window remains but the entry boxes and a border disappear. It hasn't totally crashed and can be closed - but it has stopped.

I've tried their help forum, but they keep telling me to create an empty database. Maybe the problem has something to do with Mysql, but for a test script, I'm getting zero feedback. I have an empty database and one with a couple of tables. I don't see a problem with Mysql. So, how does one begin to debug this php test script to see what's failing? I'm kind of new to php.

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


Perhaps your install of php is blocking the error reporting from telling you where the problem is. Trying turning error reporting on

Bastien

--- End Message ---
--- Begin Message ---
i find var_dump useful in these situations, and for error reporting
try trigger error. http://php.net/manual/en/function.trigger-error.php

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

I have created few chats in the past, but I'm trying to create a new one
which saves on HTTP requests and do not become an overkill to the server as
more users get in.

The chat is a one on one, I'm trying to achieve this:
* A user sends a message
* The message is not saved/save temporarily on the server
* The message is showed to the other user

Any ideas how i should implement this?

I have no idea how to build it in the most efficiency way, any notes or
recommendations or
anything that I should pay attention to during development will be very
appreciated.

--- End Message ---
--- Begin Message ---
Martin Zvarík napsal(a):
I have 10 images of different sizes.

If user clicks ROTATE, a script will go through all these 10 images and rotates them.

If the user clicks TWICE, the first script will get aborted in the middle (so few images are already rotated) and then the second request will rotate all of them again.

I probably need to write a script that would lock the first file and if this file is already locked it would just die('already working...')

Is this a good approach?

I know I can use javascript to disable second click, but I want it server side.


Thanks for your suggestions,
Martin


I rename the first file at the beginning of the script.

Than do all rotations.

--

If there's another request, it checks if the file exists - if not = it's being processed = wait.

Simple.

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

How does one deal with that? Do you use mysql_real_escape_string?
e.g.
<?php
$db_host = 'localhost';
$db_user = 'auser';
$db_pwd = 'apassword';

$database = 'adatabase';
$table = 'authorBook';

if (!mysql_connect($db_host, $db_user, $db_pwd))
   die("Can't connect to database");

if (!mysql_select_db($database))
   die("Can't select database");

// sending query
$result = mysql_query("SELECT * FROM {$table}");

Inputs are user supplied.
Are you saying that I don't need to sanitize the variables above -
$db_host, $db_user, $db_pwd, $database, $table ?

No - they are essentially hardcoded.

A user (through a form or any other method) cannot change which db you are talking to. They cannot change the hostname either.

If a variable comes from:
- a post variable
- a get variable
- a session variable
- a cookie
- an environment variable

then it will need to be escaped & sanitized.

If you are putting the variable at the top of the script and there's no way for a user to change it, then no need to sanitize.

I would love to see an example somewhere that shows an unsanitized
variable and the same variable sanitized.

"Sanitizing" depends on what you need.

An age field doesn't need anything except a number.
A name field should accept everything except html tags.

They are going to be sanitized differently.

$name = $_POST['name']; <-- unsanitized
$name = strip_tags($name); <-- sanitized.

=========
Better:
myql_query("INSERT INTO foo (`name`) VALUES ('".
mysql_real_escape_string($name, $link) ."')");

This is better because we escape it in the sql statement itself.
$name remains unchanged in case we want to use it later.

Best:
Use prepared statements!
=========
What is meant by prepared stetements? Does that mean not using variables?

It's a different way of putting the query together. Data can only mean one thing - data. There's no escaping, the db will always know what it's going to do.

http://www.php.net/manual/en/pdo.prepare.php

--
Postgresql & php tutorials
http://www.designmagick.com/


--- End Message ---

Reply via email to