[PHP] imagecopyresize???????

2010-04-05 Thread Karl DeSaulniers

Hello List,
I am new here, and I am hoping this will be a quick and easy for  
someone to help me with.
I am trying to create an upload form that lets a user upload a  
product photo to the server.
In the process of this upload, I want to take the file they are  
uploading and create two images to put on the server.

Both are specific sizes. A large image and a thumbnail.
I then want to throw away the file they uploaded.

My question is what is the proper way to do the uploading/resizing/ 
destroying?

I have been toying with imagecopyresize, but it never works.
I think I just have parameters out of order or something.

Also, I would like to put a copyright on the side.
I have been able to use imagestringup to do that,
but it covers the image I'm placing it on with
a transparent background and deletes the image.

How do you duplicate an image with transparency?
Or keep the transparency an image already has?
Most grateful for any help, pointers, tuts.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] Updating HTML on page

2010-04-05 Thread Paul M Foster
On Mon, Apr 05, 2010 at 09:29:26PM -0600, Ashley M. Kirchner wrote:

> Hrm, been looking at it for a while now and I can feel a headache coming up.
> I think I need to have one PHP script that does the processing, and another
> that the user pulls up in their browser.  That one "pings" the processor
> every so often to get updated data.  Yes?
> 
> Am I way off here?

Slightly. PHP code runs on the server, so in the browser, it won't
"ping" the server.

Yes, you should have a PHP script on the server to do the processing,
(call it, say, "process.php") and one which paints the basic screen for
the browser (call it "page.php" or somesuch). But the connection between
these should be AJAX code in the page.php script. That will most likely
be Javascript in the page.php script which will "ping" the process.php
script for whatever contents you want.

The Javascript to do this is beyond the scope of this list (it's a PHP
list, after all). The "process" script doesn't have to be PHP. It could
be any language you prefer, as long as you can get it to return JSON or
XML to page.php, so that the Javascript in the page.php script can
interpret it.

Paul

-- 
Paul M. Foster

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



Re: [PHP] include path in httpd.conf

2010-04-05 Thread ad

Ash,

Nice call.   .htaccess was not being processed at all which led me to a 
cname configuration error for the sub domain.


Thanks!.

On 4/5/2010 8:27 PM, Ashley Sheridan wrote:

On Mon, 2010-04-05 at 19:40 -0400, ad wrote:

I have several virtual hosts on a dedicated server.
In a IFmodule mod_php5c container in an httpd.conf  include file I have
the following to create a unique include path for each virtual host:

IfModule mod_php5.c>
php_value include_path ".:/home/virtual/site#/path/to/include"
php_admin_flag safe_mode off


  For one of the virtual hosts I've set up a dev site in a subdomain at
  dev.site#.com for development.
  In the root directory of this development site I have an .htacces file
  to create another unique include_path solely for this development subdomain.

  php_value include_path  ".:/home/virtual/site#/path/to/dev/includes"

  Also in the httpd.conf I have
  
  Allow from all
  AllowOverride All
  Order allow,deny
  


  The configuration is CentOS 5.3, Apache/2.2.3, PHP 5.1.6

  I recently upgraded the OS from FC6 and the PHP version and I have not
  been able to get the include_path to change for this dev.subdomain.
  Even after restarting apache it PHPinfo tells me it is reading the
  server php.ini and the virtual host include path for the httpd.conf but
  it is ignoring the .htaccess file.

  I've even tried putting the php.ini with specific settings in the
  /home/virtual/site#/root directory to no avail.

Any ideas how to make this work or even a better set up?

Thanks in advance.


 


Are you able to determine if you can set any attributes with the 
.htaccess file? Is it possible the .htaccess isn't being processed at all?


I'm not sure why the virtual server settings are being ignored in the 
httpd.conf file though. Have you checked any other .conf files in that 
directory to see that they are not being set there? As far as I can 
remember, the .conf files in that directory are executed in 
alphabetical order, so a different file might be overriding your settings?


Thanks,
Ash
http://www.ashleysheridan.co.uk






RE: [PHP] Updating HTML on page

