Re: [PHP] PHP Dev Facts

2008-10-17 Thread Michal Sokolowski
2008/10/17 Nathan Rixham [EMAIL PROTECTED]

 Evening All,

 I'd be /really/ interested to know who uses what!

 *Procedural or OOP?*

Mostly OO


 *Dev OS*

Ubuntu Hardy


 *Dev PHP Version*

5.2.? - I don't remember


 *Live Server OS*

CentOS, Fedora


 *Live Server PHP Version*

5.2.?


 *Which HTTP Server Software (+version)?*

Apache 2.2


 *IDE / Dev Environment*

Eclipse Ganymede + PDT


 *Preferred Framework(s)?*

Hopefully Zend soon, as I'm learning it now.



 *Do you Unit Test?*

No



 *Most Used Internal PHP Class*

PDO, Mysqli



 *Preferred OS CMS*

WordPress



 *Anything else you use frequently in you're PHP'ing that's worth
 mentioning:*

No



 ps: I'm not asking for any kind of research project, just interested and
 interested to know what's most common + might learn something/find some new
 tools/toys!

 pps: will reply myself as well but if I do here it'll make your intertwined
 replies messy!

 Many Regards

 Nathan

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




Re: [PHP] PHP tags - any reasons to close ?

2008-09-23 Thread Michal Sokolowski
Hi,

First time I've seen code without closing tag is when I've read about Zend
Framework and bellow is what they say about it.

For files that contain only PHP code, the closing tag (?) is never
permitted. It is not required by PHP, and omitting it prevents the
accidental injection of trailing whitespace into the response. 

Regards,
Michal Sokolowski

2008/9/23 Martin Zvarík [EMAIL PROTECTED]

 Hi,
 I have seen some projects where people start with opening tag ?php but
 they DON'T close it with ?
 This is especially the case of CONFIG.php files...

 1) What's the reason of that?

 2) What if you would not close any 100% PHP files?

 3) What's the reason of making an empty space after ?
 I've also seen this in some projects.


 Thanks for ideas,
 Martin

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




Re: [PHP] Re: Google Maps Distance Between UK Postcodes

2008-09-01 Thread Michal Sokolowski
2008/9/1 Tom Chubb [EMAIL PROTECTED]

 On 01/09/2008, Colin Guthrie [EMAIL PROTECTED] wrote:
 
  Tom Chubb wrote:
 
  I thought it would be easy but it seems that I need to convert each
  postcode
  to Lat/Long using Geocoding and then work it out from there.
 
 
  That's the best way: then just do something like:
 
  Here's how I do it in SQL, but the principle is the same in PHP, so I'm
  sure you'll be able to convert it.
 
  HTHs
 
  Col
 
  snip
   public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
  false)
   {
 $multiplier = 6371;
 if ($blnMiles)
   $multiplier *= 1.609344;
 
 $rv = ESQL
   (ACOS(
 SIN(RADIANS($latA)) * SIN(RADIANS($latB))
 + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
  RADIANS($lngA)))
   * $multiplier)
  ESQL;
 return $rv;
   }
  /snip
 
 
 
 
  --
 
  Colin Guthrie
  gmane(at)colin.guthr.ie
  http://colin.guthr.ie/
 
  Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
  Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 Thanks Colin,
 That's all way above my head, but I think I'll be able to understand it
 after a strong coffee!
 Any idea how you get the co-ords from the UK Postcode though?
 There seems to be a privacy factor with UK postcodes, but I'm only after
 the
 first section: eg SW11 6**



This address should help you. Thay have distance calculator on the page but
also you can download database with postcodes and their co-ords -
http://www.pc-i.co.uk/postcode-distance.php


Re: [PHP] System errno in PHP

2008-02-24 Thread Michal Maras
Hi

 Thank you for answer, but I do not understand.
 How can I use this class Errno after unsuccessful fopen?
 I want to get the number, for example 13 if there is not enough permissions
to open file.
It is not problem for me that script will be no portable, it is
only for AIX.

By

On 22/02/2008, Ravi Menon [EMAIL PROTECTED] wrote:

 Hi,

 I also ran into the same issue with file and socket apis, and for now, I
 just
 hack it like ( for linux 2.6 systems ):

 class Errno
 {
 const EINTR=  4;
 const EIO  =  5;
 const EINVAL   =  22;
 const ENODATA  =  61;
 const EBADMSG  =  74;
 const EOPNOTSUPP   =  95;
 const ECONNRESET   =  104;
 const ENOTCONN =  107;
 const ETIMEDOUT=  110;
 const EALREADY =  114;
 const EINPROGRESS  =  115;

 // useful static methods that use posix_strerror()
 // and socket_strerror() to return strings for logging purposes...
 .
 .

 }

 Clearly this is not portable, but I am betting that usually on the
 same kernel releases, they
 don't usually change these numbers around.

 Having PHP expose these useful constants in a portable manner would be
 a big plus.

 Thanks,
 Ravi


 On Thu, Feb 21, 2008 at 9:04 AM, Richard Lynch [EMAIL PROTECTED] wrote:
  On Wed, February 20, 2008 2:56 am, Michal Maras wrote:
I have read http://php.net/fopen from top to bottom, but I could not
find
how to get  system error number.
With set_error_handler I can get string for example
   
fopen(hmc_configuration.cfg)
[function.fopen
 http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen]:
failed to open stream: Permission denied
   
but I need integer number not string, because string error messages
depends
on locale setting.
 Of course, I can test some conditions before fopen, but it is not
enough
for me.
 
   Put in a Feature Request to expose the error number from the OS, I
   guess...
 
   http://bugs.php.net/
 
   It *seems* like it ought to be reasonable enough to this naive user.
 
 
   --
   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/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
 
 



Re: [PHP] System errno in PHP

2008-02-20 Thread Michal Maras
Hello Nick

I have read http://php.net/fopen from top to bottom, but I could not find
how to get  system error number.
With set_error_handler I can get string for example

fopen(hmc_configuration.cfg)
[function.fopenhttp://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen]:
failed to open stream: Permission denied

but I need integer number not string, because string error messages depends
on locale setting.
 Of course, I can test some conditions before fopen, but it is not enough
for me.

By

On 19/02/2008, Nick Stinemates [EMAIL PROTECTED] wrote:

 Michal Maras wrote:
  I am now using filesystem functions fopen, fread, fclose, ...
 
  On 19/02/2008, Stut [EMAIL PROTECTED] wrote:
 
  Michal Maras wrote:
 
   Coud somebody tell me if it is possible to get integer value of
 
  variable
 
  which name in C is errno end in perl $!.
   I am PHP beginner so I am sorry if question is 'stupid'.
 
  What function are you calling where you expect to get a system error?
  Check the manual page for that function - it will tell you how to
 detect
  errors.
 
  -Stut
 
  --
  http://stut.net/
 
 
 
 
 http://php.net/fopen

 --
 ==
 Nick Stinemates ([EMAIL PROTECTED])
 http://nick.stinemates.org

 AIM: Nick Stinemates
 MSN: [EMAIL PROTECTED]
 Yahoo: [EMAIL PROTECTED]
 ==

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




Re: [PHP] System errno in PHP

2008-02-20 Thread Michal Maras
Hi

Hmm.. I know I can check such sings as if file exists or has right
permission before fopen.
 But it does not mean that file will still exists with right permission a
moment later when
fopen will be issued.
 And I can't check everything. I can't image how to check whether file is
locked, or if it is on read only filesystems or
if limit of opened fil was  reached ...
 Similar problem can be with fseek, fread,...

By

On 20/02/2008, Stut [EMAIL PROTECTED] wrote:

 Michal Maras wrote:
  I have read http://php.net/fopen from top to bottom, but I could not
 find
  how to get  system error number.
  With set_error_handler I can get string for example
 
  fopen(hmc_configuration.cfg)
  [function.fopen
 http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen]:
  failed to open stream: Permission denied
 
  but I need integer number not string, because string error messages
 depends
  on locale setting.
   Of course, I can test some conditions before fopen, but it is not
 enough
  for me.

 What exactly are you trying to do? Why do you need the specific reason
 why it failed? It's pretty-much always a case of file not found or
 insufficient permissions, both of which you can check for before going
 near fopen.

 -Stut

 --
 http://stut.net/



[PHP] System errno in PHP

2008-02-19 Thread Michal Maras
Hello everybody

 Coud somebody tell me if it is possible to get integer value of variable
which name in C is errno end in perl $!.
 I am PHP beginner so I am sorry if question is 'stupid'.

By


Re: [PHP] System errno in PHP

2008-02-19 Thread Michal Maras
Hi

 I am asking about errno for Filesystems functions like
fopen, fread, fclose, ...

On 19/02/2008, Stut [EMAIL PROTECTED] wrote:

 Michal Maras wrote:
   Coud somebody tell me if it is possible to get integer value of
 variable
  which name in C is errno end in perl $!.
   I am PHP beginner so I am sorry if question is 'stupid'.

 What function are you calling where you expect to get a system error?
 Check the manual page for that function - it will tell you how to detect
 errors.

 -Stut

 --
 http://stut.net/



Re: [PHP] System errno in PHP

2008-02-19 Thread Michal Maras
I am now using filesystem functions fopen, fread, fclose, ...

On 19/02/2008, Stut [EMAIL PROTECTED] wrote:

 Michal Maras wrote:
   Coud somebody tell me if it is possible to get integer value of
 variable
  which name in C is errno end in perl $!.
   I am PHP beginner so I am sorry if question is 'stupid'.

 What function are you calling where you expect to get a system error?
 Check the manual page for that function - it will tell you how to detect
 errors.

 -Stut

 --
 http://stut.net/



Re: [PHP] XML Sending problem

2006-11-05 Thread Michal Manko

Hi Rosen,
You can do this for some ways.
The simplest:
1. Send via ftp - http://php.net/ftp
2. Send via scp using ssh2 - http://php.net/ssh2

Regards
Michael

Rosen said:

Hi,

I need to create an XML file and send it to another server, where script 
process the XML.
With creation and processing of XML I don't have a promlems, but how I can 
send XML to the processing script on another server ?



Thanks in advance,
Rosen 



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



Re: [PHP] Memcached Question

2006-10-29 Thread Michal Manko

Hi,
Best reference will be http://php.net/memcache i think.
Memcache is really effective tool, but it have one fault. Data keeping 
in this way are not stable.
Generally memcache is useful as a some kind of cache when you can have 
second data source, or when data, you want to save, have short ttl (time 
to live) (f.e. sessions ;-) ).

