Re: [PHP] Strings Question

2001-12-24 Thread Matt McClanahan

On Mon, Dec 24, 2001 at 01:48:38PM -0800, Phillip B. Bruce wrote:

 I want to take something like the following:
 
 $row = 1;
 $ column = 1;
 
 if ( $pages = r$row$column)
 
What I want to see is r1c1 as a string so I'm actually
 concatenating the strings together.

if ($pages == r$row . c$column)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP as a web browser?

2001-12-17 Thread Matt McClanahan

On Sun, Dec 16, 2001 at 11:48:38PM -0800, David Yee wrote:

 Is it possible to have PHP act like a web browser, accept cookies and
 post data (for login)?  I'm not sure exactly where to start- I know
 you can use fopen/file to retrieve url's but I'm not too sure about
 the other steps.  I would like to write and run such a php script as
 a cron job and have it do something like log into my web-based email
 account, retrieve emails, process them, save them locally, and then
 delete them on the server.  Thanks for any help.

Have a look at hte Snoopy PHP class, an object that simulates a web
browser.

http://sourceforge.net/projects/snoopy/

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] XHTML compatible error messages

2001-12-05 Thread Matt McClanahan

On Fri, Aug 17, 2001 at 05:40:07PM +0200, Jan wrote:

 Hi out there!
 
 I have got a problem with PHP's standard way of reporting errors. The
 br in the error messages are making the XML invalid (should be
 br/). Is there an easy way to do this?

This was done in CVS a few months ago.  It should be in PHP 4.1.0 when
it comes out shortly.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting the filesize of an image?

2001-12-01 Thread Matt McClanahan

On Sat, Dec 01, 2001 at 09:55:47AM +0200, faeton wrote:

 Hello Matt,
 
 filesize() works only on local filesystems.

If you want the size of a remote file, you'll have to download it; HTTP
doesn't provide a way to query a remote file's size.  FTP does, if you have
FTP access.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting the filesize of an image?

2001-12-01 Thread Matt McClanahan

On Sat, Dec 01, 2001 at 11:05:51PM +0200, faeton wrote:

 Hello Matt,
 
 Of course it does not, but as i've already said file() with strlen()
 can be used. :)
 
 MM If you want the size of a remote file, you'll have to download it; HTTP
 MM doesn't provide a way to query a remote file's size.  FTP does, if you have
 MM FTP access.

Not on binary files.  For an image that's 4494 bytes, file/join/strlen gives
me 3512.  And since file() on a remote file is downloading it anyway, you
might as well do it right:

$fp = fopen('http://example.com/image.jpg','r');
while (!feof($fp))
$image .= fread($fp,1024);
echo strlen($image);

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting the filesize of an image?

2001-11-30 Thread Matt McClanahan

On Fri, Nov 30, 2001 at 07:04:08PM -0500, Uchendu Nwachukwu wrote:

 Is there any easy way to get the filesize of an image on a remote server?
 
 Please tell me there is! TIA

It scares me that nobody has answered with filesize() yet.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Save to Desktop

2001-11-12 Thread Matt McClanahan

On Mon, Nov 12, 2001 at 11:14:04AM +0530, Sharat Hegde wrote:

 Hello,
 
 I need to capture the contents of a Form into a text file format and
 automatically allow the user to Save the file to his desktop.
 
 Here is what I am intending to do:
 * Capture the form contents and save to a temporary file. This works fine.
 * Provide some method of the user automatically downloading this. How do I
 get this download to happen?
 
 I want the screen which says Open File or Save to come up and then the
 user can basically save to his desktop.

It's not even necessary to save the form data to a file on the server
if you're just going to remove it after the user downloads the text
file.  The key to this is knowing the proper HTTP headers to send, to
inform the browser that it should download a file.  Then simply print
the desired form data to stdout, and it'll be fed into the file that
the user saves.

For example:

?

