php-general Digest 17 Dec 2007 08:13:48 -0000 Issue 5185

2007-12-17 Thread php-general-digest-help

php-general Digest 17 Dec 2007 08:13:48 - Issue 5185

Topics (messages 265952 through 265964):

Re: PRG pattern - how to implement a load page using GET
265952 by: Jochem Maas
265954 by: Robert Erbaron

Fatal error: Class 'DOMDocument' not found
265953 by: Jeff Schwartz
265956 by: Jochem Maas

Re: how to handle inserting special characters into a mysql field
265955 by: Robert Erbaron

Writing text into images, and setting text size
265957 by: Dave M G
265960 by: Casey

BBcode
265958 by: Ronald Wiplinger

Re: BBcode - Solved
265959 by: Ronald Wiplinger

how can i use timeout in php's socket?
265961 by: ½Ðǹâ

Securing your Sites
265962 by: Wolf

How to new a Object via class name String?
265963 by: ked
265964 by: Robert Cummings

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Robert Erbaron wrote:
 I've been reading up on login mechanisms using redirects, and have a
 basic mechanism down.
 
 a1.php:
 ?php
 $site_title='My Site';
 if (isset($_SESSION['errmsg_s']))
   {$errmsg = 'Warning! '.$_SESSION['errmsg_s'].'!';}
 else
   {$errmsg = ''; }
 if (isset($_SESSION['email_s']))
   { unset($_SESSION['email_s']);}
 echo 'h1Welcome to '.$site_title.'/h1br';
 echo $errmsg;
 ?
 !-- form goes here and calls a2.php --
 
 a2.php:
 ?php
 $email = $_POST['email'];
 if // (test email for goodness against database) {
  $_SESSION['email_s'] = $email;
  unset($_SESSION['errmsg_s']);
  // stuff successful login into database
  session_write_close();
  header('Location: a3.php');
  exit;}
 else {
  $_SESSION['errmsg_s']=Re-enter your email;
  unset($_SESSION['email_s']);
  session_write_close();
  header('Location: a1.php');
  exit;}
 ?
 
 a3.php:
 ?php
 if (empty($_SESSION['email_s'])) {
 session_write_close();
 header('Location: a1.php');
 exit;}
 $email = $_SESSION['email_s'];
 echo 'Hello there,'.$email.'. We are glad to have you here.br';
 ?
 
 OK, looks like this handles refresh (resubmit) and back button issues.
 Hitting back when on page 3 empties 'email', so resubmitting does a
 brand new login. (If I'm missing something, holler.)
 
 However, the seminal article at
 http://www.theserverside.com/tt/articles/article.tss?l=RedirectAfterPost
 says:
 - Never show pages in response to POST
 - Navigate from POST to GET using REDIRECT
 - Always load pages using GET
 
 I get the first and the second, and understand how to implement them.
 The third, though. Sorry, I'm missing something. I simply don't
 understand what they mean or how to do it. Can someone translate my
 little a3.php page into 'using GET' instead of just grabbing the
 session var again? And why is that necessary?

a standard HTTP request is a GET request.

using firefox and one of a number of extensions (firebug springs to mind)
you can actually view the request headers that are sent.

 
 (P.S. I'll get to the issue of rearchitecting this via require instead
 of using header() redirects,cough, cough, Richard Lynch, cough, cough
 :) in a future message. One step at a time...)

yes - abusing redirects as described is wasteful. and certainly it's the
first time I've ever heard the statement 'Never show pages in response to POST'
sounds like hubris too me.
---End Message---
---BeginMessage---
 a standard HTTP request is a GET request.

I guess I'm just missing some basic definition of terminology. Been
writing desktop systems for too long, 'spose.

 using firefox and one of a number of extensions (firebug springs to mind)
 you can actually view the request headers that are sent.

Firebug shows headers for the c3.php page are:

Response Headers:
DateSun, 16 Dec 2007 20:48:43 GMT
Server  Apache/2.2.6 (Fedora)
X-Powered-ByPHP/5.1.6
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Content-Length  51
Connection  close
Content-Typetext/html; charset=UTF-8

Request Headers:
Hostlocalhost
User-Agent  Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6)
Gecko/20070812 Remi/2.0.0.6-1.fc6.remi Firefox/2.0.0.6
Accept  
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
Referer http://localhost/hf/c1.php
Cookie  PHPSESSID=spave8i7jc7m0cmmvcdaj3msh7

 
  (P.S. I'll get to the issue of rearchitecting this via require instead
  of using header() redirects,cough, cough, Richard Lynch, cough, cough
  :) in a future message. One step at a time...)

 yes - abusing redirects as described is wasteful. and certainly it's the
 

Re: [PHP] How to new a Object via class name String?

2007-12-17 Thread Robert Cummings
On Mon, 2007-12-17 at 15:50 +0800, ked wrote:
 Hi  , I'm a  freshman in PHP, can anyone give me any  advices?
 
 I defied some simple classes, like User, Item...
 
 in a general way ,
  $obj = new User(); 
 
 specially, I need  to assign a Object via a class name .
 
 Now , my code :
  switch ($className)
 {
  case User:
 return new User();
 break ;
  case Item:
 return new Item();
 break ;
  default:
 break ;
 }
 
 I think that It's not a clever  job. How to do it skillfully?
 
 Thank you for any advice.

?php

class User
{
}
 
class Item
{
}
 
 
function getObject( $name )
{
$obj = false;

if( class_exists( $name ) )
{
$obj = new $name();
}
 
return $obj;
}
 
var_dump( getObject( 'User' ) ); echo\n\n;
var_dump( getObject( 'Item' ) ); echo\n\n;
var_dump( getObject( 'Foo' ) );  echo\n\n;

?

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



答复: [PHP] how can i use timeout in php 's socket?

2007-12-17 Thread 陆星光
Who can help me? Thank you!