2010-04-05 Thread Ashley M. Kirchner
Hrm, been looking at it for a while now and I can feel a headache coming up.
I think I need to have one PHP script that does the processing, and another
that the user pulls up in their browser.  That one "pings" the processor
every so often to get updated data.  Yes?

Am I way off here?

> -Original Message-
> From: TG [mailto:tg-...@gryffyndevelopment.com]
> Sent: Monday, April 05, 2010 8:48 PM
> To: Ashley M. Kirchner; php-general@lists.php.net
> Subject: Re: [PHP] Updating HTML on page
> 
> The only way to do it with PHP alone would be to control the output
> buffering and I've found that to be inconsistant in quality and
> predictability with different browsers even web servers.  I'm sure
> there's an art to getting that all working well with various
> technologies
> that are involved in the script -> client caching and processing, but
> why
> mess with iffy when you can use a proven technology like AJAX.
> 
> Get familiar with jQuery (or one of the other big JS libraries, but
> jQuery
> is my choice hands-down) and you'll probably find it's pretty easy.
> 
> -TG


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



Re: [PHP] Updating HTML on page

2010-04-05 Thread TG
The only way to do it with PHP alone would be to control the output 
buffering and I've found that to be inconsistant in quality and 
predictability with different browsers even web servers.  I'm sure 
there's an art to getting that all working well with various technologies 
that are involved in the script -> client caching and processing, but why 
mess with iffy when you can use a proven technology like AJAX.

Get familiar with jQuery (or one of the other big JS libraries, but jQuery 
is my choice hands-down) and you'll probably find it's pretty easy.

-TG

- Original Message -
From: "Ashley M. Kirchner" 
To: 
Date: Mon, 5 Apr 2010 20:12:30 -0600
Subject: [PHP] Updating HTML on page

> I have a PHP script that queries a DB to get a list of image names.  Then 
it
> processes each name and generate thumbnails and what not.  What I want to 
do
> is have a page called (through the browser) which updates as the PHP 
process
> in the background is working.  So when you first pull up the page it will
> say 'There are x images to process' and then dynamically update the page
> with a progress status.  In its crudest form it should say something like
> 'Processing 1 of 5 images .'  When that image is done, it should update 
the
> page with 2 of 5 . etc., etc.  Ideally without refreshing the page each
> time.
> 
>  
> 
> Is this where I need to figure out Ajax and incorporate it with PHP?


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



[PHP] Updating HTML on page

2010-04-05 Thread Ashley M. Kirchner
I have a PHP script that queries a DB to get a list of image names.  Then it
processes each name and generate thumbnails and what not.  What I want to do
is have a page called (through the browser) which updates as the PHP process
in the background is working.  So when you first pull up the page it will
say 'There are x images to process' and then dynamically update the page
with a progress status.  In its crudest form it should say something like
'Processing 1 of 5 images .'  When that image is done, it should update the
page with 2 of 5 . etc., etc.  Ideally without refreshing the page each
time.

 

Is this where I need to figure out Ajax and incorporate it with PHP?



Re: [PHP] convert a string into an array

2010-04-05 Thread Nilesh Govindarajan

On 04/05/10 19:39, Ashley Sheridan wrote:

On Mon, 2010-04-05 at 05:53 +0100, Nathan Rixham wrote:


you sure you're only smoking cigarettes?

has to be one of the most random replies to any php thread I've ever
seen - awesome!

regards

Rene Veerman wrote:

yea i'm not the only one with those type of problems. sometimes times
slows down in my room so much not even my speakers sound normal
anymore; equipment that doesn't work (despite being crappy and known
by it's patterns of refusal to work; still EXTRA abnormal since about
a week or so)...

it sounds like the "who's reading my passwords with me while i type 'm
in... === 'is there anyone looking over my shoulder despite no living
humans even in my entire properly locked room (with strong walls)'

the idea here is; take a break. work on a different project for a week
or so, but the best idea is; move around through the country side and
realize that your car will get gas at every gasstation... check your
atm cards, but not your online banking account status, just to buy a
pack of cigarettes with an atm card. and then, buy not 1 or 2 packs of
your favorite smokes(cigarettes in this case), but buy 10 packs with
that card, and make sure you have enough good old cash that you know
to be truely valid (coins are best) to get just "2 large packs of
cigarettes"..