But I recommend it.

Have fun ;)

Michael




Sancar Saran said:

Hi,
Recently I discoverd Memcache daemon for sessions, I'm very pleased its 
performance.


I want to use memcache other than $_SESSION

For example, I have an array, it  has language definitions. Normally on each 
page load I have to include that file. 

So I want to put that array into Memcached and access from each different 
SESSIONID, I believe this will reduce memory usage and gives performance 
boost.


I found (and use) SESSION examples for Memcached usage. Does anyone has any 
other examples for memcached usage.


Regards.

Sancar



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



Re: [PHP] php4.3.4 phpinfo shows in mysql section as Client API version 3.23.49

2006-09-20 Thread Michal Stankoviansky

Hi

get it here:
http://dev.mysql.com/downloads/connector/php/

Michal

Muthu wrote:

Hi,

  I am using apache2.0+php4.3.4+mysql 4.1.1 in windows. If I type phpinfo(); , in mysql section it is coming as Client API version 3.23.49 . To get the latest mysql client library for php4.3.4, what should I do?. If I need to get the php_mysql.dll for php4.3.4, Where can I get these dlls? 


Thanks,
Muthu.

  


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



RE: [PHP] error message while mysqling on php

2005-09-14 Thread Michal Krezolek
Thanks very much. I had an extra character when I was connecting to the
database. Now everything works!!!

-Original Message-
From: Alan Fullmer [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 13, 2005 5:14 PM
To: 'Michal Krezolek'; php-general@lists.php.net
Subject: RE: [PHP] error message while mysqling on php

I see two things that could be it.

#1 your $result is not $result = mysql_query(queryline);

Or #2  your syntax on your query line is bad.

You can try doing something like this:

$query = SELECT * FROM table etc blah;
$result = mysql_query($query) or die(mysql_error());
$num = mysql_num_rows($result);


Sometimes the error message can be more explicit if you tell it to print it.
If you get no error on that query statement, then your query is fine.

 I have received an error: Warning: mysql_num_rows(): supplied argument is
 not a valid MySQL result resource in /home/www/mksystem.net when trying to
 execute $num = mysql_num_rows($result);
 
 Please go to http://mksystem.net/phpinfo.php and tell me whether it is due
 to the version of php I have on server and an easy workaround would be
 appreciated.

Check the syntax of your SQL statement, it's very possible you have an error
in it somewhere. If you have PHPMyAdmin, or some other interface to MySQL
such as MySQL Query Browser, etc, try executing the SQL statement in one of
them directly, to see if they return a valid resultset.

Much warmth,

Murray
---
Lost in thought...
http://www.planetthoughtful.org

-- 
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



[PHP] error message while mysqling on php

2005-09-13 Thread Michal Krezolek
I have received an error: Warning: mysql_num_rows(): supplied argument is
not a valid MySQL result resource in /home/www/mksystem.net when trying to
execute $num = mysql_num_rows($result);

Please go to http://mksystem.net/phpinfo.php and tell me whether it is due
to the version of php I have on server and an easy workaround would be
appreciated.



[PHP] Re: executed script URL

2005-03-24 Thread Michal Kozusznik
Hello

 Rasmus answered this question a week or two ago.  Search the archives
 for 'getenv request' and you will likely find the answer.

I found something (in last 3000 posts) but it says about
getenv('REMOTE_ADDR'). My problem is how to get an URL of executed
script in always working way, compatible will all servers/configs

The problem is in URLs like this

http://domain.name.com/ ... some path ... /script.php

Where I cannot get 'some path' part (in compatible way).


best regards
-- 
***Media-IT Micha Kousznik   ***
***  IT networks - databases - multimedia  ***
***[EMAIL PROTECTED]  ***
***  http://www.media-it.net   ***

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



Re: [PHP] general organization question

2004-10-12 Thread Michal Migurski
It'll make a small project seem huge in no time flat, but that's the
price you pay for 'organization' and stuff.
But frameworks can also make a huge project seem medium which is the
advantage of organization. Also, it's quite often the case that a small
project grows and slowly becomes a big project. At which time the 
payoff
can be realized :)
Da, this is true. It's what separates the good developer from the 
merely mediocre: experience teaches how to code a small project 
quickly, but keep it organized and flexible to adapt to the inevitable 
growth and refactoring. A framework that reflects this flexibility is a 
help, one that doesn't is a hindrance.

--
michal migurski- contact info, blog, and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] config.php

2004-10-11 Thread Michal Migurski
Is there anyway of creating a config.php file on the fly using a form.
To obtain verbose output, include the keyword how at the beginning of 
your query.

--
michal migurski- contact info, blog, and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Best practise for resolving potential conflicts when editing db content?

2004-10-11 Thread Michal Migurski
I'm not sure table locking is the answer. I'm not talking about 
concurrency
in the sense of 'simultaneous' updates and selects, but in the sense 
of an
'open record edit session' that predictably will overwrite the value 
of a
record that may have been changed, after the edit session began, but 
before
the edit session is committed.
Martin Fowler's book, Patterns of Enterprise Application Architecture 
(dull name, I know) has an excellent chapter which describes various 
kinds of locks. The main applicable distinction in your case is whether 
you want your lock to be Optimistic or Pessimistic, in other words - do 
you expect that such conflicts will happen frequently, or no?

If you expect conflicts often, make your lock pessimistic: when user A 
opens ups a record to edit, a flag gets set on the server which 
prevents user B from modifying the same record. This form of locking is 
also good when the change process is coarse, and losing edits would be 
a major inconvenience. In the case of editing a wiki page, you don't 
want user B to spend 20 minutes modifying a page, only to be told that 
there's a conflict and they should try again later, wasting all that 
work. You want them to know ahead of time. Your beingedited field in 
the DB is an example of a pessimistic lock.

If you don't expect conflicts often, or the cost of a conflict is low, 
make your lock optimistic: when user A and user B both have a record 
open, the first one to commit wins, and the second one gets an error 
message. This is an easy one to implement if you version your changes 
in some way, perhaps by indicating which version a user started with at 
commit time. CVS works this way, as does my wiki software of choice, 
Tavi Wiki. For these applications, the cost of a conflict is high 
(which would indicate that a pessimistic lock might be better), but 
there is a clean method provided to resolve them when they come up.

--
michal migurski- contact info, blog, and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] forms

2004-10-10 Thread Michal Migurski
Thanks-- i got that going-GREAT !  now i have a form that creates the
database and tables, any ideas how i can get this info to change the
connect_db file so that it doesnt have to be done manually.
See fopen(), fwrite(), and fclose(): 
http://php.net/manual/en/ref.filesystem.php

Not sure exactly what you're doing, but having PHP (via http) use a 
mysql account with create privileges and write your configuration files 
is a gaping security hole - fine for a 
personal/internal/ephemeral/testing project, but terrible security 
practice for any application or site that faces the outside world.

--
michal migurski- contact info, blog, and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Associative Array Benchmarking

2004-09-19 Thread Michal Migurski
 Although I'm not certain how well known this is, I thought I'd share
 this with everyone who might have wondered if there was a benefit to
 using or not using quotes when referencing associative arrays.

The benefit to using quotes is that it's the right thing to do, unless
you're looking for constants instead of strings. Sometimes a quick R of
the first few chapters in TFM beats a benchmark.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Lambert's Projection and PHP

