Re: [PHP] IF or SWITCH

2006-04-06 Thread Oli Howson



The main perk to using switch over if
statements is speed


speed of development and ease of reading. Otherwise, it all ends up  
the same under the bonnet afaik


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



Re: [PHP] Curl With Certificates As Strings

2006-02-09 Thread Oli Howson



curl_setopt($Curl, CURLOPT_SSLCERT, /tmp/cert.pem);


Never used it, but possibly...
curl_setopt($Curl, CURLOPT_SSLCERT, 
/some/php/file/to/echo/cert/from/db.php);


just a thought :)

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



Re: [PHP] socket_read

2006-02-09 Thread Oli Howson



I want to read the content from a socket that is sending XML.


IIRC, you just read in a loop while there's still stuff to read.

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



Re: [PHP] How to output multiple tables nicely(!) from PHP in Excel format?

2006-02-08 Thread Oli Howson

The example given outputs to two tabs,  sheeta and sheetb

Quoting Olaf Greve [EMAIL PROTECTED]:


Hi all,

I've written a ArrayToExcel(XML) class, you're welcome to use if you 
wish. May need a bit of tweaking to get the colspan working (I 
haven't touched it in quite a while). But the process itself I think 
is rather nice :)


 http://projects.londonis.co.uk/arraytoexcel/

Thanks for your answer and the offer. I checked it, but I somehow do 
not see multiple tabs appear (neitehr in the direct .xls output, nor 
in the two XML versions)?!?


Meanwhile I've been playing around somewhat more with my own code 
(which in this case has the advantage that I have to do little 
rewrites in the code in order to use solely one script for both an 
HTML view as well as an Excel view), and most of it looks 
satifactorily enough. The only (?) nasty thing left is that the 
column widths are always set to that of the widest column, so I'll 
need to figure out a work around for that (e.g. by using different 
table headers for the .XLS version).


I would still be very interested in a way to get the 3 tables sent to 
different tabs though, but I'm not certain the way I do it can take 
care of that.


If anyone can tell me how to go about this, it would be greatly 
appreciated...


Cheers!
Olafo