things like that will give you the confidence you need to proceed on
your project i think..

the #1 rule i use (when you dont yet have any need for a #0 rule or a
#-1 rule (dont add those lightly and never on a whim or hope of being
saved from death in the next 5 minutes)) is: truely honest living
humans should never use the same type of lie construct in the same
type of situation for the second time within at least 1 to 3 weeks..
but hey, necessity may require you to break any rule...

rules? only guidelines are usefull ;) (pirates of the caribean #1 movie)


On Sat, Apr 3, 2010 at 1:05 AM, Andre Polykanine  wrote:

Hello everyone,

It's quite simple but I'm still stuck.
What I need is the following: I have an array as a parameter of my
custom function. However, I'd like to allow users to enter a string
instead of an array. In this case (if the parameter is a string), it
must be replaced with an array containing only one item - actually,
that string.
What I'm doing gives me (presumably) errors;
function Send ($tonames, $toemails, $subject, $message) {
...
if ((!is_array($tonames)) || (!is_array($toemails))) {
$tonames[]=$tonames;
$toemails[]=$toemails;
}

I can't give the new array a new name since I address it further in a
loop as my function's parameter... hope you understand what I'm
saying)
Thanks!

--
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule


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








Virus maybe?

Thanks,
Ash
http://www.ashleysheridan.co.uk





Now where does a virus come in here LOL ?

--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !

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



Re: [PHP] include path in httpd.conf

2010-04-05 Thread Ashley Sheridan
On Mon, 2010-04-05 at 19:40 -0400, ad wrote:

> I have several virtual hosts on a dedicated server. 
> In a IFmodule mod_php5c container in an httpd.conf  include file I have 
> the following to create a unique include path for each virtual host:
>  
> IfModule mod_php5.c>
> php_value include_path ".:/home/virtual/site#/path/to/include"
> php_admin_flag safe_mode off
> 
>  
>  For one of the virtual hosts I've set up a dev site in a subdomain at 
>  dev.site#.com for development.
>  In the root directory of this development site I have an .htacces file 
>  to create another unique include_path solely for this development subdomain.
>  
>  php_value include_path  ".:/home/virtual/site#/path/to/dev/includes"
>  
>  Also in the httpd.conf I have
>  
>  Allow from all
>  AllowOverride All
>  Order allow,deny
>  
>  
> 
>  The configuration is CentOS 5.3, Apache/2.2.3, PHP 5.1.6
>  
>  I recently upgraded the OS from FC6 and the PHP version and I have not 
>  been able to get the include_path to change for this dev.subdomain.  
>  Even after restarting apache it PHPinfo tells me it is reading the 
>  server php.ini and the virtual host include path for the httpd.conf but 
>  it is ignoring the .htaccess file. 
>  
>  I've even tried putting the php.ini with specific settings in the 
>  /home/virtual/site#/root directory to no avail.
>  
> Any ideas how to make this work or even a better set up?
>  
> Thanks in advance.
> 
> 


Are you able to determine if you can set any attributes with
the .htaccess file? Is it possible the .htaccess isn't being processed
at all?

I'm not sure why the virtual server settings are being ignored in the
httpd.conf file though. Have you checked any other .conf files in that
directory to see that they are not being set there? As far as I can
remember, the .conf files in that directory are executed in alphabetical
order, so a different file might be overriding your settings?

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] include path in httpd.conf

2010-04-05 Thread ad
I have several virtual hosts on a dedicated server. 
In a IFmodule mod_php5c container in an httpd.conf  include file I have 
the following to create a unique include path for each virtual host:


IfModule mod_php5.c>
php_value include_path ".:/home/virtual/site#/path/to/include"
php_admin_flag safe_mode off


For one of the virtual hosts I've set up a dev site in a subdomain at 
dev.site#.com for development.
In the root directory of this development site I have an .htacces file 
to create another unique include_path solely for this development subdomain.


php_value include_path  ".:/home/virtual/site#/path/to/dev/includes"

Also in the httpd.conf I have

Allow from all
AllowOverride All
Order allow,deny