if ($action == 'Get Text File')
{  
// Tell the browser to display a 'save file' dialog
Header('Content-Type: application/octet-stream');
Header('Content-Disposition: attachment; filename=formdata.txt');

// Print the text to be sent as formdata.txt
echo First text field: $firstfield\n;
echo Second text field: $secondfield\n;  

exit;
}
  
?
form method=post action=?= $PHP_SELF ?  
First: input type=text name=firstfieldbr 
Seond: input type=text name=secondfieldbr
input type=submit name=action value=Get Text File
/form

Here, the form takes in two text strings, and offers them to the
browser as a file.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] url extracting

2001-11-12 Thread Matt McClanahan

On Mon, Nov 12, 2001 at 04:42:08PM -, Caspar Kennerdale wrote:

 I am yrying to read free urls from a moreover.com to a director app which
 will be a news reader without a browser
 
 'm using php top extrat the headlines
 
 each headline looks similar to this
 
 (http://c.moreover.com/click/here.pl?l27536670;)
 
 
 If a browser goes to this page then it is redirected to the appropriate page
 ie www.newssite.com/etc/etc/etc
 
 Director does not interpret the redirection.
 
 Can anyone think of a way for a script to go the to the moreover link and
 then return the 'real url as a variable or as an array of links (if multiple
 headlines are required

You can open a socket to the web server with PHP and grab the Location
header from the response.

See the fsockopen() man page for examples, or sendtohost.txt for a
simple function to handle passing the right headers.

http://www.php.net/manual/en/function.fsockopen.php
http://dodds.net/~cardinal/sendtohost.txt

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP Usage Stats

2001-11-09 Thread Matt McClanahan

On Fri, Nov 09, 2001 at 10:11:50AM -0800, Chris wrote:

 Are there any refrences that would indicate the percent of sites (PHP
 installs) using various versions of PHP (i.e., 60% PHP4, 30% PHP3,
 etc.)?

See the top of http://php.net which refers to usage stats provided by
Netcraft and SecuritySpace.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] why cant I: array_keys($arr)[0] ?

2001-11-04 Thread Matt McClanahan

On Sun, Nov 04, 2001 at 12:54:54AM -0700, [EMAIL PROTECTED] wrote:

 Why does PHP give a parse error if you do:
 
   echo array_keys($arr)[0];
 
 It makes you assign the result of the function to a var first like this:
 
   $arr = array_keys($arr);
   echo $arr[0];
 
 I just want to grab the 1st element of the array. Why does it make you do
 it in 2 lines instead of letting you index right on the array that results
 from the function?

// Shifts the first element off the array
$first_element = array_shift($array);

// Returns the first element, preserving the array in the calling scope
function get_array_first($arr)
{
return array_shift($arr);
}
$first_element = get_arr_first($array);

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Displaying images in another page

2001-10-25 Thread Matt McClanahan

On Thu, Oct 25, 2001 at 10:30:24PM +0200, Rudi Ahlers wrote:

 I would like to setup a banned ad server, and I will need the images
 to be displayed in standard html pages, where the users don't have
 php access. Thus, they should be able to call up the image from a
 normal html page, ie: img align=center border=0
 src=http://www.adserv.webonline.co.za/phpads.php3?what=main;
 
 Can anyone give me some tips on howto do this? And any other tips for
 banner ad servers would be great as well.

For tips on banner ad services, I'd simply suggest looking over phpAds
and other such apps (See freshmeat.net).

Displaying images in this fashion is fairly simple.

In the html, as you've already provided, set the img src=.. to a
PHP script, possibly with a query string.  Then, your phpads.php3 would
be responsible for outputing the image data, along with the proper HTTP
header to tell the browser that you're sending it an image.

?

// phpads.php3

// Set the appropriate mimetype for the image
Header('Content-Type: image/jpeg');

$filename = '/path/to/file.jpg';

// Output the image data
readfile($filename);

?

That's it.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] sorting an array of objects

2001-10-24 Thread Matt McClanahan