2004-09-08 Thread Michal Migurski
 I'm working with a system that draws a map from certain information.
 Lambert's projection seems to suit well to our needs.

...

 I found a formula explaining the projection at
 http://mathworld.wolfram.com/LambertConformalConicProjection.html .
 Unfortunately there is no explanation that what units x and y are, so
 drawing them or further conversion is impossible.

x and y are the Cartesian coordinates on the projected map.
To be useful, they generally need to be scaled, translated, and rotated to
the particular dimensions of the map you wish to output.

I have a small library of classes which implement albers conical equal
are, lambert azimuthal equal area, and lambert conformal conic
projections here:
http://mike.teczno.com/map-code.tar

Those files are the beginnings of something I am planning to contribute to
the PEAR project, so if anyone has feedback or other projects they wish to
see added, they are very welcome.

See the test/lambert_conformal_conic.php file for an example of usage and
a brief unit test. Note that the reference latitude  longitude and the
standard parallels described in the mathworld write-up are the four
arguments to the constructor, and that all lat/long units are expected in
radian, not degrees. Sorry that the comments aren't as extensive as they
ought to be.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Multi-User Text-Editing

2004-09-07 Thread Michal Migurski
 Okay, i got the general idea, now it all comes down to the actual
 writing. I'm making a function that compares two strings (the one in the
 source i read used an exec() call, but i'd like to do it all in PHP)
 per-line. This poses some difficulties. Here's the scenario:

Tavi Wiki just calls out to the diff command using exec(), which is a lazy
way of doing it. The wiki at c2.com does this too. Not sure what mediawiki
(Raditha's suggestion) does. If you want to implement your own version of
diff in PHP, you can start at the explanation here:
http://c2.com/cgi/wiki?DiffAlgorithm

Also there is this:
http://pear.php.net/package/Text_Diff

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Multi-User Text-Editing

2004-09-06 Thread Michal Migurski
 What i want is basically a way for many users to update, add or delete
 parts of a text (the lyric). It will probably only be 'trusted' users
 that'll be able to do it (users that has added more than x
 artists/albums/songs). How can i make a CVS-like system, where you can
 see the changes people made, maybe roll back to an earlier version etc.
 etc.?

You've just described a wiki - one example of a wiki that is written in
PHP and MySQL is http://tavi.sourceforge.net. The code is a little
spaghetti-like, but you should be able to look through the database schema
to understand how they implement the multi-user text editing, and how to
handle the related problems of locking and revision control.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Multi-User Text-Editing

2004-09-06 Thread Michal Migurski
  You've just described a wiki - one example of a wiki that is written in
  PHP and MySQL is http://tavi.sourceforge.net. The code is a little
  spaghetti-like, but you should be able to look through the database schema
  to understand how they implement the multi-user text editing, and how to
  handle the related problems of locking and revision control.

 Wow, confusing code - but i think i got the idea. Just one thing: After
 reading the code, it seems to me that every time someone makes a change
 to a record, a new row is inserted into the DB with the full text of the
 edited record - not just the changes. I saw that there was an automatic
 expiration function, but still, wouldn't it be a drag for the server?

Yeah, that's what happens.

I think it's only a problem if you're storing truly stupendous amounts of
text, and then it's just a storage problem - drives are cheap.

If anything, storing the changes only would probably be a bigger processor
load, since viewing any one page would mean having to reconstruct the
content from all previous versions.  This way, the overhead of a diff is
only incurred when you want to view changes to a file between two given
versions.

I think the rationale behind CVS storing just diffs is that it has
branches and merges, while wiki text generally does not. Also (conjecture)
it may be a historical legacy of RCS, from a time when storage was not
quite so cheap.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] ftp functions not working

2004-09-02 Thread Michal Migurski
#!/usr/local/bin/php
?
if (function_exists('ftp_connect')):
  print cool\n;
else:
  print damn\n;
endif;
?
output when ran: 'Damn'
During the make I didn't see any errors.  When I ran phpinfo() 
[http://www.randomthoughtprocess.com/info.php] it shows that I have 
FTP support. Is there something that I am missing?
The version of PHP you're running on the command-line may or may not be 
the same installation as the one used by Apache. Use the following to 
see what your CLI installation does or does not have enabled:

php -r phpinfo();

michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] ftp functions not working

2004-09-02 Thread Michal Migurski
shell$php -r phpinfo(); | grep ftp
Registered PHP Streams = php, http, ftp, compress.zlib
shell$
I looked at the complete output and did not see that anything else for 
FTP. What do I need to do add FTP support for the CLI?
Just to be absolutely sure, try to use `grep -i ftp` -- the FTP in 
FTP support = enabled is in all-caps.

If it's still missing, you will need to recompile PHP. I'm not sure if 
you're on a shared host or not, but this actually does not demand root 
permissions - you can install a personal PHP binary in your home 
directory with all the required features, and use that. See the manual 
for relevant configuration details.


michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] xml tags interfere with php tags

2004-09-01 Thread Michal Migurski
How do I get an xml tag to work with a php script?
?xml version=1.0?
php is trying to parse that.
?= ''.'?xml version=1.0?'.'' ?
ugly, huh?
I'm not sure if there is a better way, but I use the above to prevent 
erroneous PHP parsing of xml declarations regardless of short_open_tags 
setting, and to keep my text editor's syntax highlighting from being 
fooled.


michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Form Spoofing - How?

2004-08-31 Thread Michal Migurski
 I've been asked to make a php script to automatically fill out and
 submit a form on a remote site. I know this is possible, but have no
 idea where to begin

SimpleTest can do this quite elegantly.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] $_SERVER['HTTP_HOST'] without the 'www.'

2004-08-31 Thread Michal Migurski
 How can I get the URL of the page I am on without the 'www.' i.e. just
 mydomain.com? I need to enurse this is correct in case the user types in
 the domain without using the 'www.'.

This should be Apache's job - you can configure the webserver to redirect
requests from example.com to www.example.com without PHP's involvement, if
that's what you're interested in.

 I have looked at using substr but if the user leaves out the 'www.' then
 substr($_SERVER['HTTP_HOST'], 4) would return 'main.com', is there a
 better function to use in this instance?

preg_match() should get you started.
/(\w+\.\w+)$/ ought to match just the primary domain.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Parsing large file

2004-08-31 Thread Michal Migurski
We have a text file that is 2.2gb in size that we are trying to parse
using PHP to put the content into a mysql database. This file contains
40 million individual lines of data.  Basically PHP isn't parsing it.
Any suggestions of how we could do this?
Process the file line-by-line instead of all-at-once, using fgets().
Check your max execution time, as William suggests.
Post a little example code or an error message.

michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Bug with mktime??

2004-08-30 Thread Michal Migurski
 gives the following output:
$i : Month: Year
0 : 08 : 2004
1 : 10 : 2004
2 : 10 : 2004
3 : 12 : 2004
4 : 12 : 2004
5 : 01 : 2005
6 : 03 : 2005
7 : 03 : 2005
8 : 05 : 2005
9 : 05 : 2005
10 : 07 : 2005
11 : 07 : 2005
Your bug is being caused by short months. If you ask mktime() to give 
you the 31st day of november, it will assume you mean the 1st of 
december. You can see more clearly what's going on if you shorten your 
code, like so:

for($i=0;$i  12;$i++) {
echo {$i}: ;
echo date(d m Y,mktime(0, 0, 0,date(m)+$i , date(d), date(Y)));
echo 'br';
}
It's a good thing you're trying this today; if you had tried it a few 
days ago, you wouldn't have had any idea that your method wasn't 
working.

--
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Dynamic Function with return?

2004-08-28 Thread Michal Migurski
 This code works.  It calls the function and receives the appropriate
 return value.
  But, is there a better way of doing this? It seems a bit round-a-bout.

Two options, details in the manual: call_user_func() or create_function().

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Keep from using cache

2004-08-27 Thread Michal Migurski
  Here's the problem...
  After a deletion, when the question list page is reloaded, the browser uses
  the cached version of the page and the question which was just deleted is
  still displayed. If you refresh the page, the question disappears. So, I
  know that the deletion is working. I just need to know how to force the
  browser to NOT use the cached version of the page.

 try these

 header(Cache-Control: private);
 header(Pragma: no-cache);

There are some bugs in IE5 which require the use of a few extra cache
headers, for good measure. For data which I don't want cached, I use this:

header('Cache-Control: no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: post-check=0, pre-check=0'); // damnable IE5
header('Expires: Wed, 16 Nov 1977 10:00:00 CET');   // date in past
header('Last-Modified: '.date('r'));// right -now-
header('Pragma: no-cache'); // HTTP/1.0

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] PHP: Undefined Variables Error Message

2004-08-27 Thread Michal Migurski
Hello all. I just finished placing a new server in production and 
PHP is not working. I am getting undefined variable messages when 
trying to submit php based forms. Register Globals is on in 
php.ini, but it still does not work. I have even tried copying a 
known-good php.ini from another server and the same behavior 
exists. I am running IIS in Windows 2000. Any ideas?