--
/'''\
| Oli Howson, BSc, MBCS |
|  www.londonis.co.uk   |
| Internet Development  |
\,,,/

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



Re: [PHP] system('bell'); ?

2006-02-06 Thread Oli Howson


each of the terminals could then use a web based POS interface but 
there was only a

single cash drawer.


It would also be possible to have each 'till' running a copy of apache 
server, and communicating with a central database server. I can't for 
the life of me think of any way the client could open the drawer 
otherwise.


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



[PHP] Till Drawers

2006-02-03 Thread Oli Howson
I'm interested in the possibility of connecting a computer running A 
PHP server to a till drawer and have the server able to open the 
drawer. Anyone know how this would work?


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



RE: [PHP] Someone please help me with this PHP script.

2005-12-18 Thread Oli Howson
The ? And : are a shortcut for ifelse, that could also be written

If (isset($_GET['page'])
{
 $page = $_GET['page'];
}
else
{
 $page = null;
}

The shortcut is a lot quicker to write (if you understand it) but not as
readable.

isset just returns true if a variable has been set, false if not :)

hth

-Original Message-
From: Erik Johnson [mailto:[EMAIL PROTECTED] 
Sent: 18 December 2005 15:42
To: php-general@lists.php.net
Subject: Re: [PHP] Someone please help me with this PHP script.

I was wondering.. how exactly does the isset function work?  I saw that
Robert Cummings wrote:

$page = isset( $_GET['page'] ) ? $_GET['page'] : null;

What exactly does that mean?

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



Re: [PHP] upload path

2005-12-16 Thread Oli Howson
Allow them to browse the server (up to a limited level), saving the 
current selected path within the $_GET string.


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



Re: [PHP] Can anyone recommend a hosting company

2005-12-16 Thread Oli Howson

I've been using www.wehostwebpages.com for about 4 years, been good to me :)


Can anyone recommend a fair priced, reliable hosting company that would best
meet my needs as follows:


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



Re: [PHP] MIME E-mail message

2005-12-15 Thread Oli Howson
Than what? The imap extension is faster and has parsing functionality 
built in.
True, but the parsing is to be done at a completely different time, and 
then imap extension can't be that much faster, when you consider that 
my method is doing very little processing, and basically getting the 
messages as fast as they can download!



Also there's a PEAR Net_POP3 library if you insist on using sockets 
which handles lots of menial tasks for you.

But where's the fun in that?

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



Re: [PHP] MIME E-mail message

2005-12-15 Thread Oli Howson
I would imagine it would be significantly faster, and you must be 
doing some processing to extract the email body.
I'll run some tests (when I can be bothered!) and post the results ;) 
Not sure exactly how accurate they'll be though, cos the IMAP routines 
won't let you retrieve just the whole message, which is what I wanted 
to do!


The fun is going to the pub earlier because you haven't got as much 
code to write, nor as many gotchas to resolve since someone (me) has 
written the code for you.
If this was a commercial venture and I was doing it as a job, I'd 
concur. As it is, I'm writing code 'cos I enjoy it, so getting to 
finish it quicker isn't really an issue, whereas knowing you've done 
something yourself is an issue, for me at least.


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



[PHP] MIME E-mail message

2005-12-14 Thread Oli Howson
I'm working on a private webmail (and other) system, and am struggling a
little with MIME mails. I've got a script to save all the attachments, but
the thing I can't figure out is how I decide which part is the main email
message itself (and hence which to display). 
 
Oh and cheers for the info someone gave me the other day, it inspired me to
just connect to the pop3 server using a raw socket, SO much easier!!!
 
Cheers
 
Oli


RE: [PHP] Re: MIME E-mail message

2005-12-14 Thread Oli Howson
 Oh and cheers for the info someone gave me the other day, it inspired 
 me to just connect to the pop3 server using a raw socket, SO much
easier!!!
share the code please, I'm interested :)

Ok... It's a bit rough and ready, never expected anyone else to want to look
at this (at least not yet!)

  $host = 'mail.myserver.com';
  $port = '110';
  $user = '[EMAIL PROTECTED]';
  $pass = 'itsasecret';
  
  $socket = fsockopen($host,$port);
  
  if (!$socket)
  {
   echo Couldn't connect!;
  }
  else
  {
   //is it connected?
   $res=getinfo($socket);
   echo Testing connection... .$res;
   echo Send user...;
   fputs($socket,USER $user\n);
   $res=getinfo($socket);
   echo $res;
   echo Send pass...;
   fputs($socket,PASS $pass\n);
   $res=getinfo($socket);
   echo $res;
   echo Let's get the number of messages...;
   fputs($socket,STAT\n);
   $res=getinfo($socket);
   $res = split(' ',$res);
   $res = $res[1];
   echo trim($res). messages\n;
   if (trim($res)  0)
   {
echo Let's get the array of messages...\n;
fputs($socket,LIST\n);
$res=getinfo($socket);//gets rid of the OK
$res=getinfo($socket);
$res = split(\n,$res);
//print_r($res);

foreach ($res as $key = $value)
{ 
 if ((trim($value) != '.') and (trim($value != )))
 {
  $value = split( ,$value);
  $mids[] = $value[0];
 }
}
//print_r($mids);

echo Now we have a list of message IDs, we'll extract each message\nand
save under it's MID\n;
foreach ($mids as $key = $value)
{ 
 echo Requesting $value\n;
 fputs($socket,RETR $value\n);
 $res=getinfo($socket);//gets rid of the OK
 $res=getinfo($socket);
 $res = split(\n,$res);
 $cont = true;
 foreach ($res as $key2 = $value2)
 {
  if ((trim($value) != '.') and ($cont == true))
  {
   $msg[] = $value2;
  }
  else
  {
   $cont = false;
  }
 }
 $res = join(\n,$res);
 echo Saving $value\n;
 file_put_contents('my/save/folder/'.$value.'.txt',$res);
}
   }
   echo Finally, let's quit...;
   fputs($socket,QUIT\n);
   $res=getinfo($socket);
   echo $res;
  }
  
  
  function getinfo($socket)
  {
   $buff = '';
   $continue = true;
   while (!feof($socket) and ($continue==true)) 
   {
$buffer = fgets($socket);   
if (substr($buffer,0,4) == '-ERR')
{
 $res = 'error';
 $continue = false;
}
if (substr($buffer,0,3) == '+OK')
{
 $res = 'ok';
 $continue = false;
}
if (trim($buffer) == '.')
{
 $res = 'end';
 $continue = false;
}
$buff .= $buffer;
   }
   return $buff;
  }

This was designed to run as a CLI app, may need tweaking to run through
http. Not fully tested, but does what I want!

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



[PHP] Problems downloading e-mail

2005-12-13 Thread Oli Howson
I've used the IMAP functions to connect to my pop3 server. I want to 
download the emails. I can fetch headers, or fetch the body, but I 
don't seem to be able to download the entire e-mail as one raw file. 
This is so I can pass it to the PEAR mail mime class for parsing, as 
well as for storage. Anyone got any suggestions for this?


Oli

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