The configuration is CentOS 5.3, Apache/2.2.3, PHP 5.1.6

I recently upgraded the OS from FC6 and the PHP version and I have not 
been able to get the include_path to change for this dev.subdomain.  
Even after restarting apache it PHPinfo tells me it is reading the 
server php.ini and the virtual host include path for the httpd.conf but 
it is ignoring the .htaccess file. 

I've even tried putting the php.ini with specific settings in the 
/home/virtual/site#/root directory to no avail.


Any ideas how to make this work or even a better set up?

Thanks in advance.


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



Re: [PHP] Logical reason for strtotime('east') and strtotime('west') returning valid results?

2010-04-05 Thread Kevin Kinsey

Colin Guthrie wrote:


For example, I discovered that some words (or strings beginning with
those words) will return false positives:

e.g.:

[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("east"));'
int(1270514111)
[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("west"));'
int(1270488914)
[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("now"));'
int(1270488928)


The last one is valid! But the other two appear to do much the same thing...

Can anyone think of why this would be valid results before I report this
to the relevant authorities?


Time Zones?

[11] Mon 05.Apr.2010 13:05:41 [ad...@archangel][~]
php -r "echo date('r',strtotime('now'));"
Mon, 05 Apr 2010 13:05:47 -0500

This is correct for my timezone (US Central Daylight Time).

[12] Mon 05.Apr.2010 13:05:47 [ad...@archangel][~]
php -r "echo date('r',strtotime('east'));"
Mon, 05 Apr 2010 14:05:51 -0500

This is correct for the time zone east of me, US Eastern Daylight Time.
However, the TZ offset is wrong for that TZ, it's still mine.

[13] Mon 05.Apr.2010 13:05:51
[kad...@archangel][~]
php -r "echo date('r',strtotime('west'));"
Mon, 05 Apr 2010 07:05:59 -0500

This is correct for American Samoa, but I've no idea why :-D

Nonetheless, I'm suspecting the programmers had something
like this in mind.  Isn't strtotime() based on some GNU utility?

Kevin Kinsey

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



[PHP] Logical reason for strtotime('east') and strtotime('west') returning valid results?

2010-04-05 Thread Colin Guthrie
Hi,

Long time no speak!


As part of a quick filter I'm writing I try to interpret free text
strings as dates and textual data.

Sometimes, this goes wrong.

For example, I discovered that some words (or strings beginning with
those words) will return false positives:

e.g.:

[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("east"));'
int(1270514111)
[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("west"));'
int(1270488914)
[co...@jimmy Search (working)]$ php -r 'var_dump(strtotime("now"));'
int(1270488928)


The last one is valid! But the other two appear to do much the same thing...

Can anyone think of why this would be valid results before I report this
to the relevant authorities?

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



[PHP] Re: problems with utf-8 conversion

2010-04-05 Thread sudhir patil
Thanks Nathan,

i tried with utf8_encode, that doesn't help. Yes both content-type & metatag 
are set to utf-8.

When i try utf-8 converted csv everything shows up properly. Issue is when i 
try to change encoding in php, special characters are messed up.

Character that i am facing problem with is

’ ’ ’ right single quotation mark 
Thanks,
Sudhir



- Original Message 
From: Nathan Rixham 
To: sudhir patil 
Cc: php-general@lists.php.net
Sent: Mon, 5 April, 2010 8:19:54 PM
Subject: Re: problems with utf-8 conversion

sudhir patil wrote:
> I have csv file with special characters, stored in default 
> encoding(ISO-8859-1). I am convert file contents(string) to UTF-8using iconv. 
> This doesn't convert special characters properly, shows broken on fronted. 
> Page encoding & meta tag are properly set to utf-8.
> 
> Characters are shown properly on frontend if i save file encoding as 
> utf-8(Using notepad). But iconv doesn't convert characters properly to UTF-8.
> 
> $value = iconv("Latin1","utf-8", $value);
> having problem with below mentioned character
> 
> ’ ’ ’ right single quotation mark 
> Any idea or suggestions to fix this would be helpful.
> 