On Wed, Oct 24, 2001 at 10:43:53AM +0100, L Melville wrote:

 Is it possible to sort a class array using array multisort, I have two items
 in each class that I wish to sort by, one is a text and the other is the
 first item in an array within within each class. i.e.;-
 
 $class[$index]-text;
 $class[$index]-array[0];
 
 how can I do this?

I'd use usort() instead.  http://www.php.net/manual/en/function.usort.php

The manual page has a couple examples for sorting objects by their member
variables.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Why I wish PHP had Python's exception handling....

2001-10-21 Thread Matt McClanahan

On Mon, Oct 22, 2001 at 02:57:44PM +1000, Brian White wrote:

Preface to these ramblings: Exception handling is planned for the next
version of the Zend engine.  For details, see

http://www.zend.com/zend/future.php

 The nasty thing then comes in that if any task fails, I have to stop. So I
 create a convention that every task returns 1 for success, 0 for
 failure. Tasks can also be nested. So this gives me a structure like
 this:
 
  if ( ! GrabLock() )
  return 0;
 
  $retval = 0;
  switch(0){ default:
 
  if ( ! RunTask1() )
  break;
 
  if ( ! RunTask2() )
  break;
 
  if ( ! RunTask3() )
  break;
 
  $retval = 1;
  }
 
  ReleaseLock();
  return $retval;
 
 This works, but it is cumbersome, you have to be VERY careful and there are
 other complications in terms of reporting sensible error messages when
 tasks are shared.

This is probably no less messy, but it does allow you to handle an
arbitrary number of steps, possibly with arguments, without having to
add another if check as you're doing above.  This also lets you know
easilly which step failed:

?

function first($a)  { if ($a) return true; else return false; }
function second($a) { if ($a) return true; else return false; }
function third($a)  { if ($a) return true; else return false; }

function GrabLock() { echo Grabbing.\n; return true; }
function ReleaseLock() { echo Releasing.\n; return true; }

$ret = true;
$funcs = Array('first','second','third');
$args = Array(1,1,1);   // Change one to zero to trigger a failure

if (!GrabLock())
return 0;   

while ($ret = $funcs[0]($args[0]))
{
array_shift($funcs);
array_shift($args); 
if (!count($funcs)) break;
}
 
ReleaseLock();

if (count($funcs)) echo Failed at $funcs[0].\n;

?

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php / apache

2001-06-30 Thread Matt McClanahan

On Fri, Jun 29, 2001 at 03:54:13PM +, Pétur Björn Thorsteinsson wrote:

 can anyone tell me how to configure a php script so that it can only be
 accessed by other scripts and not directly by typing its url in the
 webrowser?

Just move the script outside the web root.  Browsers can't directly
access files that aren't inside web-visible directories.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Output an image stream?

2001-06-23 Thread Matt McClanahan

On Sat, Jun 23, 2001 at 04:50:48PM -0700, Todd Cary wrote:

 I have created a barcode as an image stream ($im).  Now, I want to
 output it in HTML to a particular row and column on a form.  Do I have
 to save it as a file so that I can use the routine img src=xx or is
 there a way to directly output the stream?

img src=script_that_outputs_barcode_image.php

Make sure to send a Content-type header before sending the image data:

Header('Content-type: image/png');
ImagePNG($im);

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] OT PHP Manuals

2001-05-22 Thread Matt McClanahan

On Wed, May 23, 2001 at 10:37:06AM +0930, Joseph Blythe wrote:

 Hey all,
 
 Just was wondering if anyone knew what was used to make the php manuals 
 in the windows help format (.chm), I really like them :-)

The manual is availabe in chm in several languages.

http://www.php.net/docs.php

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] dynamically naming arrays

2001-05-17 Thread Matt McClanahan

On Thu, May 17, 2001 at 01:27:52PM -0400, Matthew Luchak wrote:

 any hints on dynamically naming arrays?
 
 ie:
 
 $stuff= explode (!, $contents);
 
 //$stuff[3] is foo
 
 $stuff[3]=explode(,$stuff[4]);

${$stuff[3]} = '...';