-邮件原件-
发件人: 陆星光 [mailto:[EMAIL PROTECTED] 
发送时间: 2007年12月17日 15:11
收件人: php-general@lists.php.net
主题: [PHP] how can i use timeout in php's socket?

how can i use timeout in php's socket? And if php support multicast? thanks

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



Re: [PHP] how can i use timeout in php's socket?

2007-12-17 Thread Brice
On Dec 17, 2007 8:10 AM, 陆星光 [EMAIL PROTECTED] wrote:
 how can i use timeout in php's socket?

You can put an option with socket_set_option :
http://php.net/manual/en/function.socket-set-option.php

Availables options are listed here :
http://php.net/manual/en/function.socket-get-option.php


Brice Favre
http://www.copix.org/



Re: [PHP] PRG pattern - how to implement a load page using GET

2007-12-17 Thread Per Jessen
Robert Erbaron wrote:

 yes - abusing redirects as described is wasteful. and certainly it's
 the first time I've ever heard the statement 'Never show pages in
 response to POST' sounds like hubris too me.
 
 I've seen the statement in a number of messages in the archives here
 and in google searches. 

Personally, I try to avoid the situation where you might get a
double-POST if the user decides to do a reload/refresh.  Which means
processing the POST-request, but finish it off with a 303 redirect. 


/Per Jessen, Zürich

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



Re: [PHP] PRG pattern - how to implement a load page using GET

2007-12-17 Thread Jochem Maas
Per Jessen schreef:
 Robert Erbaron wrote:
 
 yes - abusing redirects as described is wasteful. and certainly it's
 the first time I've ever heard the statement 'Never show pages in
 response to POST' sounds like hubris too me.
 I've seen the statement in a number of messages in the archives here
 and in google searches. 
 
 Personally, I try to avoid the situation where you might get a
 double-POST if the user decides to do a reload/refresh.  Which means
 processing the POST-request, but finish it off with a 303 redirect. 
 

this can still be 'broken' by using the back button ... I find a safer way
(if the application design allows it) is to include a one-time token with
each POST request - if a token has already been used (or is invalid) the POST
processing is not done.

 
 /Per Jessen, Zürich
 

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



答复: [PHP] how can i use timeout in php 's socket?

2007-12-17 Thread 陆星光
Thank you! But these have not multicast!

-邮件原件-
发件人: Brice [mailto:[EMAIL PROTECTED] 
发送时间: 2007年12月17日 17:28
收件人: 陆星光
抄送: php-general@lists.php.net
主题: Re: [PHP] how can i use timeout in php's socket?

On Dec 17, 2007 8:10 AM, 陆星光 [EMAIL PROTECTED] wrote:
 how can i use timeout in php's socket?

You can put an option with socket_set_option :
http://php.net/manual/en/function.socket-set-option.php

Availables options are listed here :
http://php.net/manual/en/function.socket-get-option.php


Brice Favre
http://www.copix.org/


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



Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Dave M G

Casey,

Thank you for replying.


Try imagettftext().


I did, as explained:


$font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
$imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);


So my questions remain:


1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
directory. But specifying it doesn't seem to work. How do I get the
system to find the font?

2. I need the scripts I'm writing to be portable, so can I be sure of
what fonts will be available, and will I be able to locate them?

3. I'm not really concerned about what font it is, just that it's large
and readable. If there are other options than what I've explored here,
then I would be open to those too.


Thank you for any advice.

--
Dave M G

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



[PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread Jochem Maas
hi guys ( girls),

any Mac heads about? I have a MacBook Pro in front of me ... super cool,
it even comes with apache  php installed as standard. nice.

only thing is php is not compiled with with all the extensions I need, the
question is what is the *correct* way to update/recompile the standard installed
copy of php on a Mac? I quite comfortable with compiling/installing [mulitple]
custom apache+php installs on a linux server but I'd like to keep this Mac as
clean as possible if I can.

If any one has recommendations I love to here from you :-)
in the mean time I'll keep hunting

rgds,
Jochem

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



[PHP] php sockets

2007-12-17 Thread vixle
?php

/* Get the port for the WWW service. */
//$service_port = getservbyname('www', 'tcp');

/* Get the IP address for the target host. */
//$address = gethostbyname('www.example.com');

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
//echo Attempting to connect to '$address' on port '$service_port'...;
$result = socket_connect($socket, 127.0.0.1, 27015);

socket_RECV($socket, $read, 300, null);
   echo $read;
socket_close($socket);
?

i have a daemon running on that port that sends a message when it's  got a 
client connected
but the script above doesn't output anything it just loads my cpu up to 100 
percent and thats it then it basically stops working. While i need it to 
display the messages sent by server(daemon) to the user running the script 
has anyone got any idea why it rejects to work? (yeah the daemon is written 
in c++ if that matters) 

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



Re: [PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread Frank Arensmeier

hi guys ( girls),

any Mac heads about? I have a MacBook Pro in front of me ... super  
cool,

it even comes with apache  php installed as standard. nice.

only thing is php is not compiled with with all the extensions I  
need, the
question is what is the *correct* way to update/recompile the  
standard installed
copy of php on a Mac? I quite comfortable with compiling/installing  
[mulitple]
custom apache+php installs on a linux server but I'd like to keep  
this Mac as

clean as possible if I can.

If any one has recommendations I love to here from you :-)
in the mean time I'll keep hunting

rgds,
Jochem

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


Why not do it the Mac-way?
http://www.entropy.ch/software/macosx/php/

Download the latest package and make a custom install. I think there  
are 40/50 PHP extensions included. Just pick what you want.


//frank

ps. merry christmas ds.

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



Re: [PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread Jochem Maas
Frank Arensmeier schreef:
 hi guys ( girls),

 any Mac heads about? I have a MacBook Pro in front of me ... super cool,
 it even comes with apache  php installed as standard. nice.

 only thing is php is not compiled with with all the extensions I need,
 the
 question is what is the *correct* way to update/recompile the standard
 installed
 copy of php on a Mac? I quite comfortable with compiling/installing
 [mulitple]
 custom apache+php installs on a linux server but I'd like to keep this
 Mac as
 clean as possible if I can.

 If any one has recommendations I love to here from you :-)
 in the mean time I'll keep hunting

 rgds,
 Jochem

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

 Why not do it the Mac-way?

I've had this Mac for about 5 minutes - it's my first one ... I'm not yet
upto speed on the Mac-way :-) ... heck I've even figured out what the key
above the TAB key is (I was used to having a backtick/tilde there and it took
me longer than I care to admit to figure out that key lies next to the SHIFT 
key.

 http://www.entropy.ch/software/macosx/php/
 
 Download the latest package and make a custom install. 

ok let's assume I know exactly what a 'custom install' is in MacWorld (I don't 
;-))
and let's assume I install this 'custom install' what happens to the standard 
php
install - I'd rahter not have 2 php builds installed to start with (especially 
if
it's because my lack of knowledge means I don't know how to 'correctly' remove 
the
original, standard installation.

anyway thanks for the hint so far ... Im off to investigate.

 I think there are
 40/50 PHP extensions included. Just pick what you want.

I'll have the blond ;-)

 
 //frank
 
 ps. merry christmas ds.
 

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



RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Monday, December 17, 2007 6:47 AM
 To: Casey
 Cc: PHP List
 Subject: Re: [PHP] Writing text into images, and setting text size
 
 Casey,
 
 Thank you for replying.
 
  Try imagettftext().
 
 I did, as explained:
 
  $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
  $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);
 
 So my questions remain:
 
  1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
  directory. But specifying it doesn't seem to work. How do I get the
  system to find the font?

I wouldn't. First, I don't know of any standard fonts for linux, though there 
might be (As you have Arial or Times New Roman for windows). Second, It might 
be a safe_mode / open_base_dir issue, or a problem in GD or the freetype 
libraries if the path is right and the font exist.
I would try something like dirname(__FILE__).'/fonts/Arial.ttf'... of course 
that would mean you need to create a fonts directory and copy Arial.ttf from 
your system to that location (violating the copywrite? ;) )... anyway, you can 
check that with any other font.

 
  2. I need the scripts I'm writing to be portable, so can I be sure
 of
  what fonts will be available, and will I be able to locate them?
 

Deploy the fonts along with your scripts... that's the only way I know.

  3. I'm not really concerned about what font it is, just that it's
 large
  and readable. If there are other options than what I've explored
 here,
  then I would be open to those too.

You can get some free fonts, and deploy them along with every project. I do so 
for a custom CAPTCHA script I've made.

 
 Thank you for any advice.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | 
TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |  
Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

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



Re: [PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread Frank Arensmeier

17 dec 2007 kl. 12.03 skrev Jochem Maas:


Frank Arensmeier schreef:

hi guys ( girls),

any Mac heads about? I have a MacBook Pro in front of me ...  
super cool,

it even comes with apache  php installed as standard. nice.

only thing is php is not compiled with with all the extensions I  
need,

the
question is what is the *correct* way to update/recompile the  
standard

installed
copy of php on a Mac? I quite comfortable with compiling/installing
[mulitple]
custom apache+php installs on a linux server but I'd like to keep  
this

Mac as
clean as possible if I can.

If any one has recommendations I love to here from you :-)
in the mean time I'll keep hunting

rgds,
Jochem

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


Why not do it the Mac-way?


I've had this Mac for about 5 minutes - it's my first one ... I'm  
not yet
upto speed on the Mac-way :-) ... heck I've even figured out what  
the key
above the TAB key is (I was used to having a backtick/tilde there  
and it took
me longer than I care to admit to figure out that key lies next to  
the SHIFT key.



http://www.entropy.ch/software/macosx/php/

Download the latest package and make a custom install.


ok let's assume I know exactly what a 'custom install' is in  
MacWorld (I don't ;-))
and let's assume I install this 'custom install' what happens to  
the standard php
install - I'd rahter not have 2 php builds installed to start with  
(especially if
it's because my lack of knowledge means I don't know how to  
'correctly' remove the

original, standard installation.

anyway thanks for the hint so far ... Im off to investigate.



Uninstalling the pre-installed PHP module shouldn't be that hard. The  
PHP CLI is located under /usr/bin (at least under Tiger, not sure if  
this location was changed under Leopard). The Apache module is  
located under /usr/libexec/httpd


When you install PHP5 with the package from entropy.ch, the new PHP5  
will install under /usr/local/php5. Just download the package to the  
desktop and double click. This opens the Installer application  
within the Utilities folder - the install process should be self- 
explaining. Somewhere in the install process, you will see a button  
labeled Custom install. All necessary configuration of Apache will  
be done automatically.


You might check if /usr/local and /usr/local/php5/bin is stored in  
your PATH environment.


I mean, it is possible to compile PHP from scratch, but it's not that  
easy. See for example here: http://blog.phpdoc.info/archives/83- 
php-5.2.5-on-Leopard.html


You might check out MAMP as well http://sourceforge.net/projects/mamp


I think there are
40/50 PHP extensions included. Just pick what you want.


I'll have the blond ;-)


Sorry, already taken...




//frank

ps. merry christmas ds.





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



[PHP] 'Define vs const' or 'file vs class'

2007-12-17 Thread Johannes Skov Frandsen

Hi everybody

This post is not so much a question to solve a problem but more in the 
direction: what would you do and why.


I'm starting a new project and is preparing the basic layout for the 
application. In all my previous projects I have had a config file that 
all other files would require where I used 'define' to specify database 
connection parameters, site root, picture root and stuff like that.


This works without problems, but as I have started to code more in a OO 
way, I was wondering if it would not me bore clean to create a site 
class with constants for all these values so instead of doing:


echo 'a href=”' . ROOT . '”Go home/a';

I would do this:

echo 'a href=”' .  Site::ROOT . '”Go home/a';

The second might be more verbose in this case, but for a lot of values, 
being able to associate them with the site could prove quite valuable if 
you or someone else has to look at the code half a year from when it was 
original written.


The verbose issue aside, having a config file separate from the actual 
code seems intuitively more clean (in my mind at least) and using
a class for storing config values might no be the best of ideas. But the 
site class could be build from the config file either each time
a script was requested or as part of the build process when your 
application is deployed to the server.


Either way... both solutions would work what I'm looking for here is 
maybe some comments to the ideas before I go ahead with one of them.


Joe

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



RE: [PHP] Securing your Sites

2007-12-17 Thread admin
I want to personally thank you for 6 hours of work to remove the 
PHP-Back-door Trojan, that download from your site to my PC while viewing that 
POS you call a help line.

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



Re: [PHP] 'Define vs const' or 'file vs class'

2007-12-17 Thread Nathan Nobbe
On Dec 17, 2007 8:15 AM, Johannes Skov Frandsen [EMAIL PROTECTED] wrote:

 Hi everybody

 This post is not so much a question to solve a problem but more in the
 direction: what would you do and why.

 I'm starting a new project and is preparing the basic layout for the
 application. In all my previous projects I have had a config file that
 all other files would require where I used 'define' to specify database
 connection parameters, site root, picture root and stuff like that.

 This works without problems, but as I have started to code more in a OO
 way, I was wondering if it would not me bore clean to create a site
 class with constants for all these values so instead of doing:

 echo 'a href=' . ROOT . 'Go home/a';

 I would do this:

 echo 'a href=' .  Site::ROOT . 'Go home/a';

 The second might be more verbose in this case, but for a lot of values,
 being able to associate them with the site could prove quite valuable if
 you or someone else has to look at the code half a year from when it was
 original written.


in this case there is really no difference, especially if Site contains all
the values
that were originally in the file with define directives, the structure is
essentially
the same.


 The verbose issue aside, having a config file separate from the actual
 code seems intuitively more clean (in my mind at least) and using
 a class for storing config values might no be the best of ideas. But the
 site class could be build from the config file either each time
 a script was requested or as part of the build process when your
 application is deployed to the server.

 Either way... both solutions would work what I'm looking for here is
 maybe some comments to the ideas before I go ahead with one of them.


if you are going to have just one class contain all of the configuration
values
there wont be much difference from using define directives.   one thing
about
define is its notoriously slow, so you would have that advantage.
generally, a benefit of using classes w/ constants is the namespace aspect.
so you could have Car::DEFAULT_COLOR and Plane::DEFAULT_COLOR
for example, but again, how much different is that from
define('DEFAULT_CAR_COLOR', 'red');
define('DEFAULT_PLANE_COLOR', 'blue');
i dunno.  to be honest i typically use a mixture of both approaches.  class
constants
for classes when they are appropriate and define directives for global
configuration
values.
strictly speaking i dont think having a class of all constants qualifies an
app
as 'more oo'; id say in java for example you simply dont have any other
choice.

-nathan


Re: [PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread Jason Pruim


On Dec 17, 2007, at 6:47 AM, Frank Arensmeier wrote:


17 dec 2007 kl. 12.03 skrev Jochem Maas:


Frank Arensmeier schreef:

hi guys ( girls),

any Mac heads about? I have a MacBook Pro in front of me ...  
super cool,

it even comes with apache  php installed as standard. nice.

only thing is php is not compiled with with all the extensions I  
need,

the
question is what is the *correct* way to update/recompile the  
standard

installed
copy of php on a Mac? I quite comfortable with compiling/installing
[mulitple]
custom apache+php installs on a linux server but I'd like to keep  
this

Mac as
clean as possible if I can.

If any one has recommendations I love to here from you :-)
in the mean time I'll keep hunting

rgds,
Jochem

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


Why not do it the Mac-way?


I've had this Mac for about 5 minutes - it's my first one ... I'm  
not yet
upto speed on the Mac-way :-) ... heck I've even figured out what  
the key
above the TAB key is (I was used to having a backtick/tilde there  
and it took
me longer than I care to admit to figure out that key lies next to  
the SHIFT key.



http://www.entropy.ch/software/macosx/php/

Download the latest package and make a custom install.


ok let's assume I know exactly what a 'custom install' is in  
MacWorld (I don't ;-))
and let's assume I install this 'custom install' what happens to  
the standard php
install - I'd rahter not have 2 php builds installed to start with  
(especially if
it's because my lack of knowledge means I don't know how to  
'correctly' remove the

original, standard installation.

anyway thanks for the hint so far ... Im off to investigate.



Uninstalling the pre-installed PHP module shouldn't be that hard.  
The PHP CLI is located under /usr/bin (at least under Tiger, not  
sure if this location was changed under Leopard). The Apache module  
is located under /usr/libexec/httpd


When you install PHP5 with the package from entropy.ch, the new PHP5  
will install under /usr/local/php5. Just download the package to the  
desktop and double click. This opens the Installer application  
within the Utilities folder - the install process should be self- 
explaining. Somewhere in the install process, you will see a button  
labeled Custom install. All necessary configuration of Apache will  
be done automatically.


Just opened up terminal on my Leopard iMac G5 and found out that PHP  
is located in: /usr/bin/php and apache is located in: /usr/sbin/httpd


I haven't done it on leopard because my server is still on tiger  
(Stupid fiscal money issues!) but the installer from entropy  
downloaded and installed like a charm and I don't know much about the  
CLI YET :) Born and raised on Macs so I never needed to know alot of  
CLI stuff...






You might check if /usr/local and /usr/local/php5/bin is stored in  
your PATH environment.


I mean, it is possible to compile PHP from scratch, but it's not  
that easy. See for example here: http://blog.phpdoc.info/archives/83-php-5.2.5-on-Leopard.html


You might check out MAMP as well http://sourceforge.net/projects/mamp


I think there are
40/50 PHP extensions included. Just pick what you want.


I'll have the blond ;-)


Sorry, already taken...




//frank

ps. merry christmas ds.





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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



[PHP] nested array...

2007-12-17 Thread opo jal
hi, i have a nested array
ex:
print_r($nestedarray):
 Array(
 [0]=Array([id]=1 [name]=name1 [etc]=etc1)
 [1]=Array([id]=2 [name]=name2 [etc]=etc2)
 [3]=Array([id]=3 [name]=name3 [etc]=etc3)
 )

if I want to check whether id=5 is in that $nestedarray, how to do that?!?!

i'd really appreciate the help..

thanks in advance..


Re: [PHP] Securing your Sites

2007-12-17 Thread Wolf
Funny, they should all be PHPS, source only and my last check only did
them on the source viewing.  None of them are executable in that folder.

You got it from elsewhere.

[EMAIL PROTECTED] wrote:
 I want to personally thank you for 6 hours of work to remove the 
 PHP-Back-door Trojan, that download from your site to my PC while viewing 
 that POS you call a help line.
 
 

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



Re: [PHP] nested array...

2007-12-17 Thread Richard Heyes

print_r($nestedarray):
 Array(
 [0]=Array([id]=1 [name]=name1 [etc]=etc1)
 [1]=Array([id]=2 [name]=name2 [etc]=etc2)
 [3]=Array([id]=3 [name]=name3 [etc]=etc3)
 )

if I want to check whether id=5 is in that $nestedarray, how to do that?!?!

i'd really appreciate the help..


?php
foreach ($nestedarray as $v) {
if ($v['id'] == 5) {
$in_array = true;
break;
}
}
?

--
Richard Heyes
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

** NOW OFFERING FREE ACCOUNTS TO CHARITIES AND NON-PROFITS **

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



RE: [PHP] Securing your Sites

2007-12-17 Thread Dan Parry
 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]
 Sent: 17 December 2007 16:00
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Securing your Sites
 
 Funny, they should all be PHPS, source only and my last check only did
 them on the source viewing.  None of them are executable in that
 folder.
 
 You got it from elsewhere.

I thought that too as I checked the site this morning and they all were .phps

However, wandering back over there sees that they are all now .tar.gz files 
and, upon scanning, do carry a malicious payload

Dan

 [EMAIL PROTECTED] wrote:
  I want to personally thank you for 6 hours of work to remove the
  PHP-Back-door Trojan, that download from your site to my PC while
 viewing that POS you call a help line.
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date:
 16/12/2007 11:36
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date: 16/12/2007 
11:36
 

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



Re: [PHP] nested array...

2007-12-17 Thread Cesar D. Rodas
$nestedarray[$i['id'] == 5

and $i is your array index

On 17/12/2007, opo jal [EMAIL PROTECTED] wrote:

 hi, i have a nested array
 ex:
 print_r($nestedarray):
 Array(
 [0]=Array([id]=1 [name]=name1 [etc]=etc1)
 [1]=Array([id]=2 [name]=name2 [etc]=etc2)
 [3]=Array([id]=3 [name]=name3 [etc]=etc3)
 )

 if I want to check whether id=5 is in that $nestedarray, how to do
 that?!?!

 i'd really appreciate the help..

 thanks in advance..




-- 
Best Regards

Cesar D. Rodas
http://www.cesarodas.com
http://www.thyphp.com
http://www.phpajax.org
Phone: +595-961-974165


RE: [PHP] Securing your Sites

2007-12-17 Thread Dan Parry
 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]
 Sent: 17 December 2007 16:00
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Securing your Sites
 
 Funny, they should all be PHPS, source only and my last check only did
 them on the source viewing.  None of them are executable in that
 folder.
 
 You got it from elsewhere.

Sorry, update

Scanning with AVG reveals that c99-2, 3 and 4 report backdoor Trojan infections 
but it occurs to me that maybe AVG is just finding the malicious payload you 
are demonstrating?

I'd like to thank you for supplying the source for these exploits... If I've 
made a mistake and compounded an incorrect situation I do apologise

Dan

 [EMAIL PROTECTED] wrote:
  I want to personally thank you for 6 hours of work to remove the
  PHP-Back-door Trojan, that download from your site to my PC while
 viewing that POS you call a help line.
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date:
 16/12/2007 11:36
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date: 16/12/2007 
11:36
 

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



Re: [PHP] Securing your Sites

2007-12-17 Thread Jeremy Mcentire
Wait, I'm confused.  Did PHP send a virus to your computer without  
action on your part?  That'd be scary.  If you downloaded something,  
was the checksum not published for you to verify your download prior  
to unpacking it?  That's always a warning worthy of apprehension.   
What was the PHP-Back-door Trojan exactly?


Jeremy Mcentire
Ant Farmer
ZooToo LLC

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



Re: [PHP] Securing your Sites

2007-12-17 Thread Wolf
2 things I've done to them to try to catch all...

1. GZiped them all (you'll have to download them to a machine and look
at the source yourself, taking your own precautions and YES, they will
scan malicious in this setup as they are all trojans/backdoors)
2. changed their extension to .txt on the server

I'll also modify the server folder they are running on to disable php
entirely later tonight so they can never execute it on it.

When I reloaded them in my windoze box, my AV picked up on them in the
cache as the trojans they are and disabled access to them in my
browser's cache.  Since I don't run php on the windoze box, there really
was nothing to worry about and I could view the source in the browser.

But if you didn't run AV on the system you looked at them at, installed
them to your own local area and started playing with them, then you
pretty much borked yourself.  They are live code (hence why they were
phps and should have just been source to view) and the only way to
really pick them apart to view them.

Considering that the code was phps and the server treated them as such
never did my server execute them.

Wolf

Dan Parry wrote:
 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]
 Sent: 17 December 2007 16:00
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Securing your Sites

 Funny, they should all be PHPS, source only and my last check only did
 them on the source viewing.  None of them are executable in that
 folder.

 You got it from elsewhere.
 
 I thought that too as I checked the site this morning and they all were .phps
 
 However, wandering back over there sees that they are all now .tar.gz files 
 and, upon scanning, do carry a malicious payload
 
 Dan
 
 [EMAIL PROTECTED] wrote:
 I want to personally thank you for 6 hours of work to remove the
 PHP-Back-door Trojan, that download from your site to my PC while
 viewing that POS you call a help line.

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

 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date:
 16/12/2007 11:36

 
 No virus found in this outgoing message.
 Checked by AVG Free Edition. 
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date: 16/12/2007 
 11:36
  
 
 

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



Re: [PHP] Securing your Sites

2007-12-17 Thread Daniel Brown
On Dec 17, 2007 11:27 AM, Jeremy Mcentire [EMAIL PROTECTED] wrote:
 Wait, I'm confused.  Did PHP send a virus to your computer without
 action on your part?  That'd be scary.  If you downloaded something,
 was the checksum not published for you to verify your download prior
 to unpacking it?  That's always a warning worthy of apprehension.
 What was the PHP-Back-door Trojan exactly?

Here's what is going on, from start to finish, for anyone who may
be concerned:

1.) Wolf's server was breeched (or attempted) by a couple of
wannabes and script kiddies.
2.) He tar'ed and gZip'ed the malicious PHP scripts, after
renaming them to .phps (source) scripts for you to view.
3.) When you download the gZip'ed tarballs, they contain the PHP
source code in a .phps, as expected.
4.) Any scans of those files COULD and SHOULD indicate that they
are exploits --- BECAUSE THEY ARE.
5.) Some of you may not have chosen to fully read the page telling
you what they are prior to downloading.
6.) If Step 5 applies to you, that is YOUR FAULT, not Wolf's.

