Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi, Also http://www.softstack.com/freesmtp.html which vikash mentioned works through outlook settings. Anyways the below will help- http://php.net/manual/en/ref.mail.php http://glob.com.au/sendmail/ Personally, I always found hMailServer to be perfectly reliable as a relay on Windows - just install it and SMTP to localhost - nothing more, nothing less. Andy
Re: [PHP] Intermittent etwork connection errors with apache. Restarting apache temporarily fixes the problem. PHP or apache problem?
Hi Mark, I don't have any disconnect call in my code. Is this the same for all your connections code, apart from your LDAP? It's good practice to never assume that PHP will disconnect connections for you - explicitly call the disconnect function when your connection is done with. Lately I have noticed that the apache server will get into a state where connection requests will occasionally fail. When I refresh the page, the connection almost always succeeds on the 2nd attempt. If I restart the apache server, the problem totally goes away for a long period of time. Are you talking about the connection to Apache or the connection from your Apache server to your other servers? So I assume that somewhere, something is causing connections to stay opened when the script ends, rather than automatically closing them. As I said above, always explicitly disconnect from any services you connect to when you're finished. This error occurs with other types of network connections that the script makes (besides ldap), so it's not an ldap issue. How does Apache automatically close connections when the script ends? Is it possible that connections are being left opened? Is there any way to debug the problem, i.e. to see if connections are left opened in some way? Run netstat -an|grep tcp on the server's console before and after a page request - if possible prevent all other connections to your Apache server while you do it. Connections that remain open will be in the state ESTABLISHED - server processes (e.g. Apache) will be listed as LISTEN. If you get an LDAP connection after your page request that wasn't there before in the ESTABLISHED state, PHP isn't disconnecting. If any connections are listed as TIME_WAIT, it means the connection was dropped without the client disconnecting properly - it may be worth running netstat on your LDAP server as well. Regards, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] idea? add set_trace_handler() to PHP
Hi, Have you taken a look at Xdebug - http://xdebug.org/ ? From the manual: Xdebug allows you to log all function calls, including parameters and return values to a file in different formats. Would this do what you need - then your second script could process this file? Regards, Andy On 25 Dec 2009, at 04:42, Rene Veerman wrote: Hi, I would like the opinion of the readers of this list on whether or not they agree on the usefullness of adding some new functions to the core of PHP. Background Info: I want more debug-information from my scripts. And I want to perform lengthy operations in a more robust way. And I want to monitor such operations in real-time, with points of interest highlighted, from a webbrowser, using jquery ajax calls. For instance, when 1000 items are being processed and 10 fail, i want those listed (with full details) instead of them cancelling the rest of the operation. For each lengthy operation, i want to keep track of: - $operationName, $contextName - a full trace, with per function the (timing-)stats, arguments, errors (possibly including notices), and results. - the ability to monitor the operation flow from a webbrowser (using ajax calls) in realtime. - the ability to store such logs (filtered or not) in a database via adodb.sf.net, or in a file (json / plaintext), or to email them. I'm considering to release the library i'm building for this as LGPL, including a viewer. Problem description: To enable a full trace i need to call a function that i create, on entry of any other function, and on exit of such a function. Obviously adding (even simple, standard) calls to every function i use is too cumbersome, and i'd miss all the php built-in functions. The simplest solution to this imo, is to add this to the core of PHP: $oldTraceHandlerFunctionName = set_trace_handler ( $handlerFunctionName = 'traceHandler', $functionList = array ( 'functionName', ) OR (default:)null=monitor all functions, ); function traceHandler ( $file = string;fullpath, $lineNumber = integer, $functionName = string, $eventIsStartOfFunction=boolean, // false = being called at exit of the function $arguments = array( '[]$argumentVariableName' = anyVariable, ), $localVariables = array( 'localVariableName' = anyVariable, ) ) { //do something } If you have any improvements for this mockup, please post them as reply. While there are the profiling functions of http://nl2.php.net/manual/en/function.apd-set-pprof-trace.php, I would nevertheless to propose adding of the new capabilities listed above here, for people who don't have enough control over their webserver to install the requirements of apd-set-pprof-trace. Also, i haven't looked into it yet, but converting the apd-set-pprof-trace data to any other format seems to be difficult to do in realtime because it writes such data to disk. Turning such data into your own format in realtime will be prone to slowness / errors. I'll also look at using apd-set-pprof-trace, since none of this is likely to be implemented soon.. I'll post updates to this thread if i solve that puzzle.
[PHP] Re: [PHP-DB] RE: Help for a beginner
Hi Adam, On 23 Dec 2009, at 17:21, Adam Sonzogni wrote: If you read the thread I useda php page totest mysql connectivity after phpmyadmin did not work... At this point I am willing to pay someone to troubleshoot this as I am baffled there is no definitive troubleshooting documentation for Windows installs. That's because nobody likes Windows ;-) What is at Line 4 in your test.asp? The error you provided said that there was a problem where it could not find the default driver to use. Also when you get the connection failed you were trying to connect to MYSQL from the system running MYSQL correct? I'd suggest installing the MySQL GUI tools (from http://dev.mysql.com) on your server - they may give you a better picture of what's going on. I take it you've installed the ODBC connector for MySQL? You didn't mention in your post if you had or not and I'm not familiar enough with MySQL on Windows to know if the essentials package includes it. The error you're getting from ASP means it doesn't recognise the driver mySQL or is looking for an ODBC connection called mySQL which doesn't exist. Regards, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sending email with php
Hi Suhakar, link rel=stylesheet type=text/css href=style.css / Relative URLs won't work - when it's rendered inside the e-mail client, the relative URL has no meaning (I believe Outlook renders relative URLs relative to the temporary directory the HTML is being rendered in.) Other clients may do it relative to an imap:// URL. Try uploading the images and stylesheet to your website and putting them within the newsletter as absolute URLs (including the images) - e.g. link rel=stylesheet type=text/css href=http://www.yourwebsite.com/style.css; / Also I know this is OT and is completely up to you, but remember to include a plain-text part, and also realise that a lot of mail clients don't render images/stylesheets by default - therefore straight after the body tag before the rest of the content, put a link to an external website where recipients can view the content online. Regards, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking for internet connection.
Both at home and at work there are caching DNS on the LAN. So a DNS request may come back with a valid IP address when the WAN connection is down. I still won't be able to connect to the remote site. Dig an external server - e.g. dig @a.root-servers.net google.co.uk If your net is down the query will fail even if the reply is cached locally, because you're specifically requesting a response from a.root-servers.net.
Re: [PHP] Checking for internet connection.
I'm confused... what's the problem with just trying to hit the update server? If you can then you check for updates, if not then you, erm, don't. Simples, no? True, I think I said this same thing in a previous post - I suggested the DNS option if all the OP wanted to do was check if an Internet connection was there. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking for internet connection.
And I was pointing out that this would not be a valid test when there is a caching DNS on the LAN. I also pointed out how to avoid caching issues - the comment was aimed at the author of the message before mine. Too much of the conversation and most of the attribution was stripped too early for this to be coherent. Why the negativity? A question was asked and several possible solutions were provided based on that original question. All the conversation was relevant IMO.
Re: [PHP] Checking for internet connection.
I think the only way to detect if it can connect to the Internet is to see if you can grab a file from somewhere on the Internet. I'd hazard a guess that when operating systems are able to tell you they can connect to the Internet they are actually saying they can ping a predetermined remote host. I think checking if PHP can grab a remote file with Curl would be sufficient in this case. Personally, I'd do a DNS lookup - even connecting to a server is a lot more overhead than a simple DNS request. You could force the DNS server to be one external to your network - e.g. dig @a.root-servers.net www.google.co.uk. If the dig command fails, you're not connected. Or just try and get the update anyway - if the download fails, you're not connected (or there's something wrong with the update server.)
Re: [PHP] Checking for internet connection.
By attempting to connect you will implicitly query DNS (which itself is a connection to server). No it's not - it's putting out a packet targeted at an IP address and hoping a server will answer - hence why multi-cast works for DNS because you're not directly connecting to a specified server, like you do with TCP/IP. I believe it's similar for ping which is why it's used so commonly in monitoring applications. If you're not online you won't be able to resolve the domain name. Exactly - so if all the OP wanted to check for was a working Internet connection, then DNS is a better way to go IMHO. Hence no overhead of actually connecting, because that won't even start to happen until the hostname is resolved to an IP. If it happens to resolve from some cache, oh well. Not like its that much overhead. You're nitpicking over the number of packets it takes to SYN/ACK. Yep and if it's running inside a LAN with x number of computers all doing the same thing, that mounts up to a lot of unnecessary traffic - I've seen it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why does CURLOPT_FOLLOWLOCATION require open_basedir to be turned off?
Hi, I was wondering why CURLOPT_FOLLOWLOCATION requires open_basedir and safe_mode to be turned off. The following was found in the changelog(http://www.php.net/ChangeLog-5.php): Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are enabled. (Stefan E., Ilia) I'm guessing that it would allow CURL to follow a link if a server returned a 301 or 302 redirect. For example, a PHP script consumes a web service or fetches a webpage from another server, then all of a sudden that remote server sends a 301/302 redirect to a malicious page, CURL would then follow the redirect instead of returning an error. If a server admin is paranoid enough to use safe_mode, they probably wouldn't want that to happen (note saying that being paranoid is a bad thing, but I've been managing PHP systems for years without safe_mode or open_basedir and never had an issue, but I can see why hosting providers may enable it.) I can't see any conceivable benefit to this restriction when using open_basedir, as I thought that related to the local file system - unless CURL can use file:// URLs to access the local system? Regards, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php htaccess logins and logouts
Hi, IIRC if you unset $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW'] it will log you out. I've done some research on this in the past - and not all browsers/web servers honour that as it's the browser that keeps the username/password cached and sends it after a 401 response, so the server knows nothing about the login - i.e. 1. User visits page 1 2. Server sends 401 Unauthorised header 3. Browser does not have any login details for the realm and prompts user 4. User inputs credentials, browser re-submits the request with the credentials attached 5. User visits page 2 6. Server sends 401 Unauthorised header 7. Browser has login details for the realm and re-submits the request with the credentials attached From the conclusion I came to after my research, there is no reliable way for the server to de-authorise a login after a 401 request. There are tricks you can do on the server, such as changing the authentication realm when the user has logged out - but if the user visits the same site again the realms will match and they will be logged in. I've seen a hack which uses a cookie on the user's machine - if the user has the cookie, the correct authentication realm is returned in the authentication request. If the user doesn't have the cookie, the server sends a random realm to trick the browser into thinking it's not logged in. By the time you've done all that, you might as well just use sessions. Regards, Andy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is Aptana taking a crap on the face of PHP?
* It is FREE (unlike Zend's retarded $500 price tag). I bought Zend Studio back in the 5.5 days - a couple of months after that they announced they were dropping support for the standalone IDE and made Studio an Eclipse plugin. It was then they added about $200 to the price. I moved to NuSphere PhpEd and was happy with that for a couple of years, now I'm on a Mac and haven't been able to find a decent IDE for either PHP or C++. Apple's Xcode seems to do the job for C++ (although better code completion wouldn't go a miss) but it fails miserably with PHP. Komodo was great for PHP but quite often it kept failing to load my class definitions for the code completion (and kept my processor sat at 25% use the whole time it was running.) I thought NetBeans was Java-only (and proprietary) but evidently it's come a long way since I last looked at it - I'm just downloading it now to see if it will handle both PHP and C++. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] please help with regular expression in preg_replace
Hi Rene, This looks suspiciously like regex's greedy behaviour - it will gobble up everything that matches until you tell it otherwise. For example, your regex is matching any character that isn't a dot, followed by a dot. In host.domain.com, both host. and domain. match this regex - and because your regex is greedy it's grabbing both, leaving you with com. Try adding the ungreedy modifier to your regex, like so: $domain = preg_replace( '/[^.]*\./U' , '', $host); (note the additional U in your regex.) HTH, Andy On 29 October2009, at 20:33, Red wrote: hello, im not a php developer, i just need to rewrite one php file but having problem with understanding syntax of regexp in php. i need to get domain name from fqdn (for example from $_SERVER ['HTTP_HOST'] ) in sed its working well with s/[^.]*\.// , but preg_replace behaves weird. http_host is for example hostname.domain.com ?php $host = $_SERVER['HTTP_HOST']; exec( echo $host | sed s/[^.]*\.//, $domain ) ; echo $domain[0] ? return domain.com, but ?php $host = $_SERVER['HTTP_HOST']; $domain = preg_replace( '/[^.]*\./' , '', $host) ; echo $domain; ? return only com i think when this php page get many hits, its not so wise to call sed everytime, i would like to ask someone for help how to write preg_replace pattern. thanx Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Using setters/getters with array of objects
Hi, $u-emails[] = $e; I would hazard a guess because $u-emails isn't a concrete object (whereas $u-_emails is, but is private.) It's sort of a virtual reference - PHP has no way of knowing that $u-emails actually translates into _emails which is an array, if you see what I mean (it's difficult to explain.) But that does not work. I've managed to achieve similar result using a different setter in User public function __set($name, $value) { $property = '_' . $name; switch($name) { case 'emails': array_push($this-$property, $value); break; default: $this-$property = $value; } } You could also have done: if (is_array($this-$property)) { array_push($this-$property, $value); } else { $this-$property = $value; } which would handle any array property, not just the e-mails property. If this was me, I would probably create a concrete method, called addEmail which would do $this-_emails[] = $value, but allow a programmer to call $user-emails to get the e-mails (not set.)