http://www.php.net/manual/en/language.variables.variable.php

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] IMLIB

2001-04-25 Thread Matt McClanahan

On Wed, Apr 25, 2001 at 03:34:18PM -0400, Charles wrote:

 Hello,
 
 Somebody know how to make IMLIB library compile into php ?
 i tried --with, --enable, but doesn't work !

Check to see that it actually got added to the source properly with:

./configure --help|grep imlib

If it isn't there, read the side-note below.

Obligatory quote from the INSTALL file:

Built-in Extension Installation
---
To build php_imlib into PHP, extract the extension into the ext/
subdirectory of the PHP source tree, run buildconf, and recompile.

tar -C /path/to/php_src/ext -zxvf php_imlib-0.3.tgz
cd /path/to/php_src
./buildconf
./configure --with-imlib[=/path/to/Imlib2] [other args]
make
make install

The side-note that I keep forgetting to add to the documentation: It
may be necessary to do 'touch ./config.m4' in ext/imlib before running
buildconf.  Otherwise buildconf may not add php_imlib to the available
extensions.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Functions.

2001-04-24 Thread Matt McClanahan

On Tue, Apr 24, 2001 at 03:06:40PM +0200, Anders Clerwall wrote:

 Hi,
 Is there a tutorial of some sort on how I add function sets to PHP4?
 I've searched the net for more info about this other than what the PHP4.x
 manual says, and I saw some reference to freshmeat, but I couldn't find
 that.
 Any help appreciated, thanks!

If you mean writing functions in PHP, that would be in the manual:

http://www.php.net/manual/en/functions.php

If you mean writing built-in functions (at the same level of
mysql_connect, array_reverse, etc) then you want

http://www.zend.com/zend/api.php

Or the README.SELF-CONTAINED-EXTENSIONS which is included in the PHP
source.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Graphic process within PHP

2001-04-18 Thread Matt McClanahan

On Wed, Apr 18, 2001 at 02:37:00PM -, SED wrote:

 Hi,
 
 Recently I noticed e-mails on this list about Imlib2 and GD2 extensions
 which I was not aware of. So I started to wander if there are more
 extensions working with PHP which allows graphic process (the only one I
 knew was GD). Is it? If so, is it possible to use these extensions on all
 platforms (which PHP supports) and with all web servers?

I'm not aware of other graphics-related extensions, but two other common
ways of processing images with PHP are to shell out to ImageMagick or
NetPBM.  As you look through the various PHP code repositories out
there, you'll probably notice a fair number of scripts that use one of
these two apps.

As for portability, PHP extensions can require certain platforms to
work.  Unfortunately Imlib2 falls into this category, because it
doesn't (And almost certainly never will) support Windows.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Do any of you provide hosting?

2001-04-12 Thread Matt McClanahan

On Thu, Apr 12, 2001 at 10:34:26AM -0400, Chris Anderson wrote:

 Someone who can host my domain (I own the domain already)
 Can provide MySQL and PHP. Both up-to-date.
 Can give around 60 meg of space (ballpark, less should be fine)
 Also a way to set up subdomains without needing to go through the admin (some hosts 
can do his). But this isn't necessary.
 Can anyone help with that?

Handy PHP hosting directory:

http://hosts.php.net

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Creating Arrays

2001-04-11 Thread Matt McClanahan

On Wed, Apr 11, 2001 at 03:55:38PM -0600, Ashley M. Kirchner wrote:

 "Rodney J. Woodruff" wrote:
 
  http://www.php.net/manual/en/function.msql-fetch-array.php

(snip)

 I need that result into the following:
 $items = array(0 = "Undefined", 1 = "Work", 2 = "Personal");

Here's a hint.

$arr[$key] = $value;

Define $key and $value from the row data that mysql_fetch_array
gives you.

 Reason is, I pass that $items variable to the following function:
 
   function MakeSelect($items, $selected) {
 $str = "";
 while(list($value, $name) = each($items)) {
   $str .= "option value=\"$value\"" . ($value != $selected ? \
   "" : " selected") . "$name\n";
 }
 return $str;
   }