1: try utf8_encode instead of iconv
2: check the headers being sent and that they include:
  "Content-Type: text/html; charset=UTF-8"
   as this normally overwrites and choice you make in html.

a good way of debugging this is to view the page in firefox and see menu
option "View -> Charecter Encoding -> "; the one presently selected
is generally the pages "real" encoding, and you can flick between
iso-8859-1 / utf-8 to see which one "fixes" your problem (then change
headers accordingly).

regards!



  The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/

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



[PHP] Re: problems with utf-8 conversion

2010-04-05 Thread Nathan Rixham
sudhir patil wrote:
> I have csv file with special characters, stored in default 
> encoding(ISO-8859-1). I am convert file contents(string) to UTF-8using iconv. 
> This doesn't convert special characters properly, shows broken on fronted. 
> Page encoding & meta tag are properly set to utf-8.
> 
> Characters are shown properly on frontend if i save file encoding as 
> utf-8(Using notepad). But iconv doesn't convert characters properly to UTF-8.
> 
> $value = iconv("Latin1","utf-8", $value);
> having problem with below mentioned character
> 
> ’ ’ ’ right single quotation mark 
> Any idea or suggestions to fix this would be helpful.
> 

1: try utf8_encode instead of iconv
2: check the headers being sent and that they include:
  "Content-Type: text/html; charset=UTF-8"
   as this normally overwrites and choice you make in html.

a good way of debugging this is to view the page in firefox and see menu
option "View -> Charecter Encoding -> "; the one presently selected
is generally the pages "real" encoding, and you can flick between
iso-8859-1 / utf-8 to see which one "fixes" your problem (then change
headers accordingly).

regards!

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



Re: [PHP] Re: Constructor usage

2010-04-05 Thread Peter Pei
On Sun, 04 Apr 2010 17:46:19 -0600, Nathan Rixham   
wrote:



Larry Garfield wrote:

Hi folks.  Somewhat philosophical question here.

I have heard, although not confirmed, that the trend in the Java world  
in the
past several years has been away from constructors.  That is, rather  
than

this:

class Foo {
  public void Foo(Object a, Object b, Object c) {}
}

Foo f = new Foo(a, b, c);

The preference is now for this:

class Foo {
  public void setA(Object a) {}
  public void setB(Object b) {}
  public void setC(Object c) {}
}

Foo f = new Foo(a, b, c);
f.setA(a);
f.setB(b);
f.setC(c);

I suppose there is some logic there when working with factories, which  
you
should be doing in general.  However, I don't know if that makes the  
same

degree of sense in PHP, even though the OO models are quite similar.

So, I'll throw the question out.  Who uses example 1 above vs. example  
2 when

writing dependency-injection-based OOP?  Why?  What trade-offs have you
encountered, and was it worth it?




Other than theoretical reasons, one practical reason to have getters and  
setters is to make live easier for IDE's.


I never thought the above two are in conflict. Usually parameterized  
constructors are provided along with getters and setters - each is used  
for good reasons.


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



[PHP] problems with utf-8 conversion

2010-04-05 Thread sudhir patil

I have csv file with special characters, stored in default 
encoding(ISO-8859-1). I am convert file contents(string) to UTF-8using iconv. 
This doesn't convert special characters properly, shows broken on fronted. Page 
encoding & meta tag are properly set to utf-8.

Characters are shown properly on frontend if i save file encoding as 
utf-8(Using notepad). But iconv doesn't convert characters properly to UTF-8.

$value = iconv("Latin1","utf-8", $value);
having problem with below mentioned character

’ ’ ’ right single quotation mark 
Any idea or suggestions to fix this would be helpful.

Thanks in advance,
Sudhir



  Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! 
http://downloads.yahoo.com/in/internetexplorer/

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



Re: [PHP] convert a string into an array

2010-04-05 Thread Ashley Sheridan
On Mon, 2010-04-05 at 05:53 +0100, Nathan Rixham wrote:

> you sure you're only smoking cigarettes?
> 
> has to be one of the most random replies to any php thread I've ever
> seen - awesome!
> 
> regards
> 
> Rene Veerman wrote:
> > yea i'm not the only one with those type of problems. sometimes times
> > slows down in my room so much not even my speakers sound normal
> > anymore; equipment that doesn't work (despite being crappy and known
> > by it's patterns of refusal to work; still EXTRA abnormal since about
> > a week or so)...
> > 
> > it sounds like the "who's reading my passwords with me while i type 'm
> > in... === 'is there anyone looking over my shoulder despite no living
> > humans even in my entire properly locked room (with strong walls)'
> > 
> > the idea here is; take a break. work on a different project for a week
> > or so, but the best idea is; move around through the country side and
> > realize that your car will get gas at every gasstation... check your
> > atm cards, but not your online banking account status, just to buy a
> > pack of cigarettes with an atm card. and then, buy not 1 or 2 packs of
> > your favorite smokes(cigarettes in this case), but buy 10 packs with
> > that card, and make sure you have enough good old cash that you know
> > to be truely valid (coins are best) to get just "2 large packs of
> > cigarettes"..
> > 
> > things like that will give you the confidence you need to proceed on
> > your project i think..
> > 
> > the #1 rule i use (when you dont yet have any need for a #0 rule or a
> > #-1 rule (dont add those lightly and never on a whim or hope of being
> > saved from death in the next 5 minutes)) is: truely honest living
> > humans should never use the same type of lie construct in the same
> > type of situation for the second time within at least 1 to 3 weeks..
> > but hey, necessity may require you to break any rule...
> > 
> > rules? only guidelines are usefull ;) (pirates of the caribean #1 movie)
> > 
> > 
> > On Sat, Apr 3, 2010 at 1:05 AM, Andre Polykanine  wrote:
> >> Hello everyone,
> >>
> >> It's quite simple but I'm still stuck.
> >> What I need is the following: I have an array as a parameter of my
> >> custom function. However, I'd like to allow users to enter a string
> >> instead of an array. In this case (if the parameter is a string), it
> >> must be replaced with an array containing only one item - actually,
> >> that string.
> >> What I'm doing gives me (presumably) errors;
> >> function Send ($tonames, $toemails, $subject, $message) {
> >> ...
> >> if ((!is_array($tonames)) || (!is_array($toemails))) {
> >> $tonames[]=$tonames;
> >> $toemails[]=$toemails;
> >> }
> >>
> >> I can't give the new array a new name since I address it further in a
> >> loop as my function's parameter... hope you understand what I'm
> >> saying)
> >> Thanks!
> >>
> >> --
> >> With best regards from Ukraine,
> >> Andre
> >> Http://oire.org/ - The Fantasy blogs of Oire
> >> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ 
> >> jabber.org
> >> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> >> Twitter: http://twitter.com/m_elensule
> >>
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> 
> 


Virus maybe?

Thanks,
Ash
http://www.ashleysheridan.co.uk




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

2010-04-05 Thread Bob McConnell
From: Radek Krejca

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

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

Well, in the first place, you don't simply send a series of words to the
other end after opening the connection. Most protocols define a
conversation that happens between the two ends of a new connection. So
you have to wait for the server to send you a welcome message with a
prompt and reply to that. Then wait for the next prompt and reply to it.
So instead of just blasting out these strings, you need a receive loop
and parser to interpret what the server is saying to you. Once you know
what it says at each step you can decide how to respond.

SSH adds another layer in front of this to select key exchanges,
ciphers, hashes, etc. You don't want to write an SSH client. It can take
days just to read and understand the protocol definition.

A few minutes on Google should produce some useable examples of clients
for various protocols. It shouldn't take much work to read a basic
Telnet client written in Perl and transpose it into PHP.

Bob McConnell

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



[PHP] unsigned chars

2010-04-05 Thread donald sullivan
Hello,

is it possible to return unsigned chars from an extension?
I have looked and cant find anything on it, or maybe i am looking for the wrong 
keywords.

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



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

2010-04-05 Thread Radek Krejča
Hello,

thank you for response, more in you text:

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

I want to use my script against FreeBSD router and against RouterOS so I need 
ssh. I can use system function to call ssh command, but I can try it over php 
tools.

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.

It will be probably better way than system function. If I fail with using 
sockets I use this. Thank you very much.

Radek