I didn't find it all that difficult to read the two paragraphs or
so prior to downloading.  In fact, I find that I rather enjoy doing
that so I know what the hell I'm downloading in the first place,
before blindly downloading some code.  ;-P


-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

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



Re: [PHP] Securing your Sites

2007-12-17 Thread Wolf
ALL of them should report trojan if you download them to your cache but
only should be an issue if you have PHP installed on that machine and
then execute that code in your own php server.

They are all trojans/back door.

But if you view the source then you aren't going to bork yourself.

As they are now all tar.gz the AV scanners should all catch them as
trojans, so you will need to tell your scanner to all you to access that
folder, save it to your local drive and view the source in your favorite
text editor to look at them.

Wolf

Dan Parry wrote:
 -Original Message-
 From: Wolf [mailto:[EMAIL PROTECTED]
 Sent: 17 December 2007 16:00
 To: [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Subject: Re: [PHP] Securing your Sites

 Funny, they should all be PHPS, source only and my last check only did
 them on the source viewing.  None of them are executable in that
 folder.

 You got it from elsewhere.
 
 Sorry, update
 
 Scanning with AVG reveals that c99-2, 3 and 4 report backdoor Trojan 
 infections but it occurs to me that maybe AVG is just finding the malicious 
 payload you are demonstrating?
 
 I'd like to thank you for supplying the source for these exploits... If I've 
 made a mistake and compounded an incorrect situation I do apologise
 
 Dan
 
 [EMAIL PROTECTED] wrote:
 I want to personally thank you for 6 hours of work to remove the
 PHP-Back-door Trojan, that download from your site to my PC while
 viewing that POS you call a help line.

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

 No virus found in this incoming message.
 Checked by AVG Free Edition.
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date:
 16/12/2007 11:36

 
 No virus found in this outgoing message.
 Checked by AVG Free Edition. 
 Version: 7.5.503 / Virus Database: 269.17.4/1187 - Release Date: 16/12/2007 
 11:36
  
 

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



Re: [PHP] re-compiling PHP on Mac OS X

2007-12-17 Thread David Powers

Frank Arensmeier wrote:
When you install PHP5 with the package from entropy.ch, the new PHP5 
will install under /usr/local/php5.


The Mac package from entropy.ch is not compatible with Leopard (Mac OS X 
10.5). Marc Liyanage is working on a Leopard-compatible version. Check 
the forum on his site for the latest details. There's an extremely long 
thread about PHP on Leopard. A command line installation is somewhere 
around page 15 of the thread.


--
David Powers

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



[PHP] Re: [PHP-DB] force to download file

2007-12-17 Thread Daniel Brown
On Dec 17, 2007 3:13 PM, Hiep Nguyen [EMAIL PROTECTED] wrote:
 hi all,

 i have this on top of my php page:

 header(Content-Type: application/vnd.ms-excel);
 header(Content-Disposition: inline; filename=excelfile.xls);

 but it is not prompt to save the file instead it opens right in IE.

 my question is how do i force the browser prompts to save the file?

 thanks

Hiep,

This is a question that should've been asked on the PHP General
list, so I'm reply-all'ing and sending it to the General list for the
archives as well.

Here's a function I use that should help you out.

?
function force_download($filename,$dir='./') {
if ((isset($file))(file_exists($dir.$file))) {
header(Content-type: application/force-download);
header('Content-Disposition: inline; filename='.$dir.$filename.'');
header(Content-Transfer-Encoding: Binary);
header(Content-length: .filesize($dir.$filename));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$filename.'');
readfile($dir.$filename);
} else {
echo No file selected;
}
}
?


-- 
Daniel P. Brown
[Phone Numbers Go Here!]
[They're Hidden From View!]

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

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



Re: [PHP] nested array...

2007-12-17 Thread Richard Lynch
On Mon, December 17, 2007 8:48 am, opo jal wrote:
 hi, i have a nested array
 ex:
 print_r($nestedarray):
  Array(
  [0]=Array([id]=1 [name]=name1 [etc]=etc1)
  [1]=Array([id]=2 [name]=name2 [etc]=etc2)
  [3]=Array([id]=3 [name]=name3 [etc]=etc3)
  )

 if I want to check whether id=5 is in that $nestedarray, how to do
 that?!?!

 i'd really appreciate the help..

I would have built the arrays with the ID as the index in the first
place, and then used http://php.net/isset, but maybe that's just me...

You could mess with in_array I suspect, or write an array_map that
stores the ID when you hit it...

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/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] re-compiling PHP on Mac OS X

2007-12-17 Thread Frank Arensmeier

17 dec 2007 kl. 18.23 skrev David Powers:


Frank Arensmeier wrote:
When you install PHP5 with the package from entropy.ch, the new  
PHP5 will install under /usr/local/php5.


The Mac package from entropy.ch is not compatible with Leopard (Mac  
OS X 10.5). Marc Liyanage is working on a Leopard-compatible  
version. Check the forum on his site for the latest details.  
There's an extremely long thread about PHP on Leopard. A command  
line installation is somewhere around page 15 of the thread.


Thanks for the information! As a matter of fact, although I already  
have a Leopard DVD, I haven't updated my development machine yet. My  
impression of Leopard (installed on my iMac at home) is that the OS  
still is somewhat unstable. I'll wait for 10.5.2 / 10.5.3


//frank



--
David Powers

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



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



Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Richard Lynch
On Sun, December 16, 2007 7:59 pm, Dave M G wrote:
 I've been able to write text into an image using the default fonts
 available, with this command:

 ImageString($image, 5, $x - 20,$y-10, $text, $textColour);

 The problem is that the font that is identified by the index 5 is
 too
 small. But it seems that it can't be scaled in any way.

Have you tried 0, 1, 2, 3 and 4?

They are all built-in and different sizes.

 So I thought I would try to specify a font and try something like
 this:

 $font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
 $imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);

 But I'm clearly not doing things quite right, and I have some
 questions:

 1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts
 directory. But specifying it doesn't seem to work. How do I get the
 system to find the font?