For the record, you're thinking about list() backwards.  In your
function, the array keys will go into $value, and the values will go
into $name.

HTH,
Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] submitting to a remote form

2001-04-08 Thread Matt McClanahan

On Sun, Apr 08, 2001 at 12:31:35AM -0500, Joseph Bannon wrote:

  You can use fopen/fread to open the script remotely.
  
  Just append the query string onto the url something like this:
  
  www.example.com/example.php?var1=var
  
  ...and example.php will have $var1 with the value "var". That's basically
  like using GET on a form.
  
  I believe that's what you wanted to do?
 
 I have to use POST on the form. I wish I could use GET.

For that, you'll need to open a socket.  The function to do this is
usually called PostToHost, and I don't know why it isn't in even the
annoted manual page for fsockopen.  A quick google search should turn
up copies of it in all the PHP mailing list archives.  But, here's the
version that I use (It's been modified to support both GET and POST):

function sendToHost($host,$method,$path,$data,$useragent=0)
{
   // Supply a default method of GET if the one passed was empty
   if (empty($method))
  $method = 'GET';
   $method = strtoupper($method);
   $fp = fsockopen($host,80);
   if ($method == 'GET')
  $path .= '?' . $data;
   fputs($fp, "$method $path HTTP/1.1\n");
   fputs($fp, "Host: $host\n");
   fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
   fputs($fp, "Content-length: " . strlen($data) . "\n");
   if ($useragent)
  fputs($fp, "User-Agent: MSIE\n");
   fputs($fp, "Connection: close\n\n");
   if ($method == 'POST')
  fputs($fp, $data);

   while (!feof($fp))
  $buf .= fgets($fp,128);
   fclose($fp);
   return $buf;
}

$data should be the variables of the query string, minus the question
mark.  That is, var1=value1var2=value2, etc.  The function doesn't
encode it, so you'll need to do that.

HTH,
Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How can I make this smaller

2001-04-05 Thread Matt McClanahan

On Thu, Apr 05, 2001 at 01:40:54PM -0700, Richard Kurth wrote:

 Is there another way to write this I would like to make it smaller
 also How would I write it so it is a function and I would be able to use all
 the data throughout the  whole program every time I try the rest of the
 program does not see the data

  $domain=$data[0];
  $tld=$data[1];
   $firstname=$data[2];
  $lastname=$data[3];
  $userid=$data[4];
  $passw=$data[5];this part  would like to make smaller
   $email=$data[6];
  $package=$data[7];
  $frontpage=$data[8];
  $mysql=$data[9];
  $userdatabase=$data[10];
  $newuser =$data[11];
 $newuserpass =$data[12];

Use list()

list($domain,$tld,$firstname,$lastname,$userid,.) = $data;

If you want to put it in a function, declare them all globals beforehand.

function myfunc()
{
   global $domain,$tld,$firstname,$lastname,$userid...;

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] phpinfo unneeded

2001-03-30 Thread Matt McClanahan

On Fri, Mar 30, 2001 at 04:32:40PM +0700, juang wrote:

 HI all,
 how to compile php without function phpinfo enalbe. so if user call
 phpinfo() it would be false/error.  i would like to build a free web
 server with php but i don't like if the user know what are the tools
 in my server 'couse it's a free server.
 
 is it possible or it's just a stupid question?

I imagine it's possible, but out of curiousity, what harm is there in
allowing phpinfo() to be run?  It presents the PHP configuration
settings, many of which may be important to your users when developing
their apps (Is magic_quotes on?  Is '.' in the include path?  Is
register_globals on?) and info on which PHP modules are available. 
(Which version, if any, of GD, XML, etc)

I suppose it may be undesireable to reveal some of the environment
variables (PATH, perhaps), but the solution there isn't to disable
phpinfo(), it's to run the web server from a specifically tailored
environment.

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PAM authentification

2001-03-22 Thread Matt McClanahan

On Thu, Mar 22, 2001 at 10:37:41AM +0100, Daniel Svensson, Coretrek wrote:

 Hi there!
 
 I wonder if there is someone out there who can help me out with some
 advices regarding authentification with PAM (Pluggable Authentication
 Modules)
 using PHP.

Try php_pam.

http://freshmeat.net/projects/php_pam/

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] parsing html / xml (more)

2001-03-07 Thread Matt McClanahan

On Wed, Mar 07, 2001 at 10:07:37AM -0700, Nathaniel Hekman wrote:

 Here's another case that shows up often in html, but is illegal in xml, that
 I would need to parse:  meta tags, p tags, hr tags, and other
 "singletons".
 
   HEAD
   META HTTP-EQUIV="Content-Type" CONTENT="text/html"
   /HEAD
 
 xml_parse would give an error, because the HEAD block is being closed with a
 still-open META "block".

Within the context of parsing HTML as XML, there's not really much that
can be done.  I suppose you could pre-proces the HTML to make it
XML-complaitn, but that's probably more trouble than I would go to.

You're not going to find an XML parser that allows for most HTML,
because if such a parser did exist, it would be a broken XML parser. :)
The only kind of HTML you can reliably parse with XML parsers is the
XHTML variety (Which is simply HTML4, made XML-compliant)

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] image orientation?

2001-02-22 Thread Matt McClanahan

On Wed, Feb 21, 2001 at 05:48:50PM -0500, Jaxon wrote:

 Is there any way to take an image from the filesystem, say a .jpg or .png,
 and display it in a different orientation?  e.g. 20 degrees to the right?

Yes, php_imlib can do image rotations.

http://mmcc.cx/php_imlib/
http://mmcc.cx/php_imlib/documentation.php#imlib_create_rotated_image

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] imagecolorallocate / imagesetpixel / palette size?

2001-02-12 Thread Matt McClanahan

On Sun, Feb 11, 2001 at 01:40:11AM -0700, Dan Harrington wrote:

(snip)

 Its like the "palette" only holds 256 pixels or something, what's
 the deal with that?
 
 Anyone experienced this before?  I've looked through the GD library
 documentation
 at boutell.com, i've looked through php.net, and every search engine on the
 internet, and I can't seem to find out what is going on.

You're right, the palette only holds 256 colors.  The reason for this
is that GD was originally written for GIFs only.  JPEGs were added on
later, and then PNGs were put in as a drop-in replacement for GIFs
(Patent issues).  But the library was never extended to support high
color.

If you're using Unix, one alternative could be php_imlib.

http://mmcc.cx/php_imlib/

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] returning multiple variables from a function?

2001-02-12 Thread Matt McClanahan

On Mon, Feb 12, 2001 at 09:13:09PM -, James, Yz wrote:

 What if I wanted to "return" more than one variable from the function?  And
 how would I assign it a name?  Like the actual variable, or is that just not
 possible?
 
 I've tried
 return $var1,$var2;

You're on the right track.

return Array($var1,$var2);

And when you call the function,

list($ret1,$ret2) = myfunc();  ..or..
$ret = myfunc();  ..and use $ret[0] and $ret[1]

Another option is to pass variables by reference.  For example, say you had
a function that returned true or false, but you wanted it to return an error
message with that false.  Something like this:

function test($condition,$errormsg)
{
if ($condition == $rightanswer)
{
return true;
}
else
{
$errormsg = "The condition wasn't the right answer.";
return false;
}
}

Then to check it,

if (!test('foo',$error))
echo "Failed test!brError: $errormsgbr";

HTH,
Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] To The Hacker: CodeBoy

2001-02-11 Thread Matt McClanahan

On Sun, Feb 11, 2001 at 03:51:33PM -0800, rswfire wrote:

 I am not a hacker.  I do not try to hack and
 don't know how people go about doing it.  I'm a
 programmer.  To me, those two are very different.
  A programmer is constructive.  A programmer
 likes to take a problem and turn it into a
 solution.  A programmer is creative.  A
 programmer has respect for other people's domains
 and boundaries.  A hacker is destructuve.  A
 hacker takes a solution and turns it into a
 problem.  A hacker has no respect for other
 people's domain or boundaries.  As you have
 clearly done.  You have overstepped a boundary
 with me.