Another website dies on line 4 here:
?php
$to = [EMAIL PROTECTED];
$subject = Swinos.com Booking Contact - $name;
$headers .= MIME-Version: 1.0\r\n;
$headers .= '...';
is equivalent to
$headers = $headers . '...';
So it's probably complaining that $headers is not defined when you're 
trying to append something to it. Change that first .= to a =, like 
the line above, and see if that doesn't help.

--
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Array?

2004-08-25 Thread Michal Migurski
 I cannot seem to access elements inside of the array $things in the code
 below.  All of the errors say Undefined offset:  7 in
 /Library/WebServer/Documents/lis/check.php on line 26  I don't see
 why...

print_r is your bestest buddy.

   $results = mysql_query($q);
   if ($results) {
   while ($list=mysql_fetch_assoc($results)) {
   $things[]=$list;
   }
   }
   //$things[7] is a MySQL timestamp column named last_login

$things[7] is actually an associative array containing the seventh result
row from your query. If you check out the results of print_r($things),
you'd see the array structure immediately.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] checking for utilities/applications in the PATH

2004-08-25 Thread Michal Migurski
 i am trying to do a simple check for archiving utilities (zip, unzip,
 ...), to make sure they exist within the PATH, and are executable by
 PHP.

 i could not find a better way to do this through php, so i went ahead
 and did an

 exec('which ' . $utility, $output, $return_value);

 then, i check the $return_value for a non-zero value, which would
 indicate that the utility was not found.  using GNU/Linux this seems to
 work fine, but i wouldn't mind keeping my work cross-platform.

 so, my question is, is there a better way to do this?

If you don't want to use the shell, you can check the $_SERVER['PATH']
environment variable. On my (linux) system it looks like
sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin, so you could explode() that
on ':' and then cycle through the files in each directory using readdir(),
checking each with is_executable().

You could also just check the output of your exec() call - it should be
the full path of the executable you're looking for. An empty return would
imply that there isn't a matching executable. I think which always returns
just the first match, since it's meant to show what would get called if
you were to use that command.

Personally I love using exec() to make php behave like bash at times, but
posts on this list from pparently knowledgeable people occasionally imply
that it's not the best/fastest/most stable method to use, so I try not to.

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] post file from one server to other

2004-08-24 Thread Michal Migurski
 I have a database with binary file. I want to post that file from my
 server to another one with posting method. I have no problem to post any
 text data but I can not post binary data such as picture.jpe.

The HTTP_Client class in Pear will handle post requests:

http://pear.php.net/package/HTTP_Client
http://pear.php.net/manual/en/package.http.http-client.php

I believe it has pretty good support for sending binary data in that
request. Your other option is to build your post requests manually, using
sockets. I've done this, but it does require a lot of background knowledge
of HTTP. Luckily there's someone on this list who knows a great deal about
that. :)

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] delimiter question?

2004-08-24 Thread Michal Migurski
 How can I make the following work on an apache 2.0.46/php 4.3.2
 installation?

 /dist/gogo.php/order-inventory-form.php

 Right now, unless it is a question mark after the gogo.php script, it
 will not run.

Apache 2.0 differs from 1.3.x in its handling of path info. See:

http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Problem connecting to Postgres

2004-08-23 Thread Michal Migurski
 I am a newby having a configuration problem. I am using PHP 4.3.6 and
 postgres 7.4.3

 The problem is when I try to execute my php scripts that connect to
 postgres from the command line I get error like this:

 Fatal error: Call to undefined function:  pg_connect() in
 /Users/jcapy2/Sites/Jesper/SyncPosgresToMbrMaxData
 .php on line 28

 But it works fine from a browser using apache.

The version of PHP used by Apache may not necessarily have been configured
the same way as the one you're using on the command line. Try phpinfo() to
determine what's there, and recompile/reinstall if you're lacking PG
support. Or, try to find the command line instance that corresponds to the
apache module you're using.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Text from file into database

2004-08-23 Thread Michal Migurski
 I want to create a script that will read each line of the file and
 insert it to database. I am new to php and maybe you could help me

You've been posting here for *months*, how new could you be?

Look up the file() function. And the docs for your database.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



[PHP] PHP Runtime Debugger (Was: [PHP] how to count objects instances)

2004-08-23 Thread Michal Migurski
 There's no predefined variable or method for determining this, that I'm
 aware of, short of counting how many new Test lines you have.

 You could write a wrapper class for Test that kept count of the
 instances and returned a new object upon request...

A slightly more general question: are there any PHP development
environments that let you do something like a core dump, to see what kind
of memory usage or variable allocation you have going on? Maybe a
compilation option to PHP? A search of google turns up DBG and some
commercial packages, but I lack the experience with such tools to evaluate
them intelligently.

I've done something like what the OP is asking about, by adding a log()
feature and calling it when objects are instantiated or destroyed, but it
sure would be nice to see something like this built-in.

I'm a gdb beginner, but I'm willing to learn. I realize that this is a
fairly complex problem compounded by the fact that PHP is generally a
library used within an apache child process.

Any thoughts?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Using php_value in .htaccess files

2004-08-23 Thread Michal Migurski
 Is there anything special one has to do in order to enable the use of
 the php_value directive in the context of an apache .htaccess file?

 I notice that on some hosts I can drop in something like:

   php_value auto_prepend_file groove.php

 with impunity. Other hosts, it causes Apache to generate an internal
 server error.

I believe Apache's Allowoverride directive must have Options or
+Options set for php_value changes to be permitted on a per-directory
basis in .htaccess files.

Allowoverride All is one way to make sure they're permitted. :D

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] managing cvs from php

2004-08-19 Thread Michal Migurski
 $cmd = cd .$pathToFile. ; /usr/bin/cvs ci -m '.$logMsg.' .$file ;

 passthru($cmd) ;

 If I echo the $cmd and paste in a shell the command works.  When I
 execute from web nothing happens and no output is seen
 (error_reporting(E_ALL))

Does the apache user have read/write privileges on the files in that
directory? CVS makes heavy usage of stderr, so that may be a reason you
are not seeing output.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] arrays() current() next() who to use

2004-08-19 Thread Michal Migurski
 If you think there's a better way of doing it I would like to hear it.

 However this is resulting in an Parse error on the foreach line:

   foreach(array_slice($z['distance'], $start, 10)) {
   $newuser = $z['user'][$k];
   echo $newuser .  -  . $v . br;
}

foreach needs an as, probably that was meant to say:
foreach(array_slice($z['distance'], $start, 10) as $k = $v) { ...

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Securing Forms???

2004-08-18 Thread Michal Migurski
  $token = md5(uniqid(rand(), true));
 
  .. is a pretty bad idea, since the output could include quotes,
  newlines, low-ascii-characters, thereby messing up the form.
 How do you figure that? md5() only returns 0-9 and a-f characters.

 From the manual: http://php.net/md5
 string md5 ( string str [, bool raw_output])
 If the optional raw_output is set to TRUE, then the md5 digest is
 instead returned in raw binary format with a length of 16.

true is an argument to uniqid(), in that snippet:
string uniqid ( [string prefix [, bool more_entropy]])

You would run the risk of messing up the form with (sound of pipe organ)
*excessive entropy*.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] SSH Authentication using php

2004-08-16 Thread Michal Migurski
  Hi, what my goal is is to be able to authenticate a user by they SSH
  acount on the system using php. I tried looking on google, but didn't
  see anything with ssh. What i've tried to do is use the exec() and
  just do:
 
  exec(ssh [EMAIL PROTECTED].escapleshellard(password));
 

 You can try setting up authorized_keys for this. Then you don't need to
 pass it the password.

...but you'd still need to provide the ssh passphrase, or have an instance
of ssh-agent running. Teren, what are you trying to do exactly? Is ssh
actually necessary, or are you really just trying to authenticate users by
their unix accounts?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] SSH Authentication using php

2004-08-16 Thread Michal Migurski
 Ok, here's the whole project, I have an openbsd box using authpf which
 uses authentication via ssh login. So, i'm trying to create a weblogin
 using php so people just have to enter their username/password (which
 would be a restricted unix account) to gain access to the internet. I
 have authpf all setup, but I'd like to add a web login to make it more
 user friendly. Thanks

Ah, makes sense. Authorized_keys may be a good way to go. You may wish to
run an instance of ssh-agent as the Apache user, and create a single ssh
key for that user - importing the PID as an environment variable before
you run your exec() line ought to make it work. You may have some
difficulties keeping that ssh session open directly from PHP, though.

I wonder whether you aren't subverting your network security somewhat, by
enacting strict controls (with authpf) and then routing around them with
an insecure web login.

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



Re: [PHP] string manipulation

2004-08-12 Thread Michal Migurski
 Hi I am trying to track down a method for transferring a database id
 such as 5 into a nice formatted order id such as ORD0005 - where the
 format for the order id is ORD + 5 digits made up of the database id

