Re: [PHP] goto - My comments

2010-12-18 Thread Thomas Anderson
On Sat, Dec 18, 2010 at 11:44 PM, Robert Cummings rob...@interjinn.com wrote:
 On 10-12-19 12:17 AM, Ethan Rosenberg wrote:

 Dear List -

 Thanks to all for your EXCELLENT comments.  I definitly agree that
 goto is a command to be avoided at all costs.

 Closed-minded drivel (or you're buttering up the popular opinion crowd). A
 better approach is that goto should be used with caution.

 As for doing your homework for you... ummm no thanks. You should take the
 time to do the exercise so you gain the benefit of experience.

I would have thought school would have been out on account of Christmas and all.

In any event, here's my rewrite:

switch (true)
{
case isset($_POST['Site'])  trim($_POST['Site']) != '':
$sql1 = $sql1 . site = '$ste';
break;
case isset($_POST['MedRec']) trim($_POST['MedRe']) != '':
$sql1 = $sql1 . MedRec = '$req';
break;
// ...
default:
if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
if ($_REQUEST[Sex] == 0)
$sex = 'Male';
else
$sex = 'Female';

$sql1 = $sql1 .   = '$sex';
$sexdone = 1;
}

if(isset($_POST['Hx']) trim($_POST['Hx']) != '')
{
$sql1 = $sql1 . Hx  = '$hx';
$done = 1;
}
}

You could also do an if / else if / else if / ... / else.

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



Re: [PHP] How to upload via SFTP with allow_url_open disabled?

2010-07-31 Thread Thomas Anderson
You might have better luck with phpseclib's Net_SFTP, which uses fsockopen:

http://phpseclib.sourceforge.net/documentation/net.html#net_sftp_example

Good luck!

On Thu, Jul 29, 2010 at 12:13 PM, Scott Teresi scot...@teresi.us wrote:
 I'm attempting to send a file over SFTP in PHP, but all the examples I find
 online do something like this:

   $stream = @fopen(ssh2.sftp://xx;, 'w');
   @fwrite($stream, $data_to_send)

 This requires allow_url_fopen to be enabled on the server, to get a stream
 for the remote file.

 I maintain the server but would like to keep allow_url_fopen disabled. If
 I do that, how can I send a file over SFTP?

 Thanks for any help people can provide!!

 Scott Teresi



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



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



[PHP] Re: Howto send command over ssh using sockets

2010-04-07 Thread Thomas Anderson
phpseclib does SSH without PECL extension and only with fsockopen:

http://phpseclib.sourceforge.net/

On Sun Apr  4 21:09:54 2010, Hans_Åhlin wrote:
 Instead of ssh, you could use telnet to connect to the Cisco router
 (which incidentally runs on port 23, but is likely to be disabled on
 the cisco router, unless you have a pre-SSH capable IOS running on it
 (like my old cisco crap :( ) ), because i strongly doubt you have
 written or are willing to write your own encryption libraries for this
 project, you might also want to read IETF RFC 854
 [http://tools.ietf.org/html/rfc854] about the telnet protocol, as you
 are writing your own client, and not using a pre-made one, judging
 from your script.
 Or if you do not like the idea of sending clear-text passwords to the
 router, you might want to learn about proc_open() (or popen()) and use
 the native ssh utility that most likely is present on the server,
 taking great care to READ THE MANUAL for the ssh command, because you
 most likely do _not_ want it to spit out ANSI-escapes to you script.

 Kind regards from
 Johan Lidström
 Örnsköldsvik, Sweden
 irc://irc.freenode.net/Dr_Kao
 frozendude+php...@gmail.com

 P.S. currently borrowing a friends account.

 2010/4/5 Radek Krejča radek.kre...@starnet.cz:
 Hello,

 I am trying send command to remote host over ssh with sockets. But I need to 
 set up username/password. I am trying to modify this script (from 
 www.php.net - function fsockopen), but I dont know, where set 
 username/password because I got this message:
 Bad protocol version identification 'password' from ip

 Library ssh2 is not currentu userfull for me, because I am not admin of 
 server.

 Thank you
 Radek


 ?php
 /
 * Author: Richard Lajaunie
 * Mail : richard.lajau...@cote-azur.cci.fr
 *
 * subject : this script retreive all mac-addresses on all ports
 * of a Cisco 3548 Switch by a telnet connection
 *
 * base on the script by: xbensemhoun at t-systems dot fr on the same page
 **/

 if ( array_key_exists(1, $argv) ){
   $cfgServer = $argv[1];
 }else{
   echo ex: 'php test.php 10.0.0.0' \n;
   exit;
 }

 $cfgPort    = 23;                //port, 22 if SSH
 $cfgTimeOut = 10;

 $usenet = fsockopen($cfgServer, $cfgPort, $errno, $errstr), $cfgTimeOut);

 if(!$usenet){
       echo Connexion failed\n;
       exit();
 }else{
       echo Connected\n;
       fputs ($usenet, password\r\n);
       fputs ($usenet, en\r\n);
       fputs ($usenet, password\r\n);
       fputs ($usenet, sh mac-address-table\r\n);
       fputs ($usenet,  ); // this space bar is this for long output

       // this skip non essential text
       $j = 0;
       while ($j16){
       fgets($usenet, 128);
       $j++;
       }
   stream_set_timeout($usenet, 2); // set the timeout for the fgets
   $j = 0;
       while (!feof($usenet)){
       $ret = fgets($usenet, 128);
       $ret = str_replace(\r, '', $ret);
       $ret = str_replace(\n, , $ret);
       if  (ereg(FastEthernet, $ret)){
           echo $ret \n;
       }
       if (ereg('--More--', $ret) ){
           fputs ($usenet,  ); // for following page
       }
       $info = stream_get_meta_data($usenet);
       if ($info['timed_out']) {
           $j++;
       }
       if ($j 2){
           fputs ($usenet, lo);
           break;
       }
   }
 }
 echo End.\r\n;
 ?

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




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



[PHP] Mailing List

2001-03-11 Thread Thomas Anderson

Ok, I've tried time and time again to unsubscribe from php.net's mailing
list unisubscribe instructions but it doesn't work. So how do I get off the
list?


__
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup

-- 
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] php4 auto download problem

2001-01-19 Thread Thomas Anderson

I installed php4 and supposidly configured it with apache and mysql.

When I go to a page with php in it it doesn't load it. Instead it
automatically prompts me to download it. I know this has to be an error on
my part and a common overlooked error on installation.

I did edit httpd.conf with the:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

lines and since it prompts me to download instead of loading the page php
has to be recognized by the server. So what did I overlook that doesn't load
the .php file immidiately?


Any help would be appreciated.

Thanks,

-Jesse


__
FREE Personalized Email at Mail.com
Sign up at http://www.mail.com/?sr=signup

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