This should work, according to the docs...

Can the FreeSans.ttf file be read by the PHP user?

 2. I need the scripts I'm writing to be portable, so can I be sure of
 what fonts will be available, and will I be able to locate them?

You are plain out of luck here.
There is NOTHING you can rely on for fonts installed at all, much less
where they will be.
You'd have to package them in with your own software to be safe.

And that may open up licensing/legal issues...

 3. I'm not really concerned about what font it is, just that it's
 large
 and readable. If there are other options than what I've explored here,
 then I would be open to those too.

You could draw the image with a smaller font, and scale the whole
image up...

But that would usually not work well, as the scaling up has to
interpolate pixels, which rarely looks good...

You could also try using:
$font =
imageloadfont('/usr/share/fonts/truetype/freefonts/FreeSans.ttf');
if (!$font){
  error_log(Unable to load font!);
  $font = 5; //fall back to built-in font #5
}
ImageString($image, $font, $x - 20,$y-10, $text, $textColour);

-- 
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] PRG pattern - how to implement a load page using GET

2007-12-17 Thread Richard Lynch
On Sun, December 16, 2007 2:05 pm, Robert Erbaron wrote:
 - Never show pages in response to POST
 - Navigate from POST to GET using REDIRECT
 - Always load pages using GET

I believe #3 is simply a more general way of saying #1 + #2, but may
be wrong.