See documentation for sprintf().

Try something like:

$formatted = sprintf('ORD%05d', $id);

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] how to enable utf-8 in php?

2004-07-14 Thread Michal Migurski
 PHP seems to handle all strings as ISO-8859-1 by default. How can I tell
 PHP to work with strings in UTF-8 format? This is important for sorting
 and e.g. htmlentities().

Needs to be compiled in:
http://php.net/manual/en/ref.mbstring.php

Also available:
http://php.net/manual/en/function.utf8-encode.php
http://php.net/manual/en/function.utf8-decode.php

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Session Variables ~ Best Practices

2004-07-13 Thread Michal Migurski
 I presume I am right in assuming that I can declare variables anywhere I
 like providing I have started a session on the page but I cannot
 actually use those variables until a post or some similar action has
 been performed by the user.

No, you can use them right away - they are stored server-side, so you
don't need to wait for a request/response loop before reading them:

session_start();
$_SESSION['foo'] = 'bar';
echo $_SESSION['foo']; // 'foo' is available immediately

No need to perform any special declarations. It's cookies that need to
wait for a subsequent request to be available via getcookie().

Careful with your session variable naming - you may want to implement a
primitive namespace, by using named arrays in $_SESSION, such as
$_SESSION['auth']['username'] or $_SESSION['prefs']['boxers_or_briefs'].

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Some weong when I start the apache and PHP

2004-07-13 Thread Michal Migurski
 Hello everyone!

 I just have installed the apache and PHP. When I installed apache, I ran
 the command ./apachectl start in its directory and there was an
 information showing that it has been running, but when I input
 http://localhost/; in browser I can't link to localhost.The error
 mesage is below:

 The connection was refused when attepting to contact localhost.

Check your Apache config file -- it may be set to a port other than 80
(possibly 8080) by default. Change the port and restart Apache, or just
point your browser to http://localhost:8080

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] [PHP5RC3] echo $this-db-host not work

2004-07-12 Thread Michal Migurski
 echo $this-db-host;
 // will output
 localhost

 but
 echo  $this-db-host ;
 // whill output
 Object id #2-host

 is that a bug. or just have to workout by myself?

http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Cannot send session cookie

2004-07-12 Thread Michal Migurski
 When experimenting with a few simple lines of code

  script language='php'   This is line 14
session_start();
  /script

 I get the following errors:

 Warning: session_start(): Cannot send session cookie - headers already sent by 
 (output started at e:\http\cgi\a.php:14) in e:\http\cgi\a.php on line 15

What's on lines 1-13? Does it have whitespace or indents on line 14, like
in your mail? Any use of headers, get/set cookies, or sessions must happen
before any output such as HTML or print/echo is sent to the browser.
Generally, it's a good idea to have set-up code such as session_start() be
one of the very first things you call in a script.

Wrong:
htmlhead /body?php session_start() ?/body/html

Right:
?php session_start() ?htmlhead /body //html

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] How to use multiple cookie statements

2004-07-12 Thread Michal Migurski
 I have to use cookies, since I am taking a class and it dictates that we
 use cookies, but I can't email my instructor since she never responds.
 So how do I use a cookie to record multiple values?  Help would be
 appreciative.a

A few options: use multiple cookies, e.g. setcookie('cookie_a'),
setcookie('cookie_b'), etc. Jordi's suggestion is also good, though I
would suggest using serialize() to make a single string out of your
values, like this: serialize(array('name1' = 'value', 'name2' =
'value').  Or, use PHP's built-in session support. The cookie stores a
unique ID, whie the actual values are stored on the server.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] php reserved characters...

2004-07-12 Thread Michal Migurski
  i tried to do a \p with no luck...
  any idea as to what's going on, and can someone
   point me to a list of the actual php reserved
   chars/words couldn't seem to track them down
   on the php site/google...

  is not reserved. The problem is your HTML.

 Your result ends up like this:

Either that, or short_open_tags is not enabled. Try changing the first
'?' to a '?php' and see if that doesn't help. And view source - John may
be right. :)

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] [Q] Why does my php file gets displayed instead of executed

2004-07-11 Thread Michal Migurski
 The problem is that the php script, validate_member_login.php, is
 displayed in the browser rather than being executed.

Are you running an Apache server? If so, be sure you have the appropriate
AddType lines in your configuration, as described in
http://www.php.net/manual/en/install.apache.php

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Emulating sprintf???

2004-07-08 Thread Michal Migurski
 Im trying to do something like sprintf() because I would like to have
 control over placeholders. The code I've posted works for the most part,
 but when I introduce content that has the same characters as my
 placeholders (%s and %i), it breaks to hell... Anyone got any ideas on
 how to fix, or tell me Im barking up the wrong tree...

After the first call to substr_replace, you swap in some replacement text
that contains an '%s'. Subsequent calls to substr_replace use your
replacement text as the key, because it's no longer possible to uniquely
determine what was part of the original string, and what was swapped in.

Recommendation: don't use preg_match. You can try using preg_replace with
arrays as arguments, but you may come closer to sprintf's correct behavior
if you instead consume the pattern string ($sql) character by character,
generating an output string made up of characters from the pattern string,
and elements array_shifted off of $data as you encounter placeholders.
Don't forget to add a placeholder that allows you to use '%' in that
string -- sprintf uses '%%'.

Much easier recommendation: use provided sprintf, but parse out any
unwanted placeholders first, using preg_replace.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] user tracking

2004-07-06 Thread Michal Migurski
 I am looking for some type of user tracking/stat collecting package. I
 am sure there's a million; any recommendations? We have some specific
 needs as well, so mostly likely I will be have to make some code
 changes. So the simpler package the better.

You don't mention any of the specific needs you have, but Webalizer has
worked well for me as a nice aggregate log reporting tool. It's very
flexible in terms of how it parses your logs and displays the data.

If you need too track actions of a specific user, you'll need to look
elsewhere.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Password encyption

2004-07-02 Thread Michal Migurski
 I realize the key needs to be stored somewhere which is part of the
 problem of how to make it a bit more secure.  I just don't feel safe if
 a password in a flat file in clear text.  Ideally the database should
 support something like an ssh style public/private Key auth where the
 private Key is stored internally to the database.

Where would you store the passphrase to the key? This is a losing battle -
at some point, anonymous requests from the outside world are going to have
to result in some kind of access to the database.

I think you'd be better off accepting the inherent security tradeoffs as a
known variable, and working from there: write your code so it's not
vulnerable to SQL injection or other attacks, limit the access permissions
of the database user, put the file containing the password someplace where
the webserver won't divulge its content (apache config or .htaccess is a
personal favorite of mine), and (important!) back up your DB regularly so
that you can recover from attacks cleanly.

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] calling imagemagick from php

2004-06-29 Thread Michal Migurski
 I have actually changed my code to this for debug purposes

 system('convert -geometry 200 x 200 image.JPG theThumb.gif', $retval)

 and if I cut out string between the single quotes and just run it at a
 command prompt, it works greatwhen I run this php script, I get
 syntax errorswhat is wrong?

Perhaps convert is not in your path?

Also, I'm not sure that the -geometry argument is going to behave how you
expect - typically, geometry is expressed as WxH, not W x H, in
command-line arguments to imagemagick. In the former case, you will set
the size of your output image to W width and H height. In the latter case,
I believe that the 'x H' is ignored, and you implicitly set the size of
your output image to W width and W height. Big difference for any aspect
ratio besides 1:1.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Concatenate PHP code into a string

2004-06-28 Thread Michal Migurski
 Dear List,
 How can I include a dynamically generated array:
 e.g. for($i=0; $isizeof($cols); $i++)
   { $cols[$i]= mysql_field_name($fields,$i); }

 into a MySQL insert query of the type:
-snip-

   /** {{{2
* create an INSERT or UPDATE query based on values of an associative array,
* where keys are the column names to be modified.
*
* @param   arrayvalues an associative array
* @param   string   table  the table name
* @param   string   type   the query type, currently only 'INSERT' or
*  'UPDATE'
* @return  mixed   a SQL query string on success, false otherwise (e.g., no
*  keys found matching valid column names)
*/
function array_to_query($values, $table, $type) // {{{3
{
if(!is_array($values)) return false;

foreach($values as $col = $val) {
$values[$col] = db::quote($val);
if(is_null($val)) unset($values[$col]);
}

switch($type) {

case 'INSERT':
$query = sprintf('INSERT INTO %s (%s) VALUES (%s)', $table, 
join(',', array_keys($values)), join(',', $values));
break;

case 'UPDATE':
foreach($values as $col = $val)
$values[$col] =  ${col} = ${val};

$query = UPDATE $table SET  . join(',', $values);
break;

default:
trigger_error(Unrecognized query type '$type' supplied to 
db_array_to_query(), E_USER_WARNING);
return false;

}

return $query;
}

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] a stupid question

