Re: [PHP]Zip and text files generated are corrupted

2010-03-30 Thread Bastien Helders
I've come to realize something, but I'm not sure if I could be right:

Maybe the instructions are interrupted because there is a lack of virtual
memory. I mean is there not a limit to the memory the script can use? It
would explain why the script goes on, as when the instruction is
interrupted, all the memory taken by it is released.

I don't know if I was clear about what I wanted to say...

2010/3/29 Bastien Helders eldroskan...@gmail.com

 I'm not sure. What is the exact command you are using?

 I'll show the code for the two scenario, maybe it'll help. I've edited out
 the sensitive information though, but I kept the essence of how it works.

 1) Copy the previous file and make modification on it

 ?php
 //This is this command that got interrupted and thus create the unexpected
 end-of-archive
 //To note is that the $previous_patch is retrieved from another file server
 copy($previous_patch,$zipname);

 //I go up in the file system, so that build/patchname doesn't appear in the
 paths in the zip archive.
 chdir('build/'.$patchname);

 //Foreach new folder add it to the copied patch
 foreach($folders_added as $folder){
 $command = 'zip -gr ../../' . $zipname . '
 software/hfFolders/'.$folder.'/* 21';
 exec($command, $output, $status);
 //show output and status
 }
 //I go down again, as it is no more needed when deleting entry in a zip
 file
 chdir('../..');

 //Foreach folder to be removed, remove it
 foreach($folders_removed as $folder){
 $command = 'zip -d ' . $zipname . '
 software/hfFolders/'.$folder.'\* 21';
 exec($command, $output, $status);
 //show output and status
 }



 2)After all the needed files are gathered in a temporary folder, compress
 the all

 ?php
 //I go up in the file system, so that build/patchname doesn't appear in the
 paths in the zip archive.
 chdir('build/'.$patchname);
 $command = 'zip -r ../../' . $zipname . ' * 21';
 //This is the command that timeout in this case
 exec($command, $output, $status);
 //show output and status

 //Do the rest of the operations


 I wonder if the zipArchive route would be easier.

 That what I was using before, but it modifies the timestamp of the file
 that are already in the zip archive and I can't have that.


 According to the documentation, both Apache and IIS have similar
 timeout values ...
 
 Your web server can have other timeout configurations that may also
 interrupt PHP execution. Apache has a Timeout directive and IIS has a
 CGI timeout function. Both default to 300 seconds. See your web server
 documentation for specific details.
 (
 http://docs.php.net/manual/en/info.configuration.php#ini.max-execution-time
 )

 Yeah I found this config in the httpd-default.conf file of my apache
 installation, but as I determined using two consecutive call of microtime()
 that the interrupted instructions doesn't go farther as 200 seconds, I don't
 see it relevant... (and again after the instruction is interrupted, the
 script continue to run.)


 Can you run the command from the shell directly without any problems.
 And run it repeatedly.

 I take that the equivalent of the php copy() function is the Windows copy
 command line.
 In this case, both copy on the big archive and zip -r on a big gathering of
 folder are running in the shell without any problem and repeatedly.


 2010/3/26 Richard Quadling rquadl...@googlemail.com

 On 26 March 2010 15:20, Bastien Helders eldroskan...@gmail.com wrote:
   I have checked the rights on the file for the first scenario and no
 user as
  locked it, I can see it, read it and write into it. I could even delete
 it
  if I wanted.
 
  For the second scenario, it doesn't even apply, as the exec('zip') that
  timeout try to create a new file (naturally in a folder where the web
 app
  user has all the necessary rights)
 
  In both case, it is no PHP timeout, as after the copy() in the first
  scenario, and the exec('zip') in the second scenario, the script
 continue to
  execute the other instructions, although the manipulation of the big
 files
  fails.
 
  But if it is not a PHP timeout, what is it?
 
  2010/3/26 Richard Quadling rquadl...@googlemail.com
 
  On 26 March 2010 12:21, Bastien Helders eldroskan...@gmail.com
 wrote:
   I already used error_reporting and set_time_limit and the use of
   ini_set('display_errors', 1); didn't display more exceptions.
  
   However the modification in the exec helped display STDERR I think.
  
   1) In the first scenario we have the following:
  
   STDERR
   zip warning: ../../build/Patch-6-3-2_Q3P15.zip not found or empty
  
   zip error: Internal logic error (write error on zip file)
   /STDERR
  
   The funny thing is, that now it is throwing status 5: a severe error
 in
   the
   zipfile format was
   detected. Processing probably failed imme­diately. Why It throw a
   status 5
   instead of a status 14, I can't say.
  
   So that's using 'zip -gr', when I stop using the option g and then
 call
   exec('zip -r 

[PHP] Still searching for a bugtracking system

2010-03-30 Thread Andre Polykanine
Hello everyone,
The best of all suggested bugtrackers is JotBug, on my opinion. But it
works only with SQLite databases, and I have no access to such one
(only MySql).
Any solutions?
P.S. I'd use Trac, but since I have no own server yet, we have no
access to Python, either... Only Php, MySql, Perl.
I have looked at Bugzilla... seems to heavy for our service).

-- 
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule


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



[PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread Andre Polykanine
Hello everyone,
Sorry, I've forgotten how to do this...
I need a quoted_printable_encode function but it's available only
since PHP 5.3. How do I redefine that function only if PHP version is
lower than 5.3?
Would it be valid:
function quoted_printable_encode ($str) {
$x=quoted_printable_encode ($str);
if (!isset($x)) {
// blah blah, alternative code
} else {
return $x;
}
}
Is it valid code or not?)
 Thanks!


-- 
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule


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



Re: [PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread David Otton
On 30 March 2010 14:16, Andre Polykanine an...@oire.org wrote:

 I need a quoted_printable_encode function but it's available only
 since PHP 5.3. How do I redefine that function only if PHP version is
 lower than 5.3?

function_exists().

if (!function_exists('myfunc')) {
function myfunc() {
;
}
}

http://uk3.php.net/function_exists

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



Re: [PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread Ashley Sheridan
On Tue, 2010-03-30 at 16:16 +0300, Andre Polykanine wrote:

 Hello everyone,
 Sorry, I've forgotten how to do this...
 I need a quoted_printable_encode function but it's available only
 since PHP 5.3. How do I redefine that function only if PHP version is
 lower than 5.3?
 Would it be valid:
 function quoted_printable_encode ($str) {
 $x=quoted_printable_encode ($str);
 if (!isset($x)) {
 // blah blah, alternative code
 } else {
 return $x;
 }
 }
 Is it valid code or not?)
  Thanks!
 
 
 -- 
 With best regards from Ukraine,
 Andre
 Http://oire.org/ - The Fantasy blogs of Oire
 Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
 jabber.org
 Yahoo! messenger: andre.polykanine; ICQ: 191749952
 Twitter: http://twitter.com/m_elensule
 
 


The custom way is to use function_exists() to check to see if the
function exists:

if (!function_exists('quoted_printable_encode'))
{
function quoted_printable_encode()
{
your code to replicate the functionality here
}
}

Then, you can call quoted_printable_encode safe in the knowledge that
there will always be a definition for it.


Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Alex Major
Surely if it's not suitable for your situation, it's not the best? :)

Mantis is what I'd recommend and believe has already been recommend to you.
Runs using PHP and MySQL, it's flexible for public or private projects,
multiple projects etc.

I do agree with you that Bugzilla seems heavy, I know it has its supporters
but I've always found it to be overkill for the projects I've worked on.

Alex.

-Original Message-
From: Andre Polykanine [mailto:an...@oire.org] 
Sent: 30 March 2010 14:14
To: php-general@lists.php.net
Subject: [PHP] Still searching for a bugtracking system

Hello everyone,
The best of all suggested bugtrackers is JotBug, on my opinion. But it
works only with SQLite databases, and I have no access to such one
(only MySql).
Any solutions?
P.S. I'd use Trac, but since I have no own server yet, we have no
access to Python, either... Only Php, MySql, Perl.
I have looked at Bugzilla... seems to heavy for our service).

-- 
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule


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


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



Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Jan G.B.
2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
  2010/3/29 Nathan Rixham nrix...@gmail.com
 
  Jan G.B. wrote:
  Top posting sucks, so I'll answer the post somewhere down there.
  SCNR
 
  2010/3/29 Devendra Jadhav devendra...@gmail.com
 
  Then you can do file_get_contents within PHP. or any file handling
  mechanism.
  On Mon, Mar 29, 2010 at 1:00 AM, ebhakt i...@ebhakt.com wrote:
  Hi
  i am writing a web application in php
  this webapp primarily focuses on file uploads and downloads
  the uploaded files will be saved in a folder which is not in
 document
  root
  and my query is how will i be able to provide download to such
 files
  not
  located in document root via php
 
  Try something like that
  ?php
  $content = file_get_contents($filename);
  $etag = md5($content);
  header('Last-Modified: '.gmdate('D, d M Y H:i:s',
  filemtime($filename)).' GMT');
  header('ETag: '.$etag);
  header('Accept-Ranges: bytes');
  header('Content-Length: '.strlen($content));
  header('Cache-Control: '.$cache_value); // you decide
  header('Content-type: '.$should_be_set);
  echo $content;
  exit;
  ?
 
  Depending on the $filesize, you should use something else than
  file_get_contents() (for example fopen/fread). file_get_contents on a
  huge
  file will exhaust your webservers RAM.
  Yup, so you can map the Directory /path/to in web server config; then
  allow from only from localhost + yourdomain. This means you can then
  request it like an url and do a head request to get the etag etc then
  return a 304 not modified if you received a matching etag Last-Modified
  etc; (thus meaning you only file_get_contents when really really
 needed).
 
  I'd advise against saying you Accept-Ranges bytes if you don't accept
  byte ranges (ie you aren't going to send little bits of the file).
 
  If you need the downloads to be secure only; then you could easily
  negate php all together and simply expose the directory via a location
  so that it is web accessible and set it up to ask for auth using
  htpasswd; a custom script, ldap or whatever.
 
  And if you don't need security then why have php involved at all? simply
  symlink to the directory or expose it via http and be done with the
  problem in a minute or two.
 
  Regards!
 
 
  In my opinion, serving user-content on a productive server is wicked
 sick.
  You don't want your visitors to upload malicous files that may trigger
 some
  modules as mod_php in apache. So it makes sense to store user-uploads
  outside of a docroot and with no symlink or whatsover.

 even the simplest of server configurations will ensure safety. just use
 .htaccess to SetHandler default-handler which treats everything as
 static content and serves it right up.


Yes. But the average persons posting here aren't server config gods, I
believe.
Also, you can not implement permissions on these files.
The discussion was about serving files from a place outside any docroot!
Guess there is a reason for that.



  One more thing added: your RAM will be exhausted even if you open that
 600mb
  file just once.
  Apaches memory handling is a bit weird: if *one* apache process is using
  200mb RAM on *one* impression because your application uses that much,
 then
  that process will not release the memory while it's serving another 1000
  requests for `clear.gif` which is maybe 850b in size.

 again everything depends on how you have your server configured; you can
 easily tell apache to kill each child after one run or a whole host of
 other configs; but ultimately if you can avoid opening up that file in
 php then do; serving statically as above is the cleanest quickest way to
 do it (other than using s3 or similar).

 regards!


Sure, you could configure your apache like that. Unless you have some
traffic on your site, because the time intensive thing for apache is to
spawn new processes. So it's just not a good idea to do that, Nor to serve
big files via file_get_contents.

Regards


Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Nathan Rixham
Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com
 
 Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
 Top posting sucks, so I'll answer the post somewhere down there.
 SCNR

 2010/3/29 Devendra Jadhav devendra...@gmail.com

 Then you can do file_get_contents within PHP. or any file handling
 mechanism.
 On Mon, Mar 29, 2010 at 1:00 AM, ebhakt i...@ebhakt.com wrote:
 Hi
 i am writing a web application in php
 this webapp primarily focuses on file uploads and downloads
 the uploaded files will be saved in a folder which is not in
 document
 root
 and my query is how will i be able to provide download to such
 files
 not
 located in document root via php

 Try something like that
 ?php
 $content = file_get_contents($filename);
 $etag = md5($content);
 header('Last-Modified: '.gmdate('D, d M Y H:i:s',
 filemtime($filename)).' GMT');
 header('ETag: '.$etag);
 header('Accept-Ranges: bytes');
 header('Content-Length: '.strlen($content));
 header('Cache-Control: '.$cache_value); // you decide
 header('Content-type: '.$should_be_set);
 echo $content;
 exit;
 ?

 Depending on the $filesize, you should use something else than
 file_get_contents() (for example fopen/fread). file_get_contents on a
 huge
 file will exhaust your webservers RAM.
 Yup, so you can map the Directory /path/to in web server config; then
 allow from only from localhost + yourdomain. This means you can then
 request it like an url and do a head request to get the etag etc then
 return a 304 not modified if you received a matching etag Last-Modified
 etc; (thus meaning you only file_get_contents when really really
 needed).
 I'd advise against saying you Accept-Ranges bytes if you don't accept
 byte ranges (ie you aren't going to send little bits of the file).

 If you need the downloads to be secure only; then you could easily
 negate php all together and simply expose the directory via a location
 so that it is web accessible and set it up to ask for auth using
 htpasswd; a custom script, ldap or whatever.

 And if you don't need security then why have php involved at all? simply
 symlink to the directory or expose it via http and be done with the
 problem in a minute or two.

 Regards!

 In my opinion, serving user-content on a productive server is wicked
 sick.
 You don't want your visitors to upload malicous files that may trigger
 some
 modules as mod_php in apache. So it makes sense to store user-uploads
 outside of a docroot and with no symlink or whatsover.
 even the simplest of server configurations will ensure safety. just use
 .htaccess to SetHandler default-handler which treats everything as
 static content and serves it right up.

 
 Yes. But the average persons posting here aren't server config gods, I
 believe.
 Also, you can not implement permissions on these files.
 The discussion was about serving files from a place outside any docroot!
 Guess there is a reason for that.
 
 
 One more thing added: your RAM will be exhausted even if you open that
 600mb
 file just once.
 Apaches memory handling is a bit weird: if *one* apache process is using
 200mb RAM on *one* impression because your application uses that much,
 then
 that process will not release the memory while it's serving another 1000
 requests for `clear.gif` which is maybe 850b in size.
 again everything depends on how you have your server configured; you can
 easily tell apache to kill each child after one run or a whole host of
 other configs; but ultimately if you can avoid opening up that file in
 php then do; serving statically as above is the cleanest quickest way to
 do it (other than using s3 or similar).

 regards!

 
 Sure, you could configure your apache like that. Unless you have some
 traffic on your site, because the time intensive thing for apache is to
 spawn new processes. So it's just not a good idea to do that, Nor to serve
 big files via file_get_contents.

was only addressing and issue you pointed out.. anyways.. so you propose
what exactly? don't server via apache, don't use file_get_contents
instead do..?

ps you do realise that virtually every huge file on the net is served
via a web server w/o problems yeah?


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



Re: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Jan G.B.
2010/3/30 Alex Major p...@allydm.co.uk

 Surely if it's not suitable for your situation, it's not the best? :)

 Mantis is what I'd recommend and believe has already been recommend to you.
 Runs using PHP and MySQL, it's flexible for public or private projects,
 multiple projects etc.

 I do agree with you that Bugzilla seems heavy, I know it has its supporters
 but I've always found it to be overkill for the projects I've worked on.

 Alex.

 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 30 March 2010 14:14
 To: php-general@lists.php.net
 Subject: [PHP] Still searching for a bugtracking system

 Hello everyone,
 The best of all suggested bugtrackers is JotBug, on my opinion. But it
 works only with SQLite databases, and I have no access to such one
 (only MySql).
 Any solutions?
 P.S. I'd use Trac, but since I have no own server yet, we have no
 access to Python, either... Only Php, MySql, Perl.
 I have looked at Bugzilla... seems to heavy for our service).

 -

Well. I'm not a fan of mantis. Mantis has some annoying bugs and the
codebase seems weird.
It basically works, but that is all about it.


I quote http://sqlite.org/about.html :

 SQLite is a software library that implements 
a self-contained,serverless, zero-configuration, transactional SQL database 
engine.
...
 Unlike most other SQL databases, SQLite does not have a separate server 
 process. SQLite reads and writes directly to ordinary disk files. A complete 
 SQL database with multiple tables, indices, triggers, and views, is contained 
 in a single disk file.

So you don't need access to such a database.


Regards

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



Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Jan G.B.
2010/3/30 Nathan Rixham nrix...@gmail.com:
 Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
 Top posting sucks, so I'll answer the post somewhere down there.
 SCNR

 2010/3/29 Devendra Jadhav devendra...@gmail.com

 Then you can do file_get_contents within PHP. or any file handling
 mechanism.
 On Mon, Mar 29, 2010 at 1:00 AM, ebhakt i...@ebhakt.com wrote:
 Hi
 i am writing a web application in php
 this webapp primarily focuses on file uploads and downloads
 the uploaded files will be saved in a folder which is not in
 document
 root
 and my query is how will i be able to provide download to such
 files
 not
 located in document root via php

 Try something like that
 ?php
         $content = file_get_contents($filename);
         $etag = md5($content);
         header('Last-Modified: '.gmdate('D, d M Y H:i:s',
 filemtime($filename)).' GMT');
         header('ETag: '.$etag);
         header('Accept-Ranges: bytes');
         header('Content-Length: '.strlen($content));
         header('Cache-Control: '.$cache_value); // you decide
         header('Content-type: '.$should_be_set);
         echo $content;
         exit;
 ?

 Depending on the $filesize, you should use something else than
 file_get_contents() (for example fopen/fread). file_get_contents on a
 huge
 file will exhaust your webservers RAM.
 Yup, so you can map the Directory /path/to in web server config; then
 allow from only from localhost + yourdomain. This means you can then
 request it like an url and do a head request to get the etag etc then
 return a 304 not modified if you received a matching etag Last-Modified
 etc; (thus meaning you only file_get_contents when really really
 needed).
 I'd advise against saying you Accept-Ranges bytes if you don't accept
 byte ranges (ie you aren't going to send little bits of the file).

 If you need the downloads to be secure only; then you could easily
 negate php all together and simply expose the directory via a location
 so that it is web accessible and set it up to ask for auth using
 htpasswd; a custom script, ldap or whatever.

 And if you don't need security then why have php involved at all? simply
 symlink to the directory or expose it via http and be done with the
 problem in a minute or two.

 Regards!

 In my opinion, serving user-content on a productive server is wicked
 sick.
 You don't want your visitors to upload malicous files that may trigger
 some
 modules as mod_php in apache. So it makes sense to store user-uploads
 outside of a docroot and with no symlink or whatsover.
 even the simplest of server configurations will ensure safety. just use
 .htaccess to SetHandler default-handler which treats everything as
 static content and serves it right up.


 Yes. But the average persons posting here aren't server config gods, I
 believe.
 Also, you can not implement permissions on these files.
 The discussion was about serving files from a place outside any docroot!
 Guess there is a reason for that.


 One more thing added: your RAM will be exhausted even if you open that
 600mb
 file just once.
 Apaches memory handling is a bit weird: if *one* apache process is using
 200mb RAM on *one* impression because your application uses that much,
 then
 that process will not release the memory while it's serving another 1000
 requests for `clear.gif` which is maybe 850b in size.
 again everything depends on how you have your server configured; you can
 easily tell apache to kill each child after one run or a whole host of
 other configs; but ultimately if you can avoid opening up that file in
 php then do; serving statically as above is the cleanest quickest way to
 do it (other than using s3 or similar).

 regards!


 Sure, you could configure your apache like that. Unless you have some
 traffic on your site, because the time intensive thing for apache is to
 spawn new processes. So it's just not a good idea to do that, Nor to serve
 big files via file_get_contents.

 was only addressing and issue you pointed out.. anyways.. so you propose
 what exactly? don't server via apache, don't use file_get_contents
 instead do..?

 ps you do realise that virtually every huge file on the net is served
 via a web server w/o problems yeah?



I was recommending other file methods like fopen() combinations,
fpassthru() and at best readfile(). All of them do not buffer the
whole file in memory.

http://php.net/readfile
http://php.net/fpassthru

Regards

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



Re: [PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread Richard Quadling
On 30 March 2010 14:20, Ashley Sheridan a...@ashleysheridan.co.uk wrote:
 On Tue, 2010-03-30 at 16:16 +0300, Andre Polykanine wrote:

 Hello everyone,
 Sorry, I've forgotten how to do this...
 I need a quoted_printable_encode function but it's available only
 since PHP 5.3. How do I redefine that function only if PHP version is
 lower than 5.3?
 Would it be valid:
 function quoted_printable_encode ($str) {
 $x=quoted_printable_encode ($str);
 if (!isset($x)) {
 // blah blah, alternative code
 } else {
 return $x;
 }
 }
 Is it valid code or not?)
                          Thanks!


 --
 With best regards from Ukraine,
 Andre
 Http://oire.org/ - The Fantasy blogs of Oire
 Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
 jabber.org
 Yahoo! messenger: andre.polykanine; ICQ: 191749952
 Twitter: http://twitter.com/m_elensule




 The custom way is to use function_exists() to check to see if the
 function exists:

 if (!function_exists('quoted_printable_encode'))
 {
    function quoted_printable_encode()
    {
        your code to replicate the functionality here
    }
 }

 Then, you can call quoted_printable_encode safe in the knowledge that
 there will always be a definition for it.


 Thanks,
 Ash
 http://www.ashleysheridan.co.uk




http://pear.php.net/package/PHP_Compat contains a LOT of userland
functions to allow for forward compatibility of old code.

PHP_Compat provides drop-in functions and constants for compatibility
with newer versions of PHP, environment emulation, and an API to allow
for version independent authoring.



-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread Igor Escobar
See
http://br2.php.net/manual/en/function.create-function.php


Regards,
Igor Escobar
Systems Analyst  Interface Designer

+ http://blog.igorescobar.com
+ http://www.igorescobar.com
+ @igorescobar (twitter)





On Tue, Mar 30, 2010 at 10:23 AM, David Otton 
phpm...@jawbone.freeserve.co.uk wrote:

 On 30 March 2010 14:16, Andre Polykanine an...@oire.org wrote:

  I need a quoted_printable_encode function but it's available only
  since PHP 5.3. How do I redefine that function only if PHP version is
  lower than 5.3?

 function_exists().

 if (!function_exists('myfunc')) {
function myfunc() {
;
}
 }

 http://uk3.php.net/function_exists

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




Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Nathan Rixham
Jan G.B. wrote:
 I was recommending other file methods like fopen() combinations,
 fpassthru() and at best readfile(). All of them do not buffer the
 whole file in memory.
 
 http://php.net/readfile
 http://php.net/fpassthru

ahh so you were; completely missed that, apologies - readfile's the one
and good advice.

still keen to point out that if you don't need any other features from
php then why use php when webserver will do the job perfectly well -
primary reason for me mentioning this is to take advantage of the cache
control / etag / last modified etc (most php scripts just return 200 ok
repeatedly)

regards

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



Re: [PHP] How to redefine a function if it doesn't exist?

2010-03-30 Thread Ashley Sheridan
On Tue, 2010-03-30 at 12:26 -0300, Igor Escobar wrote:

 See
 http://br2.php.net/manual/en/function.create-function.php
 
 
 Regards,
 Igor Escobar
 Systems Analyst  Interface Designer
 
 + http://blog.igorescobar.com
 + http://www.igorescobar.com
 + @igorescobar (twitter)
 
 
 
 
 
 On Tue, Mar 30, 2010 at 10:23 AM, David Otton 
 phpm...@jawbone.freeserve.co.uk wrote:
 
  On 30 March 2010 14:16, Andre Polykanine an...@oire.org wrote:
 
   I need a quoted_printable_encode function but it's available only
   since PHP 5.3. How do I redefine that function only if PHP version is
   lower than 5.3?
 
  function_exists().
 
  if (!function_exists('myfunc')) {
 function myfunc() {
 ;
 }
  }
 
  http://uk3.php.net/function_exists
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


That is only really useful for creating a function at run-time, not for
defining a function if it doesn't exist. As I and several others have
pointed out, the best way is to use function_exists() to determine
whether to create one or not. Presumably if you need to redefine a
function, you know its arguments before the code executes.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Yousif Masoud
On Tue, Mar 30, 2010 at 2:13 PM, Andre Polykanine an...@oire.org wrote:

 Hello everyone,
 The best of all suggested bugtrackers is JotBug, on my opinion. But it
 works only with SQLite databases, and I have no access to such one
 (only MySql).
 Any solutions?

[...]

I use Eventum.  So far, so good.

http://dev.mysql.com/downloads/other/eventum/

Works fine with Maria DB too.


Re: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Bastien Koert
On Tue, Mar 30, 2010 at 1:11 PM, Yousif Masoud yousif.mas...@gmail.com wrote:
 On Tue, Mar 30, 2010 at 2:13 PM, Andre Polykanine an...@oire.org wrote:

 Hello everyone,
 The best of all suggested bugtrackers is JotBug, on my opinion. But it
 works only with SQLite databases, and I have no access to such one
 (only MySql).
 Any solutions?

 [...]

 I use Eventum.  So far, so good.

 http://dev.mysql.com/downloads/other/eventum/

 Works fine with Maria DB too.


http://ca.php.net/manual/en/sqlite.requirements.php shows that sqlite
is a part of php as of version 5

-- 

Bastien

Cat, the other other white meat

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



Re[2]: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Andre Polykanine
Hello Jan,

And what do you use then?)

-- 
With best regards from Ukraine,
Andre
Skype: Francophile; WlmMSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

- Original message -
From: Jan G.B. ro0ot.w...@googlemail.com
To: Alex Major p...@allydm.co.uk
Date: Tuesday, March 30, 2010, 6:04:20 PM
Subject: [PHP] Still searching for a bugtracking system

2010/3/30 Alex Major p...@allydm.co.uk

 Surely if it's not suitable for your situation, it's not the best? :)

 Mantis is what I'd recommend and believe has already been recommend to you.
 Runs using PHP and MySQL, it's flexible for public or private projects,
 multiple projects etc.

 I do agree with you that Bugzilla seems heavy, I know it has its supporters
 but I've always found it to be overkill for the projects I've worked on.

 Alex.

 -Original Message-
 From: Andre Polykanine [mailto:an...@oire.org]
 Sent: 30 March 2010 14:14
 To: php-general@lists.php.net
 Subject: [PHP] Still searching for a bugtracking system

 Hello everyone,
 The best of all suggested bugtrackers is JotBug, on my opinion. But it
 works only with SQLite databases, and I have no access to such one
 (only MySql).
 Any solutions?
 P.S. I'd use Trac, but since I have no own server yet, we have no
 access to Python, either... Only Php, MySql, Perl.
 I have looked at Bugzilla... seems to heavy for our service).

 -

Well. I'm not a fan of mantis. Mantis has some annoying bugs and the
codebase seems weird.
It basically works, but that is all about it.


I quote http://sqlite.org/about.html :

 SQLite is a software library that implements 
a self-contained,serverless, zero-configuration, transactional SQL database 
engine.
...
 Unlike most other SQL databases, SQLite does not have a separate server 
 process. SQLite reads and writes directly to ordinary disk files. A complete 
 SQL database with multiple tables, indices, triggers, and views, is contained 
 in a single disk file.

So you don't need access to such a database.


Regards

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


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



Re: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Shawn McKenzie
Andre Polykanine wrote:
 Hello Jan,
 
 And what do you use then?)
 
If you're able to, you enable the sqllite extension in your php.ini and
then you create your database as a flat file.  The installer for the bug
tracker would probably do that for you.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Anshul Agrawal
On Tue, Mar 30, 2010 at 8:41 PM, Jan G.B. ro0ot.w...@googlemail.com wrote:

 2010/3/30 Nathan Rixham nrix...@gmail.com:
  Jan G.B. wrote:
  2010/3/29 Nathan Rixham nrix...@gmail.com
 
  Jan G.B. wrote:
  2010/3/29 Nathan Rixham nrix...@gmail.com
 
  Jan G.B. wrote:
  Top posting sucks, so I'll answer the post somewhere down there.
  SCNR
 
  2010/3/29 Devendra Jadhav devendra...@gmail.com
 
  Then you can do file_get_contents within PHP. or any file handling
  mechanism.
  On Mon, Mar 29, 2010 at 1:00 AM, ebhakt i...@ebhakt.com wrote:
  Hi
  i am writing a web application in php
  this webapp primarily focuses on file uploads and downloads
  the uploaded files will be saved in a folder which is not in
  document
  root
  and my query is how will i be able to provide download to such
  files
  not
  located in document root via php
 
  Try something like that
  ?php
  $content = file_get_contents($filename);
  $etag = md5($content);
  header('Last-Modified: '.gmdate('D, d M Y H:i:s',
  filemtime($filename)).' GMT');
  header('ETag: '.$etag);
  header('Accept-Ranges: bytes');
  header('Content-Length: '.strlen($content));
  header('Cache-Control: '.$cache_value); // you decide
  header('Content-type: '.$should_be_set);
  echo $content;
  exit;
  ?
 
  Depending on the $filesize, you should use something else than
  file_get_contents() (for example fopen/fread). file_get_contents on
 a
  huge
  file will exhaust your webservers RAM.
  Yup, so you can map the Directory /path/to in web server config;
 then
  allow from only from localhost + yourdomain. This means you can
 then
  request it like an url and do a head request to get the etag etc then
  return a 304 not modified if you received a matching etag
 Last-Modified
  etc; (thus meaning you only file_get_contents when really really
  needed).
  I'd advise against saying you Accept-Ranges bytes if you don't accept
  byte ranges (ie you aren't going to send little bits of the file).
 
  If you need the downloads to be secure only; then you could easily
  negate php all together and simply expose the directory via a
 location
  so that it is web accessible and set it up to ask for auth using
  htpasswd; a custom script, ldap or whatever.
 
  And if you don't need security then why have php involved at all?
 simply
  symlink to the directory or expose it via http and be done with the
  problem in a minute or two.
 
  Regards!
 
  In my opinion, serving user-content on a productive server is wicked
  sick.
  You don't want your visitors to upload malicous files that may trigger
  some
  modules as mod_php in apache. So it makes sense to store user-uploads
  outside of a docroot and with no symlink or whatsover.
  even the simplest of server configurations will ensure safety. just use
  .htaccess to SetHandler default-handler which treats everything as
  static content and serves it right up.
 
 
  Yes. But the average persons posting here aren't server config gods, I
  believe.
  Also, you can not implement permissions on these files.
  The discussion was about serving files from a place outside any docroot!
  Guess there is a reason for that.
 
 
  One more thing added: your RAM will be exhausted even if you open that
  600mb
  file just once.
  Apaches memory handling is a bit weird: if *one* apache process is
 using
  200mb RAM on *one* impression because your application uses that much,
  then
  that process will not release the memory while it's serving another
 1000
  requests for `clear.gif` which is maybe 850b in size.
  again everything depends on how you have your server configured; you
 can
  easily tell apache to kill each child after one run or a whole host of
  other configs; but ultimately if you can avoid opening up that file in
  php then do; serving statically as above is the cleanest quickest way
 to
  do it (other than using s3 or similar).
 
  regards!
 
 
  Sure, you could configure your apache like that. Unless you have some
  traffic on your site, because the time intensive thing for apache is to
  spawn new processes. So it's just not a good idea to do that, Nor to
 serve
  big files via file_get_contents.
 
  was only addressing and issue you pointed out.. anyways.. so you propose
  what exactly? don't server via apache, don't use file_get_contents
  instead do..?
 
  ps you do realise that virtually every huge file on the net is served
  via a web server w/o problems yeah?
 
 

 I was recommending other file methods like fopen() combinations,
 fpassthru() and at best readfile(). All of them do not buffer the
 whole file in memory.

 http://php.net/readfile
 http://php.net/fpassthru

 Regards



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


I wanted to see the diff between the memory usage of following three methods
in PHP.
1. readfile
2. fopen followed by fpassthru, and
3. file_get_contents


Re: [PHP] how to provide download of files mow in documentroot

2010-03-30 Thread Nathan Rixham
Anshul Agrawal wrote:
 On Tue, Mar 30, 2010 at 8:41 PM, Jan G.B. ro0ot.w...@googlemail.com wrote:
 
 2010/3/30 Nathan Rixham nrix...@gmail.com:
 Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
 2010/3/29 Nathan Rixham nrix...@gmail.com

 Jan G.B. wrote:
 Top posting sucks, so I'll answer the post somewhere down there.
 SCNR

 2010/3/29 Devendra Jadhav devendra...@gmail.com

 Then you can do file_get_contents within PHP. or any file handling
 mechanism.
 On Mon, Mar 29, 2010 at 1:00 AM, ebhakt i...@ebhakt.com wrote:
 Hi
 i am writing a web application in php
 this webapp primarily focuses on file uploads and downloads
 the uploaded files will be saved in a folder which is not in
 document
 root
 and my query is how will i be able to provide download to such
 files
 not
 located in document root via php

 Try something like that
 ?php
 $content = file_get_contents($filename);
 $etag = md5($content);
 header('Last-Modified: '.gmdate('D, d M Y H:i:s',
 filemtime($filename)).' GMT');
 header('ETag: '.$etag);
 header('Accept-Ranges: bytes');
 header('Content-Length: '.strlen($content));
 header('Cache-Control: '.$cache_value); // you decide
 header('Content-type: '.$should_be_set);
 echo $content;
 exit;
 ?

 Depending on the $filesize, you should use something else than
 file_get_contents() (for example fopen/fread). file_get_contents on
 a
 huge
 file will exhaust your webservers RAM.
 Yup, so you can map the Directory /path/to in web server config;
 then
 allow from only from localhost + yourdomain. This means you can
 then
 request it like an url and do a head request to get the etag etc then
 return a 304 not modified if you received a matching etag
 Last-Modified
 etc; (thus meaning you only file_get_contents when really really
 needed).
 I'd advise against saying you Accept-Ranges bytes if you don't accept
 byte ranges (ie you aren't going to send little bits of the file).

 If you need the downloads to be secure only; then you could easily
 negate php all together and simply expose the directory via a
 location
 so that it is web accessible and set it up to ask for auth using
 htpasswd; a custom script, ldap or whatever.

 And if you don't need security then why have php involved at all?
 simply
 symlink to the directory or expose it via http and be done with the
 problem in a minute or two.

 Regards!

 In my opinion, serving user-content on a productive server is wicked
 sick.
 You don't want your visitors to upload malicous files that may trigger
 some
 modules as mod_php in apache. So it makes sense to store user-uploads
 outside of a docroot and with no symlink or whatsover.
 even the simplest of server configurations will ensure safety. just use
 .htaccess to SetHandler default-handler which treats everything as
 static content and serves it right up.

 Yes. But the average persons posting here aren't server config gods, I
 believe.
 Also, you can not implement permissions on these files.
 The discussion was about serving files from a place outside any docroot!
 Guess there is a reason for that.


 One more thing added: your RAM will be exhausted even if you open that
 600mb
 file just once.
 Apaches memory handling is a bit weird: if *one* apache process is
 using
 200mb RAM on *one* impression because your application uses that much,
 then
 that process will not release the memory while it's serving another
 1000
 requests for `clear.gif` which is maybe 850b in size.
 again everything depends on how you have your server configured; you
 can
 easily tell apache to kill each child after one run or a whole host of
 other configs; but ultimately if you can avoid opening up that file in
 php then do; serving statically as above is the cleanest quickest way
 to
 do it (other than using s3 or similar).

 regards!

 Sure, you could configure your apache like that. Unless you have some
 traffic on your site, because the time intensive thing for apache is to
 spawn new processes. So it's just not a good idea to do that, Nor to
 serve
 big files via file_get_contents.
 was only addressing and issue you pointed out.. anyways.. so you propose
 what exactly? don't server via apache, don't use file_get_contents
 instead do..?

 ps you do realise that virtually every huge file on the net is served
 via a web server w/o problems yeah?


 I was recommending other file methods like fopen() combinations,
 fpassthru() and at best readfile(). All of them do not buffer the
 whole file in memory.

 http://php.net/readfile
 http://php.net/fpassthru

 Regards



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


 I wanted to see the diff between the memory usage of following three methods
 in PHP.
 1. readfile
 2. fopen followed by fpassthru, and
 3. file_get_contents
 
 Using xdebug trace, all three of them gave same number. With
 memory_get_peak_usage(true) 

Re: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Jorge Gomes
What about flyspray?

http://flyspray.org/

Demo: http://flyspray.org/demo

They use it for tracking the bugs of their software (obviously):
http://bugs.flyspray.org/

They have bad documentation but I tested the software and seems to be fine.
They are slowly working in the final 1.0 version.

Rewards
___
Jorge Gomes


2010/3/30 Shawn McKenzie nos...@mckenzies.net

 Andre Polykanine wrote:
  Hello Jan,
 
  And what do you use then?)
 
 If you're able to, you enable the sqllite extension in your php.ini and
 then you create your database as a flat file.  The installer for the bug
 tracker would probably do that for you.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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




[PHP] using UID in DB

2010-03-30 Thread Tommy Pham
Hi,

I'm just wondering if anyone on this list using some type of
UID/UUID/GUID in any of the DB?  If so, what DBMS/RDBMS are you using
and how many rows do you have for the table(s) using it?  What data
type are you using for that column?

TIA,
Tommy

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



Re: [PHP] using UID in DB

2010-03-30 Thread Paul M Foster
On Tue, Mar 30, 2010 at 01:36:27PM -0700, Tommy Pham wrote:

 Hi,
 
 I'm just wondering if anyone on this list using some type of
 UID/UUID/GUID in any of the DB?  If so, what DBMS/RDBMS are you using
 and how many rows do you have for the table(s) using it?  What data
 type are you using for that column?

If I understand you correctly, I use a single table, users. Either
MySQL or PostgreSQL (depending on the application). There is one record
per user, and that record contains a serial/sequential ID, set by the
system, a user ID which is varchar(8), email address which is
varchar(255), username which is varchar(50) and a password which is
varchar(32) and stored encrypted.

There are other related tables I use to record which URLs require
security and which users have access to those URLs.

Paul

-- 
Paul M. Foster

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



Re: [PHP] using UID in DB

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 2:04 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Mar 30, 2010 at 01:36:27PM -0700, Tommy Pham wrote:

 Hi,

 I'm just wondering if anyone on this list using some type of
 UID/UUID/GUID in any of the DB?  If so, what DBMS/RDBMS are you using
 and how many rows do you have for the table(s) using it?  What data
 type are you using for that column?

 If I understand you correctly, I use a single table, users. Either
 MySQL or PostgreSQL (depending on the application). There is one record
 per user, and that record contains a serial/sequential ID, set by the
 system, a user ID which is varchar(8), email address which is
 varchar(255), username which is varchar(50) and a password which is
 varchar(32) and stored encrypted.


Hi Paul,

In the case of mysql, it would be UUID and the value would look like this:

22ea1df1-3c40-11df-ab7a-200cd91e08cf

and the case of postgresql,

A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11
{a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}
a0eebc999c0b4ef8bb6d6bb9bd380a11

which is 36 CHAR length (including dashes not braces) and is not quite
like identity insert (autoincrement).  You could store it as
binary(16) - in mysql - but you'll need to implement UDFs to convert
between binary  char.  Is that what you're using? or Are you using an
INT type?

Regards,
Tommy

 There are other related tables I use to record which URLs require
 security and which users have access to those URLs.

 Paul


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



[PHP] Re: using UID in DB

2010-03-30 Thread Nathan Rixham
Tommy Pham wrote:
 Hi,
 
 I'm just wondering if anyone on this list using some type of
 UID/UUID/GUID in any of the DB?  If so, what DBMS/RDBMS are you using
 and how many rows do you have for the table(s) using it?  What data
 type are you using for that column?

nope never been able to find any significant advantage; and thus ended
up using http uri's in my own domain space(s) which are always
guaranteed to be unique as I'm issuing them. bonus is that they can be
dereferenced and server as both a universal (resource) identifier and a
locater.

ps: resource = anything that can be named.

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



Re: [PHP] Re: using UID in DB

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 2:27 PM, Nathan Rixham nrix...@gmail.com wrote:

 nope never been able to find any significant advantage; and thus ended
 up using http uri's in my own domain space(s) which are always
 guaranteed to be unique as I'm issuing them. bonus is that they can be
 dereferenced and server as both a universal (resource) identifier and a
 locater.

 ps: resource = anything that can be named.


Hi Nathan,

I'm interested in hearing your technique of generating your own uuid
if you don't mind sharing :).  I'm building a project to test my idea
about search engine and testing of different RDBMSes.  So naturally,
it (the app) would crawl the net and I'd have over a 1 billion rows.

Thanks,
Tommy

PS: Here are some info for those who haven't heard of UUID/GUID:

http://affy.blogspot.com/2003/03/why-use-uuid-values.html
http://www.mysqlperformanceblog.com/2007/03/13/to-uuid-or-not-to-uuid/

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



[PHP] cURL on freebsd

2010-03-30 Thread Shane Hill
can anyone tell me why the cURL code below produces a POST request as
expected on linux, but the same code on freebsd is forced to be a GET
request?

the linux box is running php 5.2.11
the freebsd box is running 5.3.2

is there a bug in 5.3.2?  a search does not turn anything up.

=

   function makePostRequest( $url , $params ) {
$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$headers = array(
'Content-type: application/json',
'Expect:'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_UPLOAD, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$content = curl_exec($ch);

$errorCode = (int)curl_getinfo($ch,
CURLINFO_HTTP_CODE);
return array(content = $content, errorCode =
$errorCode);
}


Re: [PHP] using UID in DB

2010-03-30 Thread Paul M Foster
On Tue, Mar 30, 2010 at 02:18:53PM -0700, Tommy Pham wrote:

 On Tue, Mar 30, 2010 at 2:04 PM, Paul M Foster pa...@quillandmouse.com 
 wrote:
  On Tue, Mar 30, 2010 at 01:36:27PM -0700, Tommy Pham wrote:
 
  Hi,
 
  I'm just wondering if anyone on this list using some type of
  UID/UUID/GUID in any of the DB?  If so, what DBMS/RDBMS are you using
  and how many rows do you have for the table(s) using it?  What data
  type are you using for that column?
 
  If I understand you correctly, I use a single table, users. Either
  MySQL or PostgreSQL (depending on the application). There is one record
  per user, and that record contains a serial/sequential ID, set by the
  system, a user ID which is varchar(8), email address which is
  varchar(255), username which is varchar(50) and a password which is
  varchar(32) and stored encrypted.
 
 
 Hi Paul,
 
 In the case of mysql, it would be UUID and the value would look like this:
 
 22ea1df1-3c40-11df-ab7a-200cd91e08cf
 
 and the case of postgresql,
 
 A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11
 {a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11}
 a0eebc999c0b4ef8bb6d6bb9bd380a11
 
 which is 36 CHAR length (including dashes not braces) and is not quite
 like identity insert (autoincrement).  You could store it as
 binary(16) - in mysql - but you'll need to implement UDFs to convert
 between binary  char.  Is that what you're using? or Are you using an
 INT type?

Unless you have some compelling need to store a number like this, I
don't see the need to. What I store is what is called in PostgreSQL a
serial value. MySQL calls it auto_increment. You store all the other
values as a row, and the DBMS adds in the auto_increment/serial
value for you. It's an integer, *usually* one larger than the last value
entered.

Paul


-- 
Paul M. Foster

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



Re: [PHP] cURL on freebsd

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 7:36 PM, Shane Hill shanehil...@gmail.com wrote:
 can anyone tell me why the cURL code below produces a POST request as
 expected on linux, but the same code on freebsd is forced to be a GET
 request?

 the linux box is running php 5.2.11
 the freebsd box is running 5.3.2

 is there a bug in 5.3.2?  a search does not turn anything up.


Just curious, what version of FreeBSD?  Did you compile PHP 
extensions or used the packages?

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



Re: [PHP] using UID in DB

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 7:37 PM, Paul M Foster pa...@quillandmouse.com wrote:

 Unless you have some compelling need to store a number like this, I
 don't see the need to. What I store is what is called in PostgreSQL a
 serial value. MySQL calls it auto_increment. You store all the other
 values as a row, and the DBMS adds in the auto_increment/serial
 value for you. It's an integer, *usually* one larger than the last value
 entered.

 Paul


The (personal) project I'm about to start will run in several threads
(thinking how can I make this happen in PHP) where the inserts could
be multiple inserts at once.  Identity (type) insert doesn't behave
nicely (locking up the DB) when there are multiple inserts at once.
Using UUID is one of the possible solution to resolving this problem
for me.

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



Re: [PHP] using UID in DB

2010-03-30 Thread Paul M Foster
On Tue, Mar 30, 2010 at 08:07:01PM -0700, Tommy Pham wrote:

 On Tue, Mar 30, 2010 at 7:37 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
 
  Unless you have some compelling need to store a number like this, I
  don't see the need to. What I store is what is called in PostgreSQL a
  serial value. MySQL calls it auto_increment. You store all the other
  values as a row, and the DBMS adds in the auto_increment/serial
  value for you. It's an integer, *usually* one larger than the last value
  entered.
 
  Paul
 
 
 The (personal) project I'm about to start will run in several threads
 (thinking how can I make this happen in PHP) where the inserts could
 be multiple inserts at once.  Identity (type) insert doesn't behave
 nicely (locking up the DB) when there are multiple inserts at once.
 Using UUID is one of the possible solution to resolving this problem
 for me.

I initially misunderstood your request.

But what DBMS are you using that locks up on multiple simultaneous
inserts? Any reasonable DBMS (besides SQLite) ought to queue inserts and
execute them without locking up.

I think I still don't understand what you're trying to do. It appears
you're trying to get around an insert-locking problem by using UUIDs.
But I'm not sure how a UUID will resolve your problem. As far as the
DBMS is concerned, and insert is an insert, regardless of what you're
storing. A UUID would just be another field to store; it could be any
datatype, as far as the DBMS is concerned. Now, if you actually mean
*updates*, that may be a different matter. But again, the DBMS should
queue them. 

I will say this-- if you're looking to add a unique identifier to each
record (I presume the reason for the UUID), and you're going to need
more than 2 billion records (32-bit platform), or 9 quadrillion records
(64-bit platform), integers or serials won't do. In PostgreSQL, you can
specify arbitrary precision numbers up to 1000 digits of precision as:

uuid number(128)

which would be what you're looking for. But you'd have to generate that
value yourself, as only a PostgreSQL serial type (integer) will
automatically increment.

Hope that helps (but I doubt it).

Paul

-- 
Paul M. Foster

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



Re: [PHP] cURL on freebsd

2010-03-30 Thread Shane Hill

On Mar 30, 2010, at 19:50, Tommy Pham tommy...@gmail.com wrote:

On Tue, Mar 30, 2010 at 7:36 PM, Shane Hill shanehil...@gmail.com  
wrote:

can anyone tell me why the cURL code below produces a POST request as
expected on linux, but the same code on freebsd is forced to be a GET
request?

the linux box is running php 5.2.11
the freebsd box is running 5.3.2

is there a bug in 5.3.2?  a search does not turn anything up.



Just curious, what version of FreeBSD?  Did you compile PHP 
extensions or used the packages?


Freebsd 7.2 stable

I compiled everything

enohPi ym morf tnes

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



Re: [PHP] using UID in DB

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 8:38 PM, Paul M Foster pa...@quillandmouse.com wrote:
 On Tue, Mar 30, 2010 at 08:07:01PM -0700, Tommy Pham wrote:

 On Tue, Mar 30, 2010 at 7:37 PM, Paul M Foster pa...@quillandmouse.com
 wrote:
 
  Unless you have some compelling need to store a number like this, I
  don't see the need to. What I store is what is called in PostgreSQL a
  serial value. MySQL calls it auto_increment. You store all the other
  values as a row, and the DBMS adds in the auto_increment/serial
  value for you. It's an integer, *usually* one larger than the last value
  entered.
 
  Paul
 

 The (personal) project I'm about to start will run in several threads
 (thinking how can I make this happen in PHP) where the inserts could
 be multiple inserts at once.  Identity (type) insert doesn't behave
 nicely (locking up the DB) when there are multiple inserts at once.
 Using UUID is one of the possible solution to resolving this problem
 for me.

 I initially misunderstood your request.

 But what DBMS are you using that locks up on multiple simultaneous
 inserts? Any reasonable DBMS (besides SQLite) ought to queue inserts and
 execute them without locking up.


In the past, I've not implement anything close to what I'm about to
do.  Initial test run of the app will be about 10 threads.  Live run
expected to be excess of 100 threads (and DB connections).  Thus, I've
yet to encounter the locking problems, but I've read many DB articles,
in the past few years, from different sources.  Some of those state
that lockup will happen when multiple simultaneous inserts occur.

 I think I still don't understand what you're trying to do. It appears
 you're trying to get around an insert-locking problem by using UUIDs.
 But I'm not sure how a UUID will resolve your problem. As far as the
 DBMS is concerned, and insert is an insert, regardless of what you're
 storing. A UUID would just be another field to store; it could be any
 datatype, as far as the DBMS is concerned. Now, if you actually mean
 *updates*, that may be a different matter. But again, the DBMS should
 queue them.

 I will say this-- if you're looking to add a unique identifier to each
 record (I presume the reason for the UUID), and you're going to need
 more than 2 billion records (32-bit platform), or 9 quadrillion records
 (64-bit platform), integers or serials won't do. In PostgreSQL, you can
 specify arbitrary precision numbers up to 1000 digits of precision as:

 uuid number(128)

 which would be what you're looking for. But you'd have to generate that
 value yourself, as only a PostgreSQL serial type (integer) will
 automatically increment.

 Hope that helps (but I doubt it).

 Paul

PostgreSQL have several functions to generate it:
http://www.postgresql.org/docs/8.3/static/uuid-ossp.html
MySQL has UUID().
MSSQL has NEWID().
Don't remember top of my head what Oracle has.
Don't know about Firebird as I have zero experience with it.

The adequate # of rows (of URL) I need is at least 1 billion.  Given
that if I fetch 1 URL / sec, it would take me at least 31 years :)).
If I can get it to run smoothly with over 100 threads, I'd have that
data in less 1/3 year :D

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



[PHP] Newbie Question about Conditionals

2010-03-30 Thread Matty Sarro
Hey all!
This is probably my second post on the list, so please be gentle. Right now
I am running through the Heads First PHP and MySQL book from O'Reilly.
It's been quite enjoyable so far, but I have some questions about some of
the code they're using in one of the chapters.

Basically the code is retreiving rows from a DB, and I'm just not getting
the explanation of how it works.

Here's the code:

$result=mysqli_query($dbc,$query)

while($row=mysqli_fetch_array($result)){
echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] . 'br
/';
}

Now, I know what it does, but I don't understand how the conditional
statement in the while loop works. Isn't an assignment operation always
going to result in a true condition? Even if mysqli_fetch_array($result)
returned empty values (or null) wouldn't the actual assignment to $row still
be considered a true statement? I would have sworn that assignment
operations ALWAYS equated to true if used in conditional operations.
Please help explain! :)

Thanks so much!
-Matty


Re: [PHP] Newbie Question about Conditionals

2010-03-30 Thread Tommy Pham
On Tue, Mar 30, 2010 at 9:22 PM, Matty Sarro msa...@gmail.com wrote:
 Hey all!
 This is probably my second post on the list, so please be gentle. Right now
 I am running through the Heads First PHP and MySQL book from O'Reilly.
 It's been quite enjoyable so far, but I have some questions about some of
 the code they're using in one of the chapters.

 Basically the code is retreiving rows from a DB, and I'm just not getting
 the explanation of how it works.

 Here's the code:

 $result=mysqli_query($dbc,$query)

 while($row=mysqli_fetch_array($result)){
 echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] . 'br
 /';
 }

 Now, I know what it does, but I don't understand how the conditional
 statement in the while loop works. Isn't an assignment operation always
 going to result in a true condition? Even if mysqli_fetch_array($result)
 returned empty values (or null) wouldn't the actual assignment to $row still
 be considered a true statement? I would have sworn that assignment
 operations ALWAYS equated to true if used in conditional operations.
 Please help explain! :)

 Thanks so much!
 -Matty


http://www.php.net/manual/en/function.mysql-fetch-array.php

Returns an array of strings that corresponds to the fetched row, or
FALSE  if there are no more rows.

while($row=mysqli_fetch_array($result)) is equivalent to this:

$row=mysqli_fetch_array($result);
while ($row){

// do something

$row=mysqli_fetch_array($result);
}

So, if $row is not equal to FALSE, the loop will happens.

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



Re: [PHP] Newbie Question about Conditionals

2010-03-30 Thread Matty Sarro
That explains it perfectly, thanks you!

On Wed, Mar 31, 2010 at 12:40 AM, Tommy Pham tommy...@gmail.com wrote:

 On Tue, Mar 30, 2010 at 9:22 PM, Matty Sarro msa...@gmail.com wrote:
  Hey all!
  This is probably my second post on the list, so please be gentle. Right
 now
  I am running through the Heads First PHP and MySQL book from O'Reilly.
  It's been quite enjoyable so far, but I have some questions about some of
  the code they're using in one of the chapters.
 
  Basically the code is retreiving rows from a DB, and I'm just not getting
  the explanation of how it works.
 
  Here's the code:
 
  $result=mysqli_query($dbc,$query)
 
  while($row=mysqli_fetch_array($result)){
  echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] . 'br
  /';
  }
 
  Now, I know what it does, but I don't understand how the conditional
  statement in the while loop works. Isn't an assignment operation always
  going to result in a true condition? Even if
 mysqli_fetch_array($result)
  returned empty values (or null) wouldn't the actual assignment to $row
 still
  be considered a true statement? I would have sworn that assignment
  operations ALWAYS equated to true if used in conditional operations.
  Please help explain! :)
 
  Thanks so much!
  -Matty
 

 http://www.php.net/manual/en/function.mysql-fetch-array.php

 Returns an array of strings that corresponds to the fetched row, or
 FALSE  if there are no more rows.

 while($row=mysqli_fetch_array($result)) is equivalent to this:

 $row=mysqli_fetch_array($result);
 while ($row){

 // do something

 $row=mysqli_fetch_array($result);
 }

 So, if $row is not equal to FALSE, the loop will happens.