And I basically completely disagree with the author in the first
place, so...

 (P.S. I'll get to the issue of rearchitecting this via require instead
 of using header() redirects,cough, cough, Richard Lynch, cough, cough
 :) in a future message. One step at a time...)

... you can probably just ignore this, as it's diametrically opposed
to the rules you're following, as I understand them.

ymmv

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



[PHP] Re: Writing text into images, and setting text size

2007-12-17 Thread Al

http://www.imagemagick.org/Usage/text/

You can use http://docs.php.net/manual/en/intro.imagick.php
Or exec() with Imagemagick commands directly http://www.imagemagick.org

Dave M G wrote:

PHP List,

I've been able to write text into an image using the default fonts 
available, with this command:


ImageString($image, 5, $x - 20,$y-10, $text, $textColour);

The problem is that the font that is identified by the index 5 is too 
small. But it seems that it can't be scaled in any way.


So I thought I would try to specify a font and try something like this:

$font = '/usr/share/fonts/truetype/freefonts/FreeSans.ttf';
$imagettftext($image, 20, 0, $x, $y-10, $textColour, $font, $text);

But I'm clearly not doing things quite right, and I have some questions:

1. 'FreeSans.ttf' is in my /usr/share/fonts/truetype/freefonts 
directory. But specifying it doesn't seem to work. How do I get the 
system to find the font?


2. I need the scripts I'm writing to be portable, so can I be sure of 
what fonts will be available, and will I be able to locate them?


3. I'm not really concerned about what font it is, just that it's large 
and readable. If there are other options than what I've explored here, 
then I would be open to those too.


Thank you for any advice.



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



Re: [PHP] PRG pattern - how to implement a load page using GET

2007-12-17 Thread Robert Erbaron

 And I basically completely disagree with the author in the first
 place, so...

Well, that's been clear for a year. :)

  (P.S. I'll get to the issue of rearchitecting this via require instead
  of using header() redirects,cough, cough, Richard Lynch, cough, cough
  :) in a future message. One step at a time...)

 ... you can probably just ignore this, as it's diametrically opposed
 to the rules you're following, as I understand them.

'tain't gonna ignore it. Just want to understand the PRG first. Much
better to understand something before dismissing it. Simply saying 'it
sucks' without understanding it is sorta ignorant.

Course, I may end up disagreeing with you, but we won't know that
until next week's exciting episode.
-- 
RE, Chicago

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



[PHP] PHP Session Vars Flash Movie

2007-12-17 Thread Luis Magaña
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I have a small application made in flash, that uses a set of PHP scripts
to pull data from a database. I've added sessions to this scripts so
they would only return the data if a proper session has been
initialized, the flash movie is hosted in a sessioned php as well so you
can only see it if a session has been initialized.

All of it works well, the flash movie calls the scripts and the scripts
return the data if and only if a session has been started. all of this
was tested on Apache 2.2.2 and PHP 5.1.6 and works as expected. however,
moving the whole thing to another server running Apache 2.2.6 with PHP
5.2.4 does not work, the flash movie calls the scripts, but it seems to
be calling them outside the session set in PHP, thus the scripts return
and invalid session message, if we call the scripts directly once the
session has been initialized they return the correct data.

So, the question is, is the above working because we are relaying on
some bug in the previous versions of apache+php or are we missing some
setting in the new versions ? We have tried to find a relevant setting
making a difference but so far we are not able to do so.

Thank you very much for your help.

Regards.

- --
Luis Magaña
Gnovus Networks  Software
www.gnovus.com
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (Darwin)

iD8DBQFHZzXtqSchlMT6gK4RAjHRAJ4pU81dw8BpZBf7bhF5QS7mxRqMcQCaAtIu
eTMSRMXsmddN0jvqEWUOlrw=
=fSiN
-END PGP SIGNATURE-

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



[PHP] PHP translation needed

2007-12-17 Thread Grace Shibley
Hi Everyone,

We have an encryption function that was written in another language that we
needed translated to PHP.

Here's the function:

function rc4 pText, pKey
-- initialize
repeat with i = 0 to 255
put i into S1[i]
end repeat

put 0 into i
repeat with n = 0 to 255
add 1 to i
if i  length(pkey) then put 1 into i
put chartonum(char i of pKey) into S2[n]
end repeat

put 0 into j
repeat with i = 0 to 255
put (j + S1[i] + S2[i]) mod 256 into j
put S1[i] into temp
put S1[j] into S1[i]
put temp into S1[j]
end repeat

-- encrypt/decrypt
put 0 into i ; put 0 into j
repeat for each char c in pText
put chartonum(c) into tChar