2004-06-24 Thread Michal Migurski
 Maybe it has to be Some text.aFunction();.sometext; with the
 semicolon after the function.
 I don't really know, just guessing.

Yeesh, that's not even remotely valid PHP. Why would that have been posted
as advice?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] file locking question

2004-06-21 Thread Michal Migurski
 I have this script whereby I use the php function file().
 Just a quick question, do I need to implement file locking.

If you want to ensure that the file is not changed by other scripts while
you're reading from it, yes. Note that this is advisory only - writer
scripts will only respect the lock if they request a write lock. See
manual for details.

 if so, can I just use something like
   flock( file(/path/file.ext) );

flock() takes a file handle as an argument, not an array of strings:

$fh = fopen(/path/file.ext, 'r');
flock($fh, LOCK_SH);
// read from file here
flock($fh, LOCK_UN);
fclose($fh);

See example 1 in the manual page for flock for more info.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] mod_rewrite Issues

2004-06-19 Thread Michal Migurski
 This isn't exactly a PHP issue, but they seem to go rather hand in
 hand...

 Right now I'm just running my own apache server on my computer and I'm
 trying to protect my scripts using mod_rewrite. I uncommented all the
 mod_rewrite lines in the apache configuration file and restarted it all. I
 got no errors doing this, so I assume it compiled fine.

 The problem is, I can put a rewrite rule in the httpd.conf file or a
 .htaccess file but it never rewrites any URLs... For example:

 RewriteEngine on
 RewriteRule ^/woot$ /beta

You may need to add a RewriteCond:
http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteCond


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] index.php not loading up

2004-06-16 Thread Michal Migurski
 [Wed Jun 16 13:49:12 2004] [error] [client 158.114.144.121] File does not exist: 
 /var/www/html/, referer: http://158.114.148.90/index.php3
 [Wed Jun 16 13:49:14 2004] [error] [client 158.114.144.121] File does not exist: 
 /var/www/html/, referer: http://158.114.148.90/index.php3
 [Wed Jun 16 13:49:16 2004] [error] [client 158.114.144.121] File does not exist: 
 /var/www/html/, referer: http://158.114.148.90/index.php
 [Wed Jun 16 13:49:18 2004] [error] [client 158.114.144.121] File does not exist: 
 /var/www/html/, referer: http://158.114.148.90/index.php

 The index.php file is there, is it looking for some other file?

Yes, it appears to be looking for /var/www/html/.

Going back to your original post, this line is where your problem is:
http://158.114.148.90/? echo $sys_graphics .  alt=Keystone 2 /

I'm not even sure that's remotely valid PHP or HTML.
What's it supposed to do?

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] src=test.php

2004-06-16 Thread Michal Migurski
 I wondering how browsers handle the following html-codes:

 link rel=stylesheet src=style.php /
 and
 script type=text/javascript src=code.php/script

 are there any browser that will choke in it because the files don't have the
 appropriate (.css and .js) extension?

What matters is the appropriate Content-type header. See header().

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Re: Cookie Security?

2004-06-14 Thread Michal Migurski
  My login script sets unique, secure, cookies that identify the user.
  Some of my pages only display content if a secure cookie is present.
  Is this a bad idea for secure pages with sensitive details as I have
  heard that cookies can be faked? I am always interested in creating a
  secure environment for my website visitors and I want to make sure I
  am protecting their privacy. Any help on this matter is greatly
  appreciated.

 I would suggest tying your cookies to an IP. This makes it MUCH harder
 for a cracker to use the cookie. You may just want to search for PHP
 secure cookies on google.

As well as much harder for AOL subscribers (whose IP's change per-request)
to use the site. Cookies are easy to fake. In most cases, though, the cost
(to an intruder) of interfering with a user session far outweighs the
benefit. This is why most e-commerce sites are pretty lax about security
while you browse, and why they immediately switch to SSL when you decide
to pay.

Consider the potential damage done to your users or the sensitivity of the
information you're transmitting, and you may decide to go with SSL.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Re: Cookie Security?

2004-06-14 Thread Michal Migurski
 [snip}
  As well as much harder for AOL subscribers (whose IP's change per-request)
  to use the site.
 [snip]

 WHAT?? Are you sure of this? AOL really breaks internet browsing this
 much? Sorry, I can't believe this. If this was true, many things would
 break.

Not really -- HTTP is stateless, so there's really no reason for each
request to come from the same IP. As other posters in this thread have
pointed out, AOL uses an army of proxy servers. In the past, they've even
cached and re-compressed images for the benefit of those on slow dialup.

As you say, wacky stuff.

You're on the right track, though - the way to make cookies tougher to
crack is to associate the cookie with some other piece of user
information. I've toyed with using an encrypted string based on the user
agent as part of the cookie, but have never encountered a project where
this level of care was called-for while SSL was not.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Eliminating all lowercase words

2004-06-14 Thread Michal Migurski
 $search (([^\bA-Z][a-z]\b*?)*?));
 $replace = ;
 $add = preg_replace($search, $replace, $add);

 hWhen I tried it, it eliminated all lowercase words, and in the case of the
 single upper case word, 'Bellingham', it retained only the capital 'B' --
 arrgh!

You could just look for lowercase words, instead of not-uppercase words,
like so:
/\b[a-z]\w+\b/

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Expedia.com

2004-06-09 Thread Michal Migurski
 When Expedia.com is searching for flights, it displays a page with a
 little animated GIF progress bar, then display the results.

 How do they do that? How does the page sit idle until the query is
 finished, and then sends a new page with the results? I was thinking
 that they might use HTTP-REFRESH or something, and just keep hitting the
 database until the result is there. But is there a best way to do
 this? In my application, when the user clicks a certain button, it will
 take 10-20 seconds for the operation to completeduring that time I need
 the web browser to waiit for the data.

The progress bar goes by too quickly for me to tell, but perhaps they are
using a slow-loading resource someplace on the page? E.g., an image whose
content-length is 64, whose 64th byte does not get sent by the server
until the query is complete. Combine that with a bit of javascript waiting
for the image to load, and you should have basic loading-bar behavior.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Can someone explain this?

2004-06-08 Thread Michal Migurski
 Forgive me if my math is askew, but doesn't the negative imply the
 number is signed? If I remember from my C++ days, a declaration of:

 unsigned int blah;

 Meant you could not store negative numbers in that variable. Hence,
 negatives would be signed. No?

Yes, but once it become a hex string (after dechex()), all that info is
gone. I think the way to handle this situation is to use pack  unpack.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] include and require

2004-05-27 Thread Michal Migurski
 Can anyone help me with this one:
 Is there a difference between  include() and  require()   ?

http://php.net/require
http://php.net/include

require() and include() are identical in every way except how they
handle failure. include() produces a Warning while require()
results in a Fatal Error. In other words, don't hesitate to use
require() if you want a missing file to halt processing of the
page. include() does not behave this way, the script will continue
regardless. Be sure to have an appropriate include_path setting as
well.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



[PHP] PHP segfaults, any ideas?

2004-05-26 Thread Michal Migurski
Hi -

I'm having some PHP segfault issues, and I can't seem to figure out what's
wrong. Kinda frustrating :) The script i'm using to test is really simple,
and as I tweak it to figure out the failure point, I'm finding that it
/seems/ to break more reliably based on the presence of code **after** a
call to exit. This seems counterintuitive to me.

Being a novice to gdb, I was hoping someone might help me to understand
this backtrace?

#0  0x4010d76e in chunk_free () from /lib/libc.so.6
#1  0x4010d548 in free () from /lib/libc.so.6
#2  0x4033cb87 in shutdown_memory_manager (silent=1, clean_cache=0) at 
/usr/local/src/build/php-4.3.2/Zend/zend_alloc.c:532
#3  0x403236cc in php_request_shutdown (dummy=0x0) at 
/usr/local/src/build/php-4.3.2/main/main.c:992
#4  0x40365001 in apache_php_module_main (r=0x8103a84, display_source_mode=0) 
at /usr/local/src/build/php-4.3.2/sapi/apache/sapi_apache.c:60
#5  0x40365b7e in send_php (r=0x8103a84, display_source_mode=0, filename=0x0) 
at /usr/local/src/build/php-4.3.2/sapi/apache/mod_php4.c:617
#6  0x40365bd2 in send_parsed_php (r=0x8103a84) at 
/usr/local/src/build/php-4.3.2/sapi/apache/mod_php4.c:632
#7  0x08053c73 in ap_invoke_handler ()
#8  0x08068bf7 in process_request_internal ()
#9  0x08068c58 in ap_process_request ()
#10 0x0805fa95 in child_main ()
#11 0x0805fc40 in make_child ()
#12 0x0805fdb4 in startup_children ()
#13 0x0806042c in standalone_main ()
#14 0x08060c8f in main ()
#15 0x400b01c4 in __libc_start_main () from /lib/libc.so.6

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] interesting

2004-05-25 Thread Michal Migurski
 What does the { } around the array mean?

