php-general Digest 30 Dec 2009 10:08:09 -0000 Issue 6513
Topics (messages 300731 through 300744):
Re: ip-to-country
300731 by: George Langley
300732 by: Nitsan Bin-Nun
Re: output buffer
300733 by: Bastien Koert
300736 by: Marc Fromm
300740 by: kranthi
Re: sending email with php
300734 by: George Langley
Re: Unable to get output from exec "ssh remote-server 'ping -c4 ip'"
300735 by: Adam Randall
300741 by: kranthi
Re: Multiple Inheritance Needed in OOP?
300737 by: Daniel Kolbo
300738 by: Daniel Egeberg
300739 by: Daniel Kolbo
not able to use mysql server
300742 by: Sudhakar
300743 by: Jignesh Thummar
Help with security configuration for a shared hosting environment
300744 by: robert mena
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]
----------------------------------------------------------------------
--- Begin Message ---
From my experience, I have had reported one incorrect country-level
IP from Maxmind's paid service (returned US vrs Canada for a Canadian
IP). But their free version is based on the commercial lists, just not
updated as often, or automatically (you download and store locally on
your server). So should be nearly as accurate as long as you maintain
the lists (ie. think is weekly, being 2-weeks behind).
That said, someone on another list is running a geo-location service
comparison test, where you click links to the various services, then
enter the location they returned. He was compiling the results, and so
far has reported the following:
---------QUOTE-------
So far some crazy numbers and realities. Of these numbers, all of the
vendors missed 25 exact city locations equally. So our continued plan
is to measure how far off the approx. 25% are so we can then say, "OK,
x vendor is 100% accurate up to x% and then x% accurate within say x-y
miles". The shocking thing to us is still how some of the more
expensive providers will say their definition of accuracy on a city
level can be within 25 miles. Thus you would receive statistical
confidence of a 90-100 for an IP that shows Pasadena, Calif. and yet
in reality be located in Long Beach, Calif., or the same for San Jose,
Ca. and yet be further up the peninsula in San Carlos, Ca.
total: 103
ip2: 55
quova: 46
ipiligence: 32
whatis: 62
maxmind: 63
By the way, we are obviously way short still on queries so if you
haven't clicked on the link, please do so and follow some ez pz
instructions:
http://www.stratosanalytics.com/iplookup.html
---------END QUOTE-----------
So help him out by clicking the link (although not sure what he means
by "e-zed-p-zed instructions".... ;-{)] )
George
On 14-Dec-09, at 5:07 AM, Angelo Zanetti wrote:
-----Original Message-----
From: George Langley [mailto:[email protected]]
Sent: 19 October 2009 01:38 AM
To: [email protected]
Subject: Re: [PHP] ip-to-country
On 18-Oct-09, at 1:03 PM, SED wrote:
How can I access an index for IP to a country (or a more detailed
location)?
------------
<http://www.maxmind.com/app/ip-location>
has both free and various paid services.
George
Hi George,
How accurate are the free ones compared to the paid ones?
Regards
Angelo
http://www.elemental.co.za
http://www.wapit.co.za
--- End Message ---
--- Begin Message ---
easy-peasy :)
I have nothing to add to the discussion, my experience is only with
Maxmind's free database, and it is definitely not accurate at Israel.
On Tue, Dec 29, 2009 at 11:14 PM, George Langley <[email protected]>wrote:
> From my experience, I have had reported one incorrect country-level
> IP from Maxmind's paid service (returned US vrs Canada for a Canadian IP).
> But their free version is based on the commercial lists, just not updated as
> often, or automatically (you download and store locally on your server). So
> should be nearly as accurate as long as you maintain the lists (ie. think is
> weekly, being 2-weeks behind).
> That said, someone on another list is running a geo-location service
> comparison test, where you click links to the various services, then enter
> the location they returned. He was compiling the results, and so far has
> reported the following:
> ---------QUOTE-------
> So far some crazy numbers and realities. Of these numbers, all of the
> vendors missed 25 exact city locations equally. So our continued plan is to
> measure how far off the approx. 25% are so we can then say, "OK, x vendor is
> 100% accurate up to x% and then x% accurate within say x-y miles". The
> shocking thing to us is still how some of the more expensive providers will
> say their definition of accuracy on a city level can be within 25 miles.
> Thus you would receive statistical confidence of a 90-100 for an IP that
> shows Pasadena, Calif. and yet in reality be located in Long Beach, Calif.,
> or the same for San Jose, Ca. and yet be further up the peninsula in San
> Carlos, Ca.
>
> total: 103
>
> ip2: 55
> quova: 46
> ipiligence: 32
> whatis: 62
> maxmind: 63
>
>
> By the way, we are obviously way short still on queries so if you haven't
> clicked on the link, please do so and follow some ez pz instructions:
>
> http://www.stratosanalytics.com/iplookup.html
>
> ---------END QUOTE-----------
>
> So help him out by clicking the link (although not sure what he
> means by "e-zed-p-zed instructions".... ;-{)] )
>
> George
>
>
>
> On 14-Dec-09, at 5:07 AM, Angelo Zanetti wrote:
>
>
>>
>> -----Original Message-----
>> From: George Langley [mailto:[email protected]]
>> Sent: 19 October 2009 01:38 AM
>> To: [email protected]
>> Subject: Re: [PHP] ip-to-country
>>
>> On 18-Oct-09, at 1:03 PM, SED wrote:
>>
>>>
>>> How can I access an index for IP to a country (or a more detailed
>>> location)?
>>>
>> ------------
>> <http://www.maxmind.com/app/ip-location>
>>
>> has both free and various paid services.
>>
>> George
>>
>>
>> Hi George,
>>
>> How accurate are the free ones compared to the paid ones?
>>
>> Regards
>> Angelo
>>
>> http://www.elemental.co.za
>> http://www.wapit.co.za
>>
>>
>>
>
--- End Message ---
--- Begin Message ---
On Tue, Dec 29, 2009 at 4:09 PM, Marc Fromm <[email protected]> wrote:
> I am receiving the "Cannot send session cookie - headers already sent"
> message even though I am using ob_start() at the top of my script.
> The php.ini file has output_buffering set to 4096 4096.
> My server is running Red Hat Enterprise Linux 5.2
> I am using PHP 5.1.6
>
> Is there some other setting I need to adjust to be able to start a session
> within the php script?
>
> Thanks
>
> Marc
>
>
Check that you don't have white space in your include files. One trick
there is to remove the closing PHP tags '?>' to avoid this problem
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
I figured it out but not sure why.
On the dev server the script ran with no errors
On the live server the script created the header already sent error.
In the code I did not execute ob_start() at the top of the script.
Once I executed ob_start at the top of the script on the live server it worked
with no header already sent error.
I cannot see why on the dev server it works with the ob_start() command in
inside the script while the live server had an error when it was in the same
place in the script.
-----Original Message-----
From: Alexey Bovanenko [mailto:[email protected]]
Sent: Tuesday, December 29, 2009 1:38 PM
To: Marc Fromm
Subject: Re: [PHP] output buffer
Hi.
There're some other code that is sent to client. You must send cookie
first, at header, then the other data.
Please send code to view your case.
With regards,
Alexey
On Wed, Dec 30, 2009 at 12:09 AM, Marc Fromm <[email protected]> wrote:
> I am receiving the "Cannot send session cookie - headers already sent"
> message even though I am using ob_start() at the top of my script.
> The php.ini file has output_buffering set to 4096 4096.
> My server is running Red Hat Enterprise Linux 5.2
> I am using PHP 5.1.6
>
> Is there some other setting I need to adjust to be able to start a session
> within the php script?
>
> Thanks
>
> Marc
>
>
--- End Message ---
--- Begin Message ---
most probable error in your case is the dev server has output
buffering enabled while it is turned off on the live server. try
phpinfo to verify
--- End Message ---
--- Begin Message ---
<http://articles.sitepoint.com/article/code-html-email-newsletters>
is a straight-ahead overview of what you can/should/cant/shouldn't do
in HTML e-mails.
Or check out:
<http://www.devshed.com/c/a/PHP/Composing-Messages-in-HTML-for-MIME-Email-with-PHP/
>
for some heavy-duty mail classes (be sure to check the "See Also"
section for the full story).
I also referenced the following:
<http://www.wilsonweb.com/wmt5/html-email-multi.htm>
on the basics of sending multi-part e-mail (ie. plain text AND HTML).
HTH.
George
On 23-Dec-09, at 1:58 PM, Sudhakar wrote:
<?php
$headers = "Content-type: text/html; charset=iso-8859-1";
$to="myemailaddress";
$subject="Email Newsletter";
$message = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Email Newsletter</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="wrapper">
<div id="topmenu">
</div>
<div id="content">
<div class="leftcolumn">
</div>
<div class="rightcolumn">
</div>
</div>
<div id="footer">
</div>
</div>
</body>
</html>';
if(! mail($to, $subject, $message, $headers)){
echo "There was an error is sending the email";
}
else{
echo "The email has been sent";
}
?>
hi
my question is about send an email with php like a newsletter, when
we read
a newsletter email its similar to a webpage which contains content,
images,
css and other elements
i created a static webpage initially with html css and images folder
after
creating the page i wanted to test to see how it would look if i
were to
send this as an email like a newsletter.
so i have created a php file with
$headers = "Content-type: text/html; charset=iso-8859-1";
$to="myemailaddress";
$subject="Email Newsletter";
and
$message as mentioned above has the entire html code as i used it in
my
static html page
i also copied the style.css in the server and created images folder
and
copied all the images i used in my static page to the server.
i created a separate folder in my webserver called newsletter and
copied the
php file, css file and images folder with the images i used
when i accessed the index.php as http://website.com/emailnewsletter
i am
getting a message that The email has been sent and i am getting the
email
however my question is when i open this email the styles and images
are not
being applied and i see only the text in the static page i created.
can someone let me know how i can fix this so that when i open the
email it
would look like the static page i created with all the styles
applies and
images displayed
is this only possible by using specialized email softwares or can it
be done
by php as well with the logic used.
any help will be appreciated.
thanks
--- End Message ---
--- Begin Message ---
If you are just checking to see if the IP is pingable, but don't care about
the output you could just test against the exit code:
$host = 'hostorip';
$sshhost = 'hostorip';
$alive = trim( shell_exec( 'ssh ' . $sshhost . ' ping -q -n -c 5 -W 2 ' .
$host . ' \>/dev/null 2\>\&1 \&\& echo "Alive"' ) ) == 'Alive';
var_dump( $alive );
I use a variant of the above with good success on Gentoo.
Adam.
On Sun, Dec 27, 2009 at 1:53 PM, robert mena <[email protected]> wrote:
> Hi,
>
> I need to develop an interface that will, for example, ping IPs from a
> remote server. So the php script will be hosted in a server with ssh access
> (key) to the remote server.
>
> I can make it work from the console but when I try
>
> $cmd = "ssh remote-server 'ping -c 4 ip'"
> exec($cmd, $ouput);
>
> the output is empty.
>
> the same command (with the remote-server and IP changed to the real ones)
> works fine from command line.
>
> I've added the key/config in the webserver's user .ssh directory so I am
> assuming that that there is something wrong with my setup.
>
> any ideas?
>
--
Adam Randall
http://www.xaren.net
AIM: blitz574
Twitter: @randalla0622
--- End Message ---
--- Begin Message ---
better try using ssh2_* functions
http://www.php.net/manual/en/function.ssh2-tunnel.php
--- End Message ---
--- Begin Message ---
Larry Garfield wrote:
> On Monday 28 December 2009 9:45:03 pm Daniel Kolbo wrote:
>> Hello,
>>
>> Okay so PHP designers explicitly decided against multiple inheritances,
>> but aren't there legitimate needs for multiple inheritance in OOP?
>>
>> For example, consider the following three classes (A,B,C) with the
>> following properties (a number is a distinct property or method).
>>
>> A: 1, 2, 3
>> B: 1, 3
>> C: 1, 2,
>>
>> I would like to set the 3 classes up so that no object has 'extra'
>> properties than it requires, so that no property has to be
>> declared/defined in two or more classes, and so that we are strictly
>> using single inhertiance. I don't think it's possible. I've been
>> incorrect beforee...If i'm incorrect please let me know how to set this
>> up as a single inhertance class structure.
>>
>> If this is not possible, why doesn't the PHP community implement
>> multiple inheritance? (I'm anticipating that someone will say, you
>> simply need to redefine what you are calling your objects so that the
>> properties do permit a single inheritance...)
>>
>> I'm very interested to hear why there is the dogma of single inheritance
>> only.
>>
>> Thanks,
>> dK
>> `
>
> Because pure multiple inheritance can lead to all sorts of highly weird
> behavior when you don't know which parent class you mean at any given time.
> Single inheritance is just easier to wrap your head around, and wrap the
> compiler's head around.
>
> What you're looking for is composition, which can do pretty much what you're
> looking for. See my last reply to you on this list from Christmas day.
>
> There's been some discussion of implementing "traits" in later versions of
> PHP, but no concrete patches so far.
>
Hello Mr. Garfield,
I saw your reply on how to mimic composition, and I appreciate your
comments. I don't prefer (not saying that anyone really does) the mixin
approach as private/protected aspects of the mixined class are not
available in the pseudo-child class. Also, the code may still need to
be maintained in the child class for some changes in the parent class.
I would prefer to throw too much into my parent class then to deal with
the mixin approach (at this time).
I understand about a seemingly simple idea, being not so simple to
implement. However ;), for name conflict issues, the compiler could
have a simple rule. Such a proposed rule might be for the compiler to
throw a warning and to use the last definition supplied. This way
multiple inheritance is available for those that legitimately need it
and the warning is there so the 'spooky' behaviour scenario can be
isolated to an hesitance name conflict.
I was reading the request for comments about the traits. My thought is,
if we go through the work of allowing horizontal reuse into php, why not
do the work for multiple inheritance first.
I could understand having the default install to only single
inheritance, but i do not understand why php programmers are not, at
least, given the option.
Thanks,
dK
`
--- End Message ---
--- Begin Message ---
On Wed, Dec 30, 2009 at 01:24, Daniel Kolbo <[email protected]> wrote:
> This way multiple inheritance is available for those that legitimately need
> it [...]
Could you by any chance provide an example where multiple inheritance
would be required? To be honest, I've never really seen a use for it,
but that may be because I've not used a language that supports
multiple inheritance (not on classes anyway).
--
Daniel Egeberg
--- End Message ---
--- Begin Message ---
Daniel Egeberg wrote:
> On Wed, Dec 30, 2009 at 01:24, Daniel Kolbo <[email protected]> wrote:
>> This way multiple inheritance is available for those that legitimately need
>> it [...]
>
> Could you by any chance provide an example where multiple inheritance
> would be required? To be honest, I've never really seen a use for it,
> but that may be because I've not used a language that supports
> multiple inheritance (not on classes anyway).
>
In the OP i had an example:
>> For example, consider the following three classes (A,B,C) with the
>> following properties (a number is a distinct property or method).
>>
>> A: 1, 2, 3
>> B: 1, 3
>> C: 1, 2,
>>
>> I would like to set the 3 classes up so that no object has 'extra'
>> properties than it requires, so that no property has to be
>> declared/defined in two or more classes, and so that we are strictly
>> using single inheritance.
Granted this example has the additional specifications of not having
inherited extra properties then needed and not having duplicated code.
This example doesn't 'require', multiple inheritance, as we could always
just throw all of our code (methods, properties) we would ever possibly
conceive of needing into one root class and have all classes extend the
root class. So no, there is no example where it would be absolutely
required, but i argue the above example legitimates the need for
multiple inheritance.
Other reasons:
If the only way to make your classes follow strict single inheritance is
to reduce readability and/or confuse the intuitive understanding of the
design's class model structure, then i would argue readable and
intuitive code is a legitimate reason (perhaps even a requirement ;)
Also, if one is trying to enhance a 3rd party's code, but the 3rd party
didn't provide access to the code (closed source) and/or they didn't
provide interfaces to allow for mixins.
Also, if you don't want to deal with the headache and drawbacks of mixins.
Also, if you want to ensure higher levels of code maintainability and so
don't want to duplicate code.
Also, if you are concerned about your code's efficiency and want to
avoid the situation of throwing in all the methods higher up the parent
class chain.
I think that this list of reasons (specifically maintainability,
readability, and efficiency) more than justifies the concern of
resolving namespace conflicts.
Thanks,
dK
`
--- End Message ---
--- Begin Message ---
hi
i am using windows vista and installed wamp server, initially i installed
wamp and accessed phpmyadmin and while setting a password for the root i did
a mistake and could not access phpmyadmin and also renamed some php files so
i uninstalled wamp server and re installed
now the problem i am facing is when i click on mysql.exe located at
D:\wamp\bin\mysql\mysql5.1.36\bin i am getting the following error
error 2003 cant connect to Mysql server on localhost 10061
in config.inc.php located at d:\wamp\apps\phpmyadmin3.2.0.1 i have the
following
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
along with others.
when i type http://localhost i am able to see the welcome screen of wamp and
can click on phpinfo but when i click on phpmyadmin it takes a while to load
and a blank screen appears
also i have stopped all services and restarted all services from the
wampserver icon in the system tray, normally the colors change from red to
yellow to white, the color is at yellow and does not change to white
how do i solve the error error 2003 cant connect to Mysql server on
localhost 10061 so that i can use phpmyadmin
please advice.
thanks.
--- End Message ---
--- Begin Message ---
It is problem with mysql client, it's not able to connect with mysql server.
Either mysql server is not running or windows firewall is blocking to the
access of port 3306. Try to disable firewall.
-Jignesh
On Wed, Dec 30, 2009 at 11:41 AM, Sudhakar <[email protected]> wrote:
> hi
>
> i am using windows vista and installed wamp server, initially i installed
> wamp and accessed phpmyadmin and while setting a password for the root i
> did
> a mistake and could not access phpmyadmin and also renamed some php files
> so
> i uninstalled wamp server and re installed
>
> now the problem i am facing is when i click on mysql.exe located at
> D:\wamp\bin\mysql\mysql5.1.36\bin i am getting the following error
> error 2003 cant connect to Mysql server on localhost 10061
>
> in config.inc.php located at d:\wamp\apps\phpmyadmin3.2.0.1 i have the
> following
> $cfg['Servers'][$i]['host'] = 'localhost';
> $cfg['Servers'][$i]['port'] = '3306';
> $cfg['Servers'][$i]['auth_type'] = 'config';
> $cfg['Servers'][$i]['user'] = 'root';
> $cfg['Servers'][$i]['password'] = 'root';
> $cfg['Servers'][$i]['AllowNoPassword'] = true;
>
> along with others.
>
> when i type http://localhost i am able to see the welcome screen of wamp
> and
> can click on phpinfo but when i click on phpmyadmin it takes a while to
> load
> and a blank screen appears
>
> also i have stopped all services and restarted all services from the
> wampserver icon in the system tray, normally the colors change from red to
> yellow to white, the color is at yellow and does not change to white
>
> how do i solve the error error 2003 cant connect to Mysql server on
> localhost 10061 so that i can use phpmyadmin
>
> please advice.
>
> thanks.
>
--- End Message ---
--- Begin Message ---
Hi,
I am setting a shared hosting server and I'd like to gather some advices
regarding the security. Since the code will not be produced by me I'd like
to focus on environment strategies.
For now I've added a noexec in the mount options of the /tmp and the homedir
of the web server, disabled the devel tools (such as gcc).
In terms of the PHP I am inclined to use mod_suPHP to avoid having the
problem with the script generated files (such as uploads) being owned by the
webserver itself and I'd like to use the available php.ini options to try to
make it harder for an attacker to cause problems.
I will disable the register_globals and the allow url fopen. But what else
can I do (open_basedir/doc_root/safe_mode etc)?
I need to allow the user to access the pear classes.
Using linux/php 5.2.x
Regards.
--- End Message ---