put (i + 1) mod 256 into i
put (j + S1[i]) mod 256 into j
put S1[i] into temp
put S1[j] into S1[i]
put temp into S1[j]
put (S1[i] + S1[j]) mod 256 into t
put S1[t] into K

put numtochar(tChar bitXor K) after tOutput
end repeat

return tOutput
end rc4

Can anyone help us with this?  We don't mind paying via PayPal :)

Thanks!
grace


Re: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Dave M G

Andrés,

Thank you for responding.


Deploy the fonts along with your scripts... that's the only way I know.
... I do so for a custom CAPTCHA script I've made.


This sounds like a good solution. I'm having a little trouble 
implementing it, however.


I have what I believe is a freely distributable font called 
FreeSans.ttf, and I put it in a directory called fonts in the base 
directory of my site.


However, this seems not to work:

$font = 'fonts/FreeSans.ttf';
imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);

Putting a slash in front to specify starting from the base directory - 
'/fonts/FreeSans.ttf' - does not seem to work either.


Looking in the manual, it seemed that maybe I needed to set the font 
path with putenv:


$path = realpath('fonts');
putenv('GDFONTPATH=' . $path);

But this yielded no results.

Am I still getting the syntax wrong somehow?

Thank you for any advice.

--
Dave M G

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



[PHP] XML Extraction

2007-12-17 Thread VamVan
Hello,

I receive an output  as an  XML File. Please  provide some scripts that I
can use for extraction of the values.

For Example:
titlehello/title

titlehello2/title

titlehello3/title

are 3 different records in the XML File. How can I retrieve the result set
in a loop and also sort it like DESC and ASC for example.

While()
{
 xml['title'] // Value
}
Thanks,
Vamsee


Re: [PHP] PHP translation needed

2007-12-17 Thread Casey
On Dec 17, 2007 7:06 PM, Grace Shibley [EMAIL PROTECTED] wrote:
 Hi Everyone,

 We have an encryption function that was written in another language that we
 needed translated to PHP.

 Here's the function:

 function rc4 pText, pKey
 -- initialize
 repeat with i = 0 to 255
 put i into S1[i]
 end repeat

 put 0 into i
 repeat with n = 0 to 255
 add 1 to i
 if i  length(pkey) then put 1 into i
 put chartonum(char i of pKey) into S2[n]
 end repeat

 put 0 into j
 repeat with i = 0 to 255
 put (j + S1[i] + S2[i]) mod 256 into j
 put S1[i] into temp
 put S1[j] into S1[i]
 put temp into S1[j]
 end repeat

 -- encrypt/decrypt
 put 0 into i ; put 0 into j
 repeat for each char c in pText
 put chartonum(c) into tChar

 put (i + 1) mod 256 into i
 put (j + S1[i]) mod 256 into j
 put S1[i] into temp
 put S1[j] into S1[i]
 put temp into S1[j]
 put (S1[i] + S1[j]) mod 256 into t
 put S1[t] into K

 put numtochar(tChar bitXor K) after tOutput
 end repeat

 return tOutput
 end rc4

 Can anyone help us with this?  We don't mind paying via PayPal :)

 Thanks!
 grace


function rc4($pText, $pKey) {
// initialize
$S1 = range(0, 255);
$S2 = array();

$i = 0;
for ($n=0; $n=255; $n++) {
$i++;
if ($i  strlen($pkey))
$i = 1;
$S2[] = ord($pKey[$i]);
}

$j = 0;
for ($i=0; $i=255; $i++) {
$j = ($j + $S1[$i] + $S2[$i]) % 256;
$temp = $S1[$i];
$S1[$i] = $S1[$j];
$S1[$j] = $temp;
}

// encrypt/decrypt
$i = $j = 0;
$tOutput = '';

foreach (str_split($pText) as $c) {
$tChar = ord($c);

$i = ($i+1) % 256;
$j = ($j+$S1[$i]) % 256;
$temp = $S1[$i];
$S1[$i] = $S1[$j];
$S1[$j] = $temp;
$t = ($S1[$i] + $S1[$j]) % 256;
$K = $S1[$t];

$tOutput .= chr($tChar ^ $K);
}

return $tOutput;
}

I don't know what language this is. I'm curious -- what is it? It
might not work; it's untested except for syntax errors.

[EMAIL PROTECTED] ;]

-Casey

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



Re: [PHP] XML Extraction

2007-12-17 Thread Nathan Nobbe
On Dec 17, 2007 10:44 PM, VamVan [EMAIL PROTECTED] wrote:

 Hello,

 I receive an output  as an  XML File. Please  provide some scripts that I
 can use for extraction of the values.

 For Example:
 titlehello/title

 titlehello2/title

 titlehello3/title

 are 3 different records in the XML File. How can I retrieve the result set
 in a loop and also sort it like DESC and ASC for example.

 While()
 {
  xml['title'] // Value
 }



?php
$xml=
XML
container
titlei/title
titlecare/title
titleabout/title
titlethings/title
arbitraryContentxmlInPhpIsFun/arbitraryContent
/container
XML;

$simpleXmlElt = new SimpleXMLElement($xml);
$titleElements = $simpleXmlElt-xpath('//title');
foreach($titleElements as $curTitleElement) {
echo $curTitleElement . PHP_EOL;
}
?

no charge ;) hehe
-nathan


RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
I'm tempted to say that the problem is that the system is not finding the 
font... you'd need to include the full path to the font (and it must be 
readable for the user PHP runs on behalf).

Try the following:

Just for testing put the font and the script that generates the image in the 
SAME directory, so let's say you have something like this:

arial.ttf (-- I just copied it from my windows fonts folder)
PrintImage.php

BOTH IN THE SAME DIRECTORY...
Then, the code for PrintImage.php would look like the following...

?php
//
/* Begin PrintImage.php */

// dirname(__FILE__) means the full path to the directory where this file 
PrintImage.php is sitting
$fontFile = dirname(__FILE__).'/arial.ttf';

$imW = 200;
$imH = 100;
$im = imagecreatetruecolor($imgW, $imgH);
$bgColor = imagecolorallocate($im, 238, 239, 239);
$borderColor = imagecolorallocate($im, 208, 208, 208);
$textColor = imagecolorallocate($im, 46, 60, 31);
$whiteColor = imagecolorallocate($im, 255, 255, 255);
$fontSize = 18;
$textAngle = 0;
$codeString = 'Works!';

// Print rectangle
imagefilledrectangle($im, 0, 0, $imgW, $imgH, $bgColor);
imagerectangle($im, 0, 0, $imW-1, $imH-1, $borderColor);

// Print Text (Calculate Position)
$box = imagettfbbox($fontSize, $fontAngle, $fontFile, $codeString);
$x = (int)($imgW - $box[4]) / 2;
$y = (int)($imgH - $box[5]) / 2;
imagettftext($im, $fontSize, $fontAngle, $x, $y, $textColor, $fontFile, 
$codeString);

// Output... no caching
header(Content-type: image/png);
header(Cache-Control: no-cache, must-revalidate);
header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
imagepng($im);

/* End PrintImage.php */
/**/
?