http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Re: best way to do this with arrays...

2004-05-24 Thread Michal Migurski
 $start = '2004-07-04';
 $end = '2004-07-09';
 $check = '2004-07-06'; // the date you want to check

 $timestampStart =
 mktime(0,0,0,substr($start,5,2),substr($start,8,2),substr($start,0,4));
 $timestampEnd =
 mktime(0,0,0,substr($end,5,2),substr($end,8,2),substr($end,0,4));
 $timestampCheck =
 mktime(0,0,0,substr($check,5,2),substr($check,8,2),substr($check,0,4));

FYI, the above can be shortened to:
$timestampStart = strtotime($start);
$timestampEnd = strtotime($end);
$timestampCheck = strtotime($check);

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Quick encoding question:

2004-05-24 Thread Michal Migurski
 I have a form and the people who submit are likely to include a bunch of
 ¶ characters. (That's a paragraph symbol in case it doesn't come
 through the list correctly.)

 However when I read it out of MySQL it comes back as ¶. What can I do
 about this? Thanks!

Looks like UTF-8. Make sure your output character encoding matches the
database encoding, and use htmlentities() and the mb_* (multibyte string)
functions where necessary.

Debugging this stuff is a pain. :P

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] Re: best way to do this with arrays...

2004-05-24 Thread Michal Migurski
 the tricky part is I could have fifteen rows in the db all with
 different start and end dates that I need to check each day against.

Then do the data comparison in the DB --

SELECT * FROM your_table
WHERE {$check_time} = start_time
AND {$check_time} = end_time;

(Adjust as appropriate for date formatting, SQL injection, etc.)
If you're using MySQL, this page is informative:
http://dev.mysql.com/doc/mysql/en/Date_and_time_types.html

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Using php to modify a css file

2004-05-22 Thread Michal Migurski
 Then I added the following line to my .htaccess file AddType
 application/x-httpd-php .css It works just fine at my hosting company
 but I can't get it to work locally.

Try fetching it with cUrl, or using Mozilla's view-headers feature. Make
sure that the PHP is in fact being parsed, and that the Content-Type
header is correct.

You'd be better off not messing with AddType at all to parse .css files
- it's more important that the content-type be text/css.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Using php to modify a css file

2004-05-22 Thread Michal Migurski
 The reason for the two files is that My4CSS.css contains code that
 doesn't break Netscape 4 (people are still using that garbage) and
 MyCSS.css is the code that I want for decent browsers.  Just doing the
 AddType without changing the css files at all breaks things locally.
 Without a ?php in the file I think that whether it's parsed by php or
 not shouldn't make any difference -- but it does.

It will only make a difference if the HTTP response from the server is
different somehow -- contains junk, wrong headers, that sort of thing. The
only way to reliably diagnose such problems is to figure out a way to view
the entire HTTP response, headers and all. I use curl for this, but you
might not have access to a command line. The mozilla view-headers thing I
mentioned - I've never actually used it {{embarrassed shrug}} so I can't
help you find it, but there are many ways of achieving the same end.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] XML problem

2004-05-18 Thread Michal Migurski
 I'm looking for a good tutorial in xml or a list with most of the xml
 tags. I've googled for it but i can't find anything. Could someone send
 me a link to that kind of tutorial?

There are no xml tags as such; XML defines a grammar but not a
vocabulary. The actual tags used depend on the specific application in
question, e.g. XHTML defines one set of tags, SOAP another. You can define
your own, if you want. A lot of parsers, like the xml_parse functions in
PHP, can handle arbitrary XML input as long as it's well-formed, that
is, follows the syntax rules properly.

Most of the syntax is described here:
http://www.w3schools.com/xml/xml_syntax.asp

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] HTTP_RAW_POST_DATA

2004-05-12 Thread Michal Migurski
   Check the value of always_populate_raw_post_data in php.ini on
  both servers.
 
  Thats such a funny name.

 Not to mention misleading, since it doesn't always populate
 $HTTP_RAW_POST_DATA when enabled. Always should mean always.

Anyone have any clue why this is the case? Is there a performance reason
that raw post data must be explicitly enabled, or is it more of a
protective measure for overly permissive beginner scripts?

Inquiring minds demand answers!

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] default and another constructor

2004-05-12 Thread Michal Migurski
 No, you cannot do this kind of method overloading, not like this anyway.
 If you are using PHP5 you can kind of emulate overloading by using the
 __call() function... some googling will find examples.

 You can at least make the below work by removing the first forum()
 instance and using

  function forum($naam=NULL,$tijd=NULL,$tekst=NULL)

Another option, if you wish to have varying argument lists, is to define
the methods with no arguments at all, and use the func_get_args(),
func_num_args(), and func_get_arg() functions described here:

http://php.net/manual/en/ref.funchand.php

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] HTTP_RAW_POST_DATA

2004-05-12 Thread Michal Migurski
  Anyone have any clue why this is the case? Is there a performance
  reason that raw post data must be explicitly enabled, or is it more of
  a protective measure for overly permissive beginner scripts?

 If it was always enabled, it sure would make a DoS attack easy. I'd just
 send lots of huge POST requests to any PHP script on your server. Hope
 you have migs and megs of memories, as Strong Bad would say. :-)

Isn't this potentially a DoS attack vector anyway? I don't need a server
to accept or read my obscenely long POST requests to clog the pipes with
them. Would the proper way to handle this risk be to disallow POST at the
webserver level, or does turning always_populate_raw_post_data off cause
the connection to be automatically dropped after Connection: close?

-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] HTTP_RAW_POST_DATA

2004-05-12 Thread Michal Migurski
  Isn't this potentially a DoS attack vector anyway? I don't need a server
  to accept or read my obscenely long POST requests to clog the pipes with
  them. Would the proper way to handle this risk be to disallow POST at the
  webserver level, or does turning always_populate_raw_post_data off cause
  the connection to be automatically dropped after Connection: close?

 By default php streams the STDIN to a file so your just dealing with
 buffer sized ~2K-4K.  enabling this option makes php put the contents
 into memory, thus leaving open the possiblity of someone using up all
 your memory and bringing the machine to a standstill till, then when
 swap space runs out.. watch out! :)

This makes sense, thanks.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Print a variable's name

2004-05-05 Thread Michal Migurski
 but what I want is to be able to pass any variable to a procedure and
 have the variable name and value printed by the procedure.

Because PHP passes arguments by value, you will be out of luck in most
cases -- by the time your debugging function sees the argument, it's no
longer tied to the calling scope. Michael Sims' example function works
only for variables in the global scope, which probably won't work for
anything complex enough to need its own debugging library.


 I'm trying to extend my library of debugging functions/procedures by
 having a procedure which can be used to inspect a variable whenever I
 call it.

You may find what you need in debug_backtrace(). Alternatively, just pass
the variable name along:
function echo_var($varname, $varvalue) {
printf(%s: %s\n, $varname, $varvalue);
}

...Which isn't much of an improvement over a plain old echo/print. And if
that's good enough for Brian Kernighan, I'd hope it's good enough for you.

:D

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



[PHP] Sorting text with multibyte characters

2004-05-01 Thread Michal Migurski
Hi,

Does anyone have any thoughts on how to effectively sort text with
multi byte characters? I am working on a project that uses lots of German
text, and the letters with umlauts don't sort correctly. I'm using the
mb_* functions in a few places (to adapt an ASCII-encoded database to XML
output for flash, which is always expected to be in UTF-8), but none of
them seems to be made for string comparison.

thanks,
-mike.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 This isn't always desirable, or even possible.  I once designed a
 database to hold characteristics for a series of 70 different tests.
 There were about 50 different characteristics used in various
 combinations for each test.  Each characteristic could be one of many
 values.  So the characteristics tables all looked like this:

id, name, value

 And the test tables looked like this:

id, name, value

In my experience, it's usually a safe assumption that if you have a bunch
of tables all structured identically and used in similar ways, you should
probably merge them all into a single table with an extra column that
corresponds to whatever differentiating characteristic used to distinguish
your original tables.

I.e., go with John Holmes' suggestion before you're really up the creek.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Re: Sorting text with multibyte characters

2004-05-01 Thread Michal Migurski
 Run into this before, PHP seams to do quite well when you set the locale
 right ( de_DE ) which will place AÄBCD instead of ABCDÄÖÜ.

 Hope this helps :-)

Thanks, I hadn't thought of that.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Select from 24 tables

2004-05-01 Thread Michal Migurski
 Up what creek?  You didn't really provide any technical justification
 for your suggestion.

Up the creek of having to call for help on php-general because you have 24
identical tables you need to join, having never performed a join before.

 The pain only occurs when writing the SQL statements to join the
 tables.  I don't think it's a good idea to optimize the database schema
 for the sake of the programmer, who only has to write the SQL one time.

I wholeheartedly disagree. :) I think that optimizing for the sake of the
programmer, the bug fixer, and the possible inheritor of the project is a
/great/ idea. Servers keep getting faster, while the human attention span
and rate of familiarization with code stays approximately constant, so
optimizing your development time is at least as sensible as optimizing SQL
select performance, which is probably better handled through well-chosen
indexes anyway.

Optimizing for the programmer usually translates into thinking about the
humans who will need to interpret your code, and making it easy to pick up
the gist of your intent. A 24-table join is not a typical characteristic
of what I'd consider a well-planned DB schema, whose meaning can be
quickly grokked by a newcomer to the project.

If all those 24 tables store the same kind of data, then there's no reason
to split them up. Of course, we haven't seen the specific usage of those
tables in this thread, but I'm basing my posts on the assumption that it's
better for the OP to have a marbles table with a color  column, than
tables named red_marbles, blue_marbles, 'green_marbles,  etc. If
that's not the kind of data we're talking about, then I stand corrected,
and John Nichel's initial response is all that's needed.

A huge table count is often evidence of a need for some refactoring.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] MySQL Dump

2004-04-24 Thread Michal Migurski
 I just tested it and yes, the Michal function runs on Windows and Linux.
 Just must write the path in the proper format for the OS you're using.

Holy smokes, that's good news. :)  Spreading dis-information is my price
for not having the first clue about windows.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] MySQL Dump

2004-04-23 Thread Michal Migurski
 Will this work on both a Windows and Unix server?

No, it's most assuredly a unix-only thing.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] PHP vs PERL? (Seriously OT Now....)

2004-04-22 Thread Michal Migurski
 Uh-oh, does that mean an Atheist has to use ASP??? ;)
 [/snip]

 And if so, what must a Buddhist use?

Lisp, of course.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] regular expressions php/perl/actionscript

2004-04-22 Thread Michal Migurski
  I'm wondering if Regular Expressions are the same in Perl and PHP (and
  possibly Actionscript)? They look the same and smell the same, but if
  I see a book in a store for Perl Regular Expressions that's $10
  cheaper than the PHP one (is there one?), then is it the same thing?

 this page will tell you what php supports:

 http://us3.php.net/ereg

Alternatively, try this:
http://www.php.net/manual/en/ref.pcre.php

PCRE == Perl-compatible Regular Expressions.

The ereg functions use a slightly different syntax.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] MySQL Dump

2004-04-22 Thread Michal Migurski
 Is there an easy way to do a mysql dump routine written in php?  I
 basically want to write a function to backup a database and have it
 create all the neccessary structures and data in the dump.  I know
 phpMyAdmin will do this for me, but I want to write a function to do
 this incase the server doesn't have phpMyAdmin installed.  Any ideas?

Why not use the existing mysqldump command-line utility?

function mysql_dump($db, $user, $pass)
{
return shell_exec(/path/to/mysqldump
--user={$user} --password={$pass}
--complete-insert --add-drop-table
{$db});
}

Or, skip PHP entirely and place a call to mysqldump with a suitable
select-privilege-only username  password in a cron job, if you're on a
unix machine. I use the following shellscript to do periodic backups to
RCS repositories in /usr/local/var/backups:

#!/bin/sh

if [ $# -ne 3 ]; then
echo 'Usage:';
echo '  mysql-backup.sh db-user db-password db-name';
exit;
fi;

USER=$1;
PASS=$2;
DB=$3;
MYSQLDUMP=/usr/local/bin/mysqldump;

BACKUP_DIR=/usr/local/var/backups;
SQL_FILE=$DB.mysql;
RCS_FILE=$SQL_FILE,v;

cd $BACKUP_DIR;
$MYSQLDUMP --user=$USER --password=$PASS --complete-insert --add-drop-table $DB  
$SQL_FILE;

 the remaining lines can be ommitted if RCS isn't needed 

if [ ! -f $RCS_FILE ]; then
echo import | rcs -q -i $SQL_FILE;
else
rcs -q -l $RCS_FILE;
fi;

echo mysql_backup.sh | ci -q $SQL_FILE;

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Making an app unviewable during system maintainance

2004-04-21 Thread Michal Migurski
  Good point, though if this is a concern, the OP will probably use the
  built-in enforcement of referential integrity and transaction support
  of whatever database they are running.

 If a single database is spread over files A, B, and C, then in the time
 it took for a naive backup to grab file A, files B and C may have
 changed such that the database cannot be restored to an
 internally-consistent state using files A, B, and C.  At this point,
 enforcement of referential integrity would actually work against you.

Right, but if the database's built-in backup tool is used rather than the
filesystem, it ought to respect the read/write locks that are a natural
by-product of using begin/commit to wrap your transactions. E.g., a call
to pg_dump should be guaranteed to pull the database in an
internally-consistent state, if the application logic uses transactions
correctly. I guess that's probably what you meant by Use the DB to make
the snapshot, then back up the snapshot. :)

(I say ought and should because I'm no DB guru, myself)

This popped up on /. yesterday, and it seems relevant:
http://www.oreillynet.com/pub/wlg/4715

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Forking external binaries

2004-04-20 Thread Michal Migurski
 We have a web application that forks off an external program to inject
 an email in the outgoing queue. At busy periods this external program
 (qmail-inject) can take a little while to return. I'm currently using
 popen() to spawn the qmail-inject binary.

 Is there a way to spawn the external binary but not wait for it to
 return. I'd be happy to ignore any return value if the tradeoff was a
 fast return.

If you call it via exec(), you can append an ampersan to detach the
controlling terminal:

exec(/path/to/qmail-inject -args );

Wish php had fork() in a non-experimental context. :\

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Making an app unviewable during system maintainance

2004-04-20 Thread Michal Migurski
 Hi there I was wondering how people usually turn the app off during
 system maintainance. During the hours of 6-7 the database goes down for
 backing up, the users therefore keeping trying to get into the system, i
 get an error that the database is down when i know it should be down
 near that time. Without causing too many if statements what is the best
 way to do this ?

Don't take the database down for backups.

I can think of no logical reason why you'd want to kill the DB to back it
up, since it's just a big read operation.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] Making an app unviewable during system maintainance

2004-04-20 Thread Michal Migurski
  Don't take the database down for backups.
 
  I can think of no logical reason why you'd want to kill the DB to back
  it up, since it's just a big read operation.

 Referential integrity might be a reason.

Good point, though if this is a concern, the OP will probably use the
built-in enforcement of referential integrity and transaction support of
whatever database they are running.

*cough* postgresql ;)

 However, I agree -- don't back up the database directly -- use whatever
 utilities the database provides to dump the database, then back up the
 dump.  Depending on how well the dump utility works, you might be able
 to do away with the downtime.

mysql has mysqldump, and postgresql has pg_dump. Both of these are pretty
much all you'd need, and neither requires any site downtime.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



RE: [PHP] Re: oo question

2004-04-19 Thread Michal Migurski
  One personal suggestion: you could directly put the code from
  initialize_customer() into the constructor.

 but i'm thinking that i might, at some point, want to use that method
 after the object has been instantiated. i can't think of a specific
 case, but i'm only imagining that it's possible.

It could be useful when retrieving real data is expensive.

I've been recently working with a data set that is derived from a
highly-relational database served over HTTP via XML. It's time consuming
to pull new information about a record and not all information is used
everywhere, so I've been using a structure similar to yours with a
lazy-load component -- the data source isn't actually accessed for a
particular piece of information until that piece of information is
specifically requested.

In the example below, properties one and two might refer to linked or
nested objects, each with a high cost of retrieval. The database access
code that is now in your initialize_customer() method gets split up into
logical chunks, and placed in the property_*() methods.

Paraphrased/contrived example:

class thing
{
var $id;
var $property_one;
var $property_two;

function thing($id)
{
$this-id = $id;
}

function get_property_one()
{
if(!$this-property_one) {
// perform request for property one,
// set $this-property_one
}
return $this-property_one;
}

function get_property_two()
{
if(!$this-property_two) {
// perform request for property two,
// set $this-property_two
}
return $this-property_two;
}
}


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



Re: [PHP] PHP and HTTP requests

2004-04-19 Thread Michal Migurski
 I realize it's a stupid question but I need a simple solution.. I'd like
 to get contence from script-generated webpage (I send a regquest via get
 or post method to a page and it generates a response page - how do get
 that page as a string? Get the source of the page). It's obvious that it
 cannot be shown with file functions. Only solution I was mentioned vas
 CURL package but I'd like to solve this with standard functions. Is it
 possible?

fopen() can support streams, if your configuration allows it:
http://php.net/manual/en/function.fopen.php

Alternatively, you can use the socket functions to hand-roll an HTTP
request, in the event that you need stricter control over POST contents or
specific headers.
http://php.net/manual/en/ref.sockets.php

Or, if you're on a unix system, and curl's available as an executable, and
you consider exec to be a standard function, there's always this:
$response = shell_exec(curl http://www.example.com;);

I always use last method that in preference to the curl functions.
I find them incredibly overengineered. :)

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

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



  1   2   >