I feel compelled to repost this, because you seem to have the right
principles in mind, but the wrong term.  I realize it's usually viewed
as useless nitpicking to point this out, but it seems appropriate in
this context to stress the misconception of what a hacker is.  So if
you have a free moment, please do read over some of the well-written
explanations about where the word comes from, and what it stands for.

http://www.tuxedo.org/~esr/jargon/html/entry/hacker.html
http://www.tuxedo.org/~esr/jargon/html/entry/hacker-ethic.html
http://www.tuxedo.org/~esr/jargon/html/entry/cracker.html

Your description of a programmer does fit well with who a hacker really
is, so I'm sure you would appreciate what they have to say.  There is,
of course, a great wealth of writing on the topic, the links above are
simply succinct definitions.  For more in depth discussion, I'd suggest
browsing the bibliography included in the jargon file, which includes
excellent works, both fiction and non-fiction, relating to the subject.

http://www.tuxedo.org/~esr/jargon/html/Bibliography.html

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Parsing XML the Sequel :)

2001-02-10 Thread Matt McClanahan

On Sat, Feb 10, 2001 at 07:37:32PM +0100, Steve Haemelinck wrote:

 The page I want to parse is:
 
 http://213.224.136.110:8080/test.xml
 
 And this is my code:
 
 ?php
 
 //Define Opening Tags of XML
 $open_tags = array(
 'STORY' = 'nasdaqamex-dot-com',
 'STOCK_NAME' = 'issue-name',
 'LAST_SALE' = 'last-sale-price',
 'PREVIOUS_CLOSE' = 'previous-close-price',
 'NET_CHANGE_PCT' = 'net-change-pct',
 'STOCK_URL' = 'issuer-web-site-url');

(snip)

 // handles the attributes for opening tags
 // $attrs is a multidimensional array keyed by attribute
 // name and having the value of that attribute
 function startElement($parser, $name, $attrs=''){
 global $open_tags, $temp, $current_tag;
 
 $current_tag = $name;
 if ($format = $open_tags[$name]){
 switch($name){
 case 'STORY':
 echo 'New Story: ';
 break;
 default:
 break;
 }
 }
 }

This probably isn't doing what you think it's doing.  When the parser
hits a new element tag, it will pass the parser object, element name,
and its attributes to startElement().  $name will be the name of the
element.  Equity-quote, issue-name, etc.  So when you go to look for
$open_tags[$name], you won't find anything because the array is keyed
to STORY, STOCK_NAME, etc.  It looks like you're expecting the array to
be backwards.  Switching the keys/values and removing the , /,  would
be enough to make it work.

HTH,
Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] A php-xml mailing list?

2001-02-09 Thread Matt McClanahan

On Fri, Feb 09, 2001 at 05:37:04PM -0700, Michael Dearman wrote:

 I think it would be helpful.
 What do you folks think?

You'd think it would be a popular thing, but the one O'Reilly hosts
is more or less silent.

http://www.oreillynet.com/pub/a/php/php-xml-ml.html

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] To The Hacker: CodeBoy

2001-02-08 Thread Matt McClanahan

On Thu, Feb 08, 2001 at 03:19:52PM -0800, rswfire wrote:

 Whatever, James.
 
 The hackers name is Jonathan Sharp.  He is a
 regular member of this mailing list.  I do
 believe that people here would like to know they
 have a hacker on their hands, don't you think? 

http://www.tuxedo.org/~esr/jargon/html/entry/hacker.html
http://www.tuxedo.org/~esr/jargon/html/entry/cracker.html

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multidemention array question(s)

2001-01-19 Thread Matt McClanahan