Then you know what you do... you load PrintImage.php into your browser and 
you'll get a nice gray rectangle with the word Works! in the center of it. If 
you don't get that... then you have a problem that is not related to path or to 
PHP per-se... maybe it's a GD issue, or the font is broken... or whatever other 
issue... but this code works in windows and linux provided that you get the 
arial.ttf in the same directory as PrintImage.php.

And... use dirname(__FILE__) or similar (meaning ABSOLUTE PATHS), as much as 
possible to reference other files for inclusion or processing... doing 
./myfile.php or ../myfile.php leads to headaches... and usually in the 
moment you can't take a headache (which is project deadlines).

Hope this helps,

Rob
 -Original Message-
 From: Dave M G [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 18, 2007 12:31 AM
 To: Andrés Robinet
 Cc: 'PHP List'
 Subject: Re: [PHP] Writing text into images, and setting text size
 
 Andrés,
 
 Thank you for responding.
 
  Deploy the fonts along with your scripts... that's the only way I
 know.
  ... I do so for a custom CAPTCHA script I've made.
 
 This sounds like a good solution. I'm having a little trouble
 implementing it, however.
 
 I have what I believe is a freely distributable font called
 FreeSans.ttf, and I put it in a directory called fonts in the base
 directory of my site.
 
 However, this seems not to work:
 
 $font = 'fonts/FreeSans.ttf';
 imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);
 
 Putting a slash in front to specify starting from the base directory -
 '/fonts/FreeSans.ttf' - does not seem to work either.
 
 Looking in the manual, it seemed that maybe I needed to set the font
 path with putenv:
 
 $path = realpath('fonts');
 putenv('GDFONTPATH=' . $path);
 
 But this yielded no results.
 
 Am I still getting the syntax wrong somehow?
 
 Thank you for any advice.
 
 --
 Dave M G
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



RE: [PHP] Writing text into images, and setting text size

2007-12-17 Thread Andrés Robinet
Just a correction...

Replace at the beginning of the script (I had some typos, while extracting the 
code from the original script)

 $imW = 200;
 $imH = 100;

By this..

$imgW = 200;
$imgH = 100;

Regards,

Rob


Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | 
TEL 954-607-4207 | FAX 954-337-2695
Email: [EMAIL PROTECTED]  | MSN Chat: [EMAIL PROTECTED]  |  SKYPE: bestplace |  
Web: http://www.bestplace.biz | Web: http://www.seo-diy.com

 -Original Message-
 From: Andrés Robinet [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 18, 2007 1:33 AM
 To: 'Dave M G'
 Cc: 'PHP List'
 Subject: RE: [PHP] Writing text into images, and setting text size
 
 I'm tempted to say that the problem is that the system is not finding
 the font... you'd need to include the full path to the font (and it
 must be readable for the user PHP runs on behalf).
 
 Try the following:
 
 Just for testing put the font and the script that generates the image
 in the SAME directory, so let's say you have something like this:
 
 arial.ttf (-- I just copied it from my windows fonts folder)
 PrintImage.php
 
 BOTH IN THE SAME DIRECTORY...
 Then, the code for PrintImage.php would look like the following...
 
 ?php
 //
 /* Begin PrintImage.php */
 
 // dirname(__FILE__) means the full path to the directory where this
 file PrintImage.php is sitting
 $fontFile = dirname(__FILE__).'/arial.ttf';
 
 $imW = 200;
 $imH = 100;
 $im = imagecreatetruecolor($imgW, $imgH);
 $bgColor = imagecolorallocate($im, 238, 239, 239);
 $borderColor = imagecolorallocate($im, 208, 208, 208);
 $textColor = imagecolorallocate($im, 46, 60, 31);
 $whiteColor = imagecolorallocate($im, 255, 255, 255);
 $fontSize = 18;
 $textAngle = 0;
 $codeString = 'Works!';
 
 // Print rectangle
 imagefilledrectangle($im, 0, 0, $imgW, $imgH, $bgColor);
 imagerectangle($im, 0, 0, $imW-1, $imH-1, $borderColor);
 
 // Print Text (Calculate Position)
 $box = imagettfbbox($fontSize, $fontAngle, $fontFile, $codeString);
 $x = (int)($imgW - $box[4]) / 2;
 $y = (int)($imgH - $box[5]) / 2;
 imagettftext($im, $fontSize, $fontAngle, $x, $y, $textColor, $fontFile,
 $codeString);
 
 // Output... no caching
 header(Content-type: image/png);
 header(Cache-Control: no-cache, must-revalidate);
 header(Expires: Mon, 26 Jul 1997 05:00:00 GMT);
 imagepng($im);
 
 /* End PrintImage.php */
 /**/
 ?
 
 Then you know what you do... you load PrintImage.php into your browser
 and you'll get a nice gray rectangle with the word Works! in the
 center of it. If you don't get that... then you have a problem that is
 not related to path or to PHP per-se... maybe it's a GD issue, or the
 font is broken... or whatever other issue... but this code works in
 windows and linux provided that you get the arial.ttf in the same
 directory as PrintImage.php.
 
 And... use dirname(__FILE__) or similar (meaning ABSOLUTE PATHS), as
 much as possible to reference other files for inclusion or
 processing... doing ./myfile.php or ../myfile.php leads to
 headaches... and usually in the moment you can't take a headache (which
 is project deadlines).
 
 Hope this helps,
 
 Rob
  -Original Message-
  From: Dave M G [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, December 18, 2007 12:31 AM
  To: Andrés Robinet
  Cc: 'PHP List'
  Subject: Re: [PHP] Writing text into images, and setting text size
 
  Andrés,
 
  Thank you for responding.
 
   Deploy the fonts along with your scripts... that's the only way I
  know.
   ... I do so for a custom CAPTCHA script I've made.
 
  This sounds like a good solution. I'm having a little trouble
  implementing it, however.
 
  I have what I believe is a freely distributable font called
  FreeSans.ttf, and I put it in a directory called fonts in the
 base
  directory of my site.
 
  However, this seems not to work:
 
  $font = 'fonts/FreeSans.ttf';
  imagettftext($image, 20, 0, $x, $y, $textColour, $font, $text);
 
  Putting a slash in front to specify starting from the base directory
 -
  '/fonts/FreeSans.ttf' - does not seem to work either.
 
  Looking in the manual, it seemed that maybe I needed to set the font
  path with putenv:
 
  $path = realpath('fonts');
  putenv('GDFONTPATH=' . $path);
 
  But this yielded no results.
 
  Am I still getting the syntax wrong somehow?
 
  Thank you for any advice.
 
  --
  Dave M G
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP] Generating Random Numbers with Normal Distribution

2007-12-17 Thread tedd

At 5:10 PM -0600 12/15/07, Richard Lynch wrote:

On Wed, December 12, 2007 11:07 pm, Robert Cummings wrote:

 Once again, we're not trying to prove order. Order obviously exists.


I'm not sure I'd agree that order exists in the first place, much less
randomness or disorder.  They could all be solely our human incorrect
interpretation.


Well, that's close to my point -- order and disorder, random and 
predictable are concepts in our minds that do not exist in nature. 
Once a series of events, or an arrangement of objects satisfies our 
mind's definition of order or random, then we define it that way.


Cheers,

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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