On Fri, 19 Jan 2001, Michael Zornek wrote:

 ok so i set up a multidimensional array with the following code:
 
 ?PHP
 // departments.inc
 //
 // This file defines the switches. All the forms, and return displays are
 // based on this table (multidimential array). The first index is the 
 switch number,
 // then each department has three proporties.
 // 1, Can the website use this depatement?
 // 2, Can this department be used in the admin pages?
 // 3, Its name.

 $departments = array ("s1" = array("On", "On", "The Seybold Report"),
 "s2" = array("On", "On", "Publishing Systems"),
 "s3" = array("On", "On", "Internet Publishing"),
 "s4" = array("On", "On", "The Bulletin"),
 "s5" = array("Off", "Off", ""),

(snip)

 Now I am creating forms and tables and need to retrieve this info I'd 
 like to say something like:
 
 if switch s23 is availbe to the admin pages do this, else do that.

if ($departments['s23'][1] == 'On')
// This department can be used in the admin pages
else
// Not

 echo switch 34's name

echo $departments['s34'][2]

If you wanted to make the code a bit more intuitive, you could reconstruct
the array to have string keys:

$departments = Array(
's1' = Array('live' = 1, 'admin' = 1, 'name' = "Dept's Name"),
's2' = Array('live' = 0, 'admin' = 1, 'name' = ''),
and so on
);

At this point, you can simply check if a department is live or admin
available with a boolean, and later on people who look at the code won't
have to wonder what the array field $departments['s23'][1] contains.

if ($departments['s23']['admin'])
// This department can be used in the admin pages
else
// Not

echo $departments['s34']['name']

Matt



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Classes question.

2001-01-19 Thread Matt McClanahan

On Fri, 19 Jan 2001, James McLaughlin wrote:

 I get an error when doing this
 
 class Something
 {
 var $something;
 
 function Something($this-something)
 {
 More somethings
 }
 
 }
 
 The error tells me that I need a ")" in the line the function call is
 in.  If I take the "$this-something" it will parse fine.  Can you not
 do this?

No, you can't do this.  Functions within the class can automatically get
to class variables with $this-something, so passing them as parameters
would be somewhat redundant.

class Something
{
   var $something;

   function Something()
   {
  $this-something = "More somethings";
   }
}

Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] graphic problem...

2001-01-13 Thread Matt McClanahan

Georg,

If you're running Apache/Unix, php_imlib would allow you to manipulate
png's with more than 256 colors.

http://mmcc.cx/php_imlib/

Matt

On Sat, 13 Jan 2001, Johan Holst Nielsen wrote:

 GD library only support PNG 256 color your PNG have more colors!
 
 With Best Regards
 
 Johan
 
 
 - Original Message - 
 From: "Georg Buschbeck" [EMAIL PROTECTED]
 To: "PHP-Liste (general)" [EMAIL PROTECTED]
 Sent: Saturday, January 13, 2001 7:10 PM
 Subject: [PHP] graphic problem... 
 
 
 i have a problem with the quality of the output picture...
 you can have a look yourself..
 http://tooltime.dyndns.org/~georg/test/
 this is the code that creates the pic...:
 ?PHP
 header("Content-type: image/png"); 
 $src_img=ImageCreateFromPNG("tool.png"); 
 ImagePNG($src_img); 
 ?
 
 so as you can see the pictures isn't modified.
 
 my system:
 linux-box: 2.2.18
 i the jpeg/png/gd/tiff libaries installed
 
 thankx
 georg
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re-engineering print()

2001-01-10 Thread Matt McClanahan

On Wed, 10 Jan 2001, Kristofer Widholm wrote:

 Basically, I'm wondering if there is a way to redirect print and echo 
 output from PHP to a variable instead of directly to a browser or 
 file stream. What I'm trying to do is create code that can generate 
 an HTML page to a variable that I can manipulate and then later store 
 in a database.

http://www.php.net/manual/ref.outcontrol.php

Specifically, ob_get_contents().

Start an output buffer, include your files, get the contents, and
ob_ed_clean.  Ought to do the trick.

Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]