[PHP] Regular Expression to get the whole Comma Separated String in Array Key
Hi All, Need help in resolving the below problem- I would like to get the whole comma separated string into an array value- 1. $postText = chapters 5, 6, 7, 8; OR 2. $postText = chapters 5, 6; OR 3. $postText = chapters 5, 6, 7; What i have done so far is- preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches); The above will exactly match the third value $postText = chapters 5, 6, 7; By Above $matches will contain a value of : $matches[1] = '5, 6, 7'; Now i need a SINGLE regular expression which can match first, second variable above or any number of comma separated string and IMPORTANTLY provide me that whole comma separated sting value (as above) in single array key element like below- $matches[1] = '5, 6, 7'; OR $matches[1] = '5, 6'; OR $matches[1] = '5, 6, 7, 8, 9'; Also I have to use regular expression only as the flow of the code does not permit to use any other method to get comma separated string from the master/base string. Thanks, Gaurav Kumar
[PHP] Re: Regular Expression to get the whole Comma Separated String in Array Key
Hey Richard, Thanks!!! You have resolved my problem.. GK On Wed, Jun 30, 2010 at 7:42 PM, Gaurav Kumar kumargauravjuke...@gmail.comwrote: Hi All, Need help in resolving the below problem- I would like to get the whole comma separated string into an array value- 1. $postText = chapters 5, 6, 7, 8; OR 2. $postText = chapters 5, 6; OR 3. $postText = chapters 5, 6, 7; What i have done so far is- preg_match('/chapter[s]*[ ]*(\d+, \d+, \d+)/i', $postText, $matches); The above will exactly match the third value $postText = chapters 5, 6, 7; By Above $matches will contain a value of : $matches[1] = '5, 6, 7'; Now i need a SINGLE regular expression which can match first, second variable above or any number of comma separated string and IMPORTANTLY provide me that whole comma separated sting value (as above) in single array key element like below- $matches[1] = '5, 6, 7'; OR $matches[1] = '5, 6'; OR $matches[1] = '5, 6, 7, 8, 9'; Also I have to use regular expression only as the flow of the code does not permit to use any other method to get comma separated string from the master/base string. Thanks, Gaurav Kumar
Re: [PHP] Character Encoding for em-dash
Thanks Tedd, but I cant make this change in the application UI level code for this problem. This application is a SAAS and we have certain quality standards which we need to follow.. Any other suggestion? Thanks, -GK On Sun, Jun 27, 2010 at 3:06 AM, tedd tedd.sperl...@gmail.com wrote: At 9:03 PM +0530 6/17/10, Gaurav Kumar wrote: Hi All, My client has a database (Sybase) in which a table column URL contains a string like- http://www.pjonline.com/cpd/nutrition_ _drugnutrient_interactions The box like un-recognized character is emdash. I need to display the data on the web lets say in a HTML page where box should be decoded somehow to be displayed as emdash. We cant change anything in the dataabse as such. So anything we need to do has to be done on the fly. I have tried using online tool like http://2cyr.com/decode/ which just converts the string to a best match decoded string and also displays box as emdash!! This means we can do something in PHP to convert the box to emdash somehow. Is there any possibility in php to convert to real emdash? I have alreasy tried urldecode, mb_convert_encoding etc. Also the interesting thing is that http://2cyr.com/decode/; website says that the string is of encoding hp-roman8! I want the string to look like- http://www.pjonline.com/cpd/nutrition_-- _prescribing_parenteral_nutrition.html Any help? Thanks, Gaurav Kumar Gaurav: When you encounter the emdash, used mdash; to display it in html. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com
Re: [PHP] Quick session question
Danny, I just read the email trail regarding your problem. The very first thing- 1. Session are stored as a file on the server in a folder. Check that the folder has read/*write* permission. (/tmp/ folder) 2. Check on the server that are the sessions really getting saved on the server? 3. Now in case you do not have access to a sessions folder on the server then set the session folder name/path to the folder (a new one) you can have access to (may be root of your ftp) using session_save_path('/httpdocs/'your-domain-folder/new-session-folder) (provide read/write permission) before session_start() in index.php or common header include file. This session_save_path() should be declared on every file on the top. Try the above and let me know if it works. Thanks, Gaurav Kumar http://blog.OsWebStudio.Com On Thu, Jun 24, 2010 at 7:54 PM, Danny dannydeb...@gmail.com wrote: Hi guys, I always start new projects with the following session code-snippet: (In other words this is how I initialize my sessions in the index.php file.) ### START CODE SNIPPET ?php session_start(); setcookie(session_name(),,0,/); unset($_COOKIE[session_name()]); $_SESSION = array(); session_unset(); session_destroy(); session_start(); /// Define some $_SESSION variables $_SESSION['sessionid'] = session_id() ; $_SESSION['server'] = http://localhost/~user/new_projecthttp://localhost/%7Euser/new_project ; $_SESSION['sql_dflts'] = $_SESSION['server']./sql/sql_dflts.inc ; $_SESSION['remoteaddr'] = $_SERVER['REMOTE_ADDR'] ; $_SESSION['remotehost'] = gethostbyaddr ( $_SERVER['REMOTE_ADDR'] ) ; /// Include Files include ( $_SESSION['sql_dflts'] ) ; include ( $_SESSION['server']./fnc/fnc_include_dir.inc ) ; $var_include_dir = include_dir ( fnc ) ; ? ### END CODE SNIPPET # All of the projects I have done so far were for business intranet purposes and it worked fine. But last week I uploaded another project to the internet and my sessions did not work. I have been using it this way since v4.0 (I think, anyway since a LONG time ago), but now I think it is a bit outdated and needs some kind of revision. Is this still sufficient or can you guys give some tips on a more updated way of starting my sessions? My php.ini file is stock-standard. I am running version 5.2.6-1 with apache 2.2.9 on a Debian 5.04 machine. Thank You Danny -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Character Encoding for em-dash
Hi All, My client has a database (Sybase) in which a table column URL contains a string like- http://www.pjonline.com/cpd/nutrition_ _drugnutrient_interactions The box like un-recognized character is emdash. I need to display the data on the web lets say in a HTML page where box should be decoded somehow to be displayed as emdash. We cant change anything in the dataabse as such. So anything we need to do has to be done on the fly. I have tried using online tool like http://2cyr.com/decode/ which just converts the string to a best match decoded string and also displays box as emdash!! This means we can do something in PHP to convert the box to emdash somehow. Is there any possibility in php to convert to real emdash? I have alreasy tried urldecode, mb_convert_encoding etc. Also the interesting thing is that http://2cyr.com/decode/; website says that the string is of encoding hp-roman8! I want the string to look like- http://www.pjonline.com/cpd/nutrition_-- _prescribing_parenteral_nutrition.html Any help? Thanks, Gaurav Kumar
[PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi All, Ash, Angelo, Any ideas how to send an email in PHP on windows platform/xp on local development machine. System Configuration PHP 5.2 Apache 2 No ISS NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Thanks, Gaurav Kumar blog.oswebstudio.com
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk
Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS
Hi Richard, The problem is that if I am using any open source software or any other pre-built software then I will not be able to manage through ini_set. 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/ Thanks, Gaurav Kumar blog.oswebstudio.com On Fri, Jan 15, 2010 at 6:21 PM, Richard Quadling rquadl...@googlemail.comwrote: 2010/1/15 vikash.i...@gmail.com: You can install any smtp server on your windows machine and the mail() will work with default settings. You can check this out: http://www.softstack.com/freesmtp.html Thanks, Vikash Kumar http://vika.sh On Fri, Jan 15, 2010 at 5:30 PM, Gaurav Kumar kumargauravjuke...@gmail.comwrote: Sorry Kim, don't want to use phpmailer script or manually setting user accounts u/p in the script. On Fri, Jan 15, 2010 at 5:23 PM, Kim Madsen php@emax.dk wrote: Hi Gaurav Gaurav Kumar wrote on 15/01/2010 09:54: NO SMTP Any trusted SMTP software to install on local development machine and how to set it up with php to send an email? Also just providing the SMTP server details in php.ini will not work for me as this requires authentication/credentials etc.. Get PHPmailer and make a gmail account that you connect to and mail through. -- Kind regards Kim Emax - masterminds.dk You only need a local SMTP server if you want to hold and relay mail. If you want to send mail directly to the recipients SMTP server you can do that with standard PHP. getmxrr() is your friend here. You provide it with the domain of the recipient and you get back the SMTP server(s) associated with that domain. Now, you can send the message to THEIR smtp server ... ini_set('SMTP', ); where is one of the servers returned from getmxrr(). No authentication required. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
Re: [PHP] Open source project management tool - PHP
OK one more the list http://dotproject.net/ Its a nice one with all project management features. Easy to use. Just checkout the website. Gaurav Kumar blog.oswebstudio.com On Fri, Dec 18, 2009 at 12:16 AM, Robert Cummings rob...@interjinn.comwrote: Angelo Zanetti wrote: Hi guys I would like to know what open source project management tools you use for your projects. We are looking at installing one that is PHP based and is easy to use. We have found: http://www.projectpier.org/ and http://trac.edgewall.org/ Has anyone used the above and how did you find them? Also are there any others you would recommend or not recommend and why? I use Mantis for most bug tracking needs. However, I've recently rolled out OpenGoo for a couple of different clients. http://fengoffice.com/web/community/community_index.php Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
Sorry buddy, I cant think of anything else which is going on wrong. 2009/12/14 René Fournier m...@renefournier.com PHP Version 5.3.0 Directive Local Value Master Value allow_call_time_pass_reference Off Off allow_url_fopen On On 2009-12-14, at 12:26 AM, Gaurav Kumar wrote: What is the value for allow_url_fopenhttp://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen in your php.ini? It should be 1. 2009/12/13 René Fournier m...@renefournier.com CURL works (remote and local) file_get_contents() doesn't work (remote or local). On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote: Ok Agreed. Lets do one last chance to ensure that your system is allowing external connections or connection to other systems in the network- Use Curl to get in the file contents. Check your PHP that Curl is enabled. Through phpinfo(); If the script output the google page then this means that there is nothing that is stopping you form getting in the content externally. ?php // $str = file_get_contents ('http://www.google.com'); // echo $str; // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, http://www.google.co.in;); // http://www.google.com curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ? Thanks, Gaurav Kumar 2009/12/13 René Fournier m...@renefournier.com The thing is, the file_get_contents() fails the same way on local URLs -- that is, web sites hosted on the same machine. Or even using the machine's own IP address. On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote: Hi Rene, The only thing which is a hurdle is that your system/computer is not allowing external connections. There seems to be nothing else wrong. I strongly suggest check your system firewall, any central server settings through which your system gets internet access, any antivirus s/w installed etc.. this can be the only reason. Something is stopping you to access external connection. Let me know when your problem is fixed. Also I tried the below code and it works fine- ?php $str = file_get_contents ('http://www.google.com'); echo $str; ? Thanks, Gaurav Kumar 2009/12/11 René Fournier m...@renefournier.com Hi Gaurav, On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote: A very typical problem. Good you sent the error message. This problem can be caused due to one of the following- 1. I have faced similar problem due to local firewall settings. Don't think this is it, since (1) the firewall settings haven't changed, and (2) other machines on the same network can execute this same code and function (but they aren't running OS X Server 10.6. 2. Try some other domain; i.e. other than google com. Try some of the local area website with a particular page like www.somedomain.com/somefile.html I've tried many different external and local web sites, and they all fail. 3. Some times the remote host does not allow you to connect to get the file contents. (Also not the cause -- as explained above.) 4. # 3 can be either way round from both the ends a) you host server does not allow external connections b) Remote host does not allow anonymous connection. Thanks for the options. I don't think they apply in this case. If you have any other suggestions on what to do, I would welcome them. Gaurav Kumar blog.oswebstudio.com On Thu, Dec 10, 2009 at 9:01 PM, René Fournier m...@renefournier.comwrote: I thought error_reporting would display them, but I guess php.ini had them suppressed. Anyway, with: ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); var_dump (file_get_contents ('http://www.google.com')); ? I get: Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in //.php on line 7 bool(false) Does that help with the diagnosis? On 2009-12-10, at 12:28 AM, Richard Quadling wrote: 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
Ok Agreed. Lets do one last chance to ensure that your system is allowing external connections or connection to other systems in the network- Use Curl to get in the file contents. Check your PHP that Curl is enabled. Through phpinfo(); If the script output the google page then this means that there is nothing that is stopping you form getting in the content externally. ?php // $str = file_get_contents ('http://www.google.com'); // echo $str; // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, http://www.google.co.in;); // http://www.google.com curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ? Thanks, Gaurav Kumar 2009/12/13 René Fournier m...@renefournier.com The thing is, the file_get_contents() fails the same way on local URLs -- that is, web sites hosted on the same machine. Or even using the machine's own IP address. On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote: Hi Rene, The only thing which is a hurdle is that your system/computer is not allowing external connections. There seems to be nothing else wrong. I strongly suggest check your system firewall, any central server settings through which your system gets internet access, any antivirus s/w installed etc.. this can be the only reason. Something is stopping you to access external connection. Let me know when your problem is fixed. Also I tried the below code and it works fine- ?php $str = file_get_contents ('http://www.google.com'); echo $str; ? Thanks, Gaurav Kumar 2009/12/11 René Fournier m...@renefournier.com Hi Gaurav, On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote: A very typical problem. Good you sent the error message. This problem can be caused due to one of the following- 1. I have faced similar problem due to local firewall settings. Don't think this is it, since (1) the firewall settings haven't changed, and (2) other machines on the same network can execute this same code and function (but they aren't running OS X Server 10.6. 2. Try some other domain; i.e. other than google com. Try some of the local area website with a particular page like www.somedomain.com/somefile.html I've tried many different external and local web sites, and they all fail. 3. Some times the remote host does not allow you to connect to get the file contents. (Also not the cause -- as explained above.) 4. # 3 can be either way round from both the ends a) you host server does not allow external connections b) Remote host does not allow anonymous connection. Thanks for the options. I don't think they apply in this case. If you have any other suggestions on what to do, I would welcome them. Gaurav Kumar blog.oswebstudio.com On Thu, Dec 10, 2009 at 9:01 PM, René Fournier m...@renefournier.comwrote: I thought error_reporting would display them, but I guess php.ini had them suppressed. Anyway, with: ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); var_dump (file_get_contents ('http://www.google.com')); ? I get: Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in //.php on line 7 bool(false) Does that help with the diagnosis? On 2009-12-10, at 12:28 AM, Richard Quadling wrote: 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')http://www.google.com/%27%29 ); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence Do you
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
What is the value for allow_url_fopenhttp://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen in your php.ini? It should be 1. 2009/12/13 René Fournier m...@renefournier.com CURL works (remote and local) file_get_contents() doesn't work (remote or local). On 2009-12-13, at 4:39 PM, Gaurav Kumar wrote: Ok Agreed. Lets do one last chance to ensure that your system is allowing external connections or connection to other systems in the network- Use Curl to get in the file contents. Check your PHP that Curl is enabled. Through phpinfo(); If the script output the google page then this means that there is nothing that is stopping you form getting in the content externally. ?php // $str = file_get_contents ('http://www.google.com'); // echo $str; // create a new cURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, http://www.google.co.in;); // http://www.google.com curl_setopt($ch, CURLOPT_HEADER, 0); // grab URL and pass it to the browser curl_exec($ch); // close cURL resource, and free up system resources curl_close($ch); ? Thanks, Gaurav Kumar 2009/12/13 René Fournier m...@renefournier.com The thing is, the file_get_contents() fails the same way on local URLs -- that is, web sites hosted on the same machine. Or even using the machine's own IP address. On 2009-12-13, at 4:00 AM, Gaurav Kumar wrote: Hi Rene, The only thing which is a hurdle is that your system/computer is not allowing external connections. There seems to be nothing else wrong. I strongly suggest check your system firewall, any central server settings through which your system gets internet access, any antivirus s/w installed etc.. this can be the only reason. Something is stopping you to access external connection. Let me know when your problem is fixed. Also I tried the below code and it works fine- ?php $str = file_get_contents ('http://www.google.com'); echo $str; ? Thanks, Gaurav Kumar 2009/12/11 René Fournier m...@renefournier.com Hi Gaurav, On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote: A very typical problem. Good you sent the error message. This problem can be caused due to one of the following- 1. I have faced similar problem due to local firewall settings. Don't think this is it, since (1) the firewall settings haven't changed, and (2) other machines on the same network can execute this same code and function (but they aren't running OS X Server 10.6. 2. Try some other domain; i.e. other than google com. Try some of the local area website with a particular page like www.somedomain.com/somefile.html I've tried many different external and local web sites, and they all fail. 3. Some times the remote host does not allow you to connect to get the file contents. (Also not the cause -- as explained above.) 4. # 3 can be either way round from both the ends a) you host server does not allow external connections b) Remote host does not allow anonymous connection. Thanks for the options. I don't think they apply in this case. If you have any other suggestions on what to do, I would welcome them. Gaurav Kumar blog.oswebstudio.com On Thu, Dec 10, 2009 at 9:01 PM, René Fournier m...@renefournier.comwrote: I thought error_reporting would display them, but I guess php.ini had them suppressed. Anyway, with: ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); var_dump (file_get_contents ('http://www.google.com')); ? I get: Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in //.php on line 7 bool(false) Does that help with the diagnosis? On 2009-12-10, at 12:28 AM, Richard Quadling wrote: 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')http://www.google.com/%27%29 ); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
Hi Rene, The only thing which is a hurdle is that your system/computer is not allowing external connections. There seems to be nothing else wrong. I strongly suggest check your system firewall, any central server settings through which your system gets internet access, any antivirus s/w installed etc.. this can be the only reason. Something is stopping you to access external connection. Let me know when your problem is fixed. Also I tried the below code and it works fine- ?php $str = file_get_contents ('http://www.google.com'); echo $str; ? Thanks, Gaurav Kumar 2009/12/11 René Fournier m...@renefournier.com Hi Gaurav, On 2009-12-11, at 2:55 PM, Gaurav Kumar wrote: A very typical problem. Good you sent the error message. This problem can be caused due to one of the following- 1. I have faced similar problem due to local firewall settings. Don't think this is it, since (1) the firewall settings haven't changed, and (2) other machines on the same network can execute this same code and function (but they aren't running OS X Server 10.6. 2. Try some other domain; i.e. other than google com. Try some of the local area website with a particular page like www.somedomain.com/somefile.html I've tried many different external and local web sites, and they all fail. 3. Some times the remote host does not allow you to connect to get the file contents. (Also not the cause -- as explained above.) 4. # 3 can be either way round from both the ends a) you host server does not allow external connections b) Remote host does not allow anonymous connection. Thanks for the options. I don't think they apply in this case. If you have any other suggestions on what to do, I would welcome them. Gaurav Kumar blog.oswebstudio.com On Thu, Dec 10, 2009 at 9:01 PM, René Fournier m...@renefournier.comwrote: I thought error_reporting would display them, but I guess php.ini had them suppressed. Anyway, with: ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); var_dump (file_get_contents ('http://www.google.com')); ? I get: Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in //.php on line 7 bool(false) Does that help with the diagnosis? On 2009-12-10, at 12:28 AM, Richard Quadling wrote: 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')http://www.google.com/%27%29 ); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence Do you have ANY errors/warning/notices? -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
Re: [PHP] file_get_contents ($file) works -- file_get_contents ($url) returns false
A very typical problem. Good you sent the error message. This problem can be caused due to one of the following- 1. I have faced similar problem due to local firewall settings. 2. Try some other domain; i.e. other than google com. Try some of the local area website with a particular page like www.somedomain.com/somefile.html 3. Some times the remote host does not allow you to connect to get the file contents. 4. # 3 can be either way round from both the ends a) you host server does not allow external connections b) Remote host does not allow anonymous connection. Hope this helps.. Gaurav Kumar blog.oswebstudio.com On Thu, Dec 10, 2009 at 9:01 PM, René Fournier m...@renefournier.com wrote: I thought error_reporting would display them, but I guess php.ini had them suppressed. Anyway, with: ?php error_reporting(-1); ini_set('display_errors', 1); set_time_limit(0); var_dump (file_get_contents ('http://www.google.com')); ? I get: Warning: file_get_contents(http://www.google.com): failed to open stream: Operation now in progress in //.php on line 7 bool(false) Does that help with the diagnosis? On 2009-12-10, at 12:28 AM, Richard Quadling wrote: 2009/12/9 René Fournier m...@renefournier.com: It is, and I use curl elsewhere in the same script to fetch remote content. This exact same function works fine on my MacBook Pro (10.6 client, PHP 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3, On 2009-12-09, at 11:10 PM, laruence wrote: try wget http://www.google.com in your command line to see whether the network is reachable LinuxManMikeC wrote: On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC linuxmanmi...@gmail.com wrote: On Wed, Dec 9, 2009 at 6:45 AM, René Fournier m...@renefournier.com wrote: Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3. Any call of file_get_contents() on a local file works fine -- the file is read and returned. But any call of file_get_contents on a url -- any url, local or remote -- always returns false. var_dump (file_get_contents ('http://www.google.com/')http://www.google.com/%27%29 ); bool(false) I've checked php.ini, and the obvious seems okay: allow_url_fopen = On = On Any ideas? ...Rene http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen I've checked php.ini Right, must remember not to reply to stuff till I'm awake. :-D -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- 2866791487_dbbbdddf9e.jpg惠 新宸 xinchen.hui | 商务搜索部 | (+8610)82602112-7974 | 2866349865_203e53a6c6.jpg:laruence Do you have ANY errors/warning/notices? -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
Re: [PHP] Upload dir
OK you used ini_get try using ini_set and set the temporary directory on your server of your choice at run time in your script (top of the script or any config file if you have one). REMEMBER that you have access to that directory, should have full permissions and also check the absolute server path is correct while you set the directory. More information on how to use ini_set to set the directory path- try googling... Gaurav Kumar blog.oswebstudio.com On Fri, Dec 11, 2009 at 10:59 AM, kranthi kranthi...@gmail.com wrote: How can i change the temporary upload directory? var_dump(ini_get('upload_tmp_dir')); gives me (and that is set in php.ini) string '/var/www/cgi-bin' (length=16) but var_dump($_FILES) gives me 'tmp_name' = string '/tmp/phpbSZ6WP' (length=14) var_dump(file_exists($_FILES['file']['tmp_name'])); gives me (/tmp has permissions drwxrwxrwt and i never used file_move_upload or any similar functions) boolean false am I missing something here? Kranthi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Force-Saving an Audio File
You can do two things- 1. Read the file by providing a base directory path of the server where the file exist. Something like- //htdocs/httpfolder/files/audio/yourfile.mp3 You can take this in a variable //htdocs/httpfolder/files/audio/. 2. Try using file_get_contents. Something like $file = file_get_contents(' http://www.example.com/audio/file.mp3', false, $context); Hope this helps. Gaurav Kumar Blog.OsWebStudio.com On Wed, Dec 9, 2009 at 8:06 AM, c...@hosting4days.com c...@hosting4days.com wrote: Hi folks, I'm trying to force save .mp3 files so this is a test page (found on the net). It works fine when: $directory = ; // so the audio is in the same local directory but fails when I use a REAL web directory - (the audio file is here - http://mysite.com/test1/audio.mp3 ) $directory = http://mysite.com/test1/;; says - The file $file was not found. Q: Any ideas how to get it to download from the website? = ?php $file = 'audio1.mp3'; $directory = http://mysite.com/test1/;; //$directory = ; $path = $directory$file; if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); $file_extension = strtolower(substr(strrchr($path,.),1)); if( $file == ) { echo html head titleFile not found./title /head body File not found. /body /html; exit; } elseif (! file_exists( $path ) ) { echo html head titleThe file $file was not found./title /head body The file $file was not found.br / - path - $path /body /html;exit; }; switch( $file_extension ) { case pdf: $ctype=application/pdf; break; case zip: $ctype=application/zip; break; case doc: $ctype=application/msword; break; case xls: $ctype=application/vnd.ms-excel; break; case ppt: $ctype=application/vnd.ms-powerpoint; break; case gif: $ctype=image/gif; break; case png: $ctype=image/png; break; case jpeg: case jpg: $ctype=image/jpg; break; case wav: case mp3: $ctype=application/iTunes; break; default: $ctype=application/force-download; } header(Pragma: public); header(Expires: 0); header(Cache-Control: must-revalidate, post-check=0, pre-check=0); header(Cache-Control: private,false); header(Content-Type: $ctype); header(Content-Disposition: attachment; filename=\.basename($path).\; ); header(Content-Transfer-Encoding: binary); header(Content-Length: .filesize($path)); readfile($path); exit(); ? Thanks, c...@hosting4days.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Correct handling _POST[] and implode. PHP5
Its Simple... Its very obvious that $_POST[color] is not an array. do something like this and you wil get the values. $arr_color = $_POST[colors]; //iterate over the array foreach($arr_color as $val) { $str_color .= , . $val; } You are done. Gaurav Kumar Teach Lead Open Source Technologies On Fri, Oct 9, 2009 at 11:14 AM, bearsfoot adam.p.reyno...@gmail.comwrote: Hi all, I have a form that has has an array of information. Mulitple checkboxes can be selected. Choose the colors: input type=checkbox name=Colors[] value=green checked=checked / Green input type=checkbox name=Colors[] value=yellow / Yellow input type=checkbox name=Colors[] value=red / Red input type=checkbox name=Colors[] value=gray / Gray When processing the form.. echo $_POST['Colors'] . 'br /'; // outputs 'Array' if ( isset($_POST['Colors']) ) { $_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string } echo Colors you chose: {$_POST['Colors']}br /; I get the following error when using the implode function. Warning: implode() [function.implode]: Bad arguments What I doing wrong ? Thanks in advance. -- View this message in context: http://www.nabble.com/Correct-handling-_POST---and-implode.-PHP5-tp25815789p25815789.html Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Apache Rewrite Issues
Hey Russell, After Going through all the threads in this post, it is correct to say, GET Rid of the space. Use - hyphen for SEO friendly URL's. Its completely OK. Other thing which is very handy is urlencode and urldecode functions. When you are sending a query string use urlencode function. This will preserve the query string variable as Test Story and not as just Test; even if there are spaces in the variable. Gaurav Kumar Tech Lead Open Source Solutions On Wed, Oct 7, 2009 at 4:22 PM, Russell Seymour russell.seym...@turtlesystems.co.uk wrote: Morning, I am trying to make my URLs more search engine friendly and I have come up against a problem. I want the following URL: mysite.example.com/articles/Test Story to be proxied to mysite.example.com/index.php?m=articlest=Test%20Story I have the following rule in my Apache conf RewriteRule ^/articles/(.*) index.php?m=articlest=$1 [P,L] Now if I run with this configuration, PHP strips the query string back at the space, so my query string ends up looking like [QUERY_STRING] = m=articlest=Test even though the log file for the rewrite shows that the full query is being passed. But if I change the RewriteRule to be a Rewrite instead of a Proxy I get [QUERY_STRING] = m=articlest=Test%20Story So something is happening when the system is proxying the request. Adding %20 into the URL does not fix the problem when proxy is enabled either. I have search around on the Internet, and people talk about using urlencode etc, this is fine when PHP is creating the URL but not when Apache is doing the rewrite. I apologise if people feel this is on the wrong list, but as far as I can tell from the rewrite logs the data is coming all the way through to PHP which is truncating it. This is purely my observation. Apache version: 2.2.11 PHP Version:5.3.0 Any help is gratefully recieved. Thanks, Russell
Re: [PHP] avoid Denial of Service
Not sure what exactly you are looking for. Anyways, some common practice are request for API key, username / password tokens before providing access to a service. Thanks, Gaurav Kumar On Thu, Oct 8, 2009 at 7:06 PM, Gerardo Benitez gerardobeni...@gmail.comwrote: Hi everybody! I want to get some tips about how avoid a attack of Denial of service. May be somebody can about your experience with Php o some configuration of apache, o other software that help in these case. Thanks in advance. -- Gerardo Benitez
[PHP] Best Practice to Create Dynamic URL's- With Username
Hi All, I am creating a social networking website. I want that every user should have there own profile page with a static URL like- http://www.abcnetwork/user/username Where username will be dynamic userid or something else. This is something very similar to www.youtube.com/user/kumargauravmail (this is my profile page). So what should be the best practice to create such DYNAMIC URL's OR what kind of methodology youtube is following? Thanks in Advance. Gaurav Kumar OSWebstudio.com
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
A Big Thanks to all of you. Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. OK Ashley, Tommy and Ralph- 100% correct that mod_rewrite will be used. I am a bit sticky that my URL will be- http://www.abcnetwork/user/*Ashley*http://www.abcnetwork/user/username. So will I get $_GET[user] with value as *Ashley* or *Tommy* in my script? http://www.abcnetwork/userProfile.php?user=usernameSo what exactly will be the .htaccess rule for above? Thanks, Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 1:26 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Mon, 2009-09-21 at 13:24 +0530, Gaurav Kumar wrote: Hi All, I am creating a social networking website. I want that every user should have there own profile page with a static URL like- http://www.abcnetwork/user/username Where username will be dynamic userid or something else. This is something very similar to www.youtube.com/user/kumargauravmail(this is my profile page). So what should be the best practice to create such DYNAMIC URL's OR what kind of methodology youtube is following? Thanks in Advance. Gaurav Kumar OSWebstudio.com If you're working on an Apache server, your best bet is to look at mod_rewrite. You can write a simple rule to match against these sorts of URL formats, so that to your visitors it appears as if the actual path exists, but internally it can get translated to something like http://www.abcnetwork.com/profile.php?id=username Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi an_...@hotmail.comwrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk -- check out the rest of the Windows Live™. More than mail–Windows Live™ goes way beyond your inbox. More than messageshttp://www.microsoft.com/windows/windowslive/
Re: [PHP] Best Practice to Create Dynamic URL's- With Username
Thanks Ashley and all the folks out there... On Mon, Sep 21, 2009 at 3:25 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: On Mon, 2009-09-21 at 15:20 +0530, Gaurav Kumar wrote: I totally agree with this architecture. You are correct, I am just in the starting phase of the project and in fact still need to define the architecture in detail. Now the question I asked in my last reply is still to be answered? Gaurav Kumar OSWebstudio.Com On Mon, Sep 21, 2009 at 3:06 PM, Andrea Giammarchi an_...@hotmail.com wrote: Question I was Asked by Andrea- mod_reqrite or .htaccess is the answer, but I wonder why you choose /user/username rather than just /username a la twitter. I will be using many other aspects of my users something like /projects/username/; /gallery/username/. well, it does not matter if this service is user based. /username/ #as user home page /username/projects/ #as user projects /username/gallery/ #as user gallery /username/etc ... it's just a silly point but from user home page you isntantly know if user exists and you instantly know subsections In your way you assume that there is a gallery for that user while he could have created only projects, without galleries. So one search failed, while to go in the user page I need to digit /user/ before, not a big deal but we are in tinyurl and bit.ly era Google Code put simply a /p/ as prefix plus the project name plus subsection /p/myprojname/ /p/myprojname/wiki since you are starting now, maybe you could consider this semantic alternative, if it suits your requirements. Regards Thanks, Ash http://www.ashleysheridan.co.uk __ check out the rest of the Windows Live™. More than mail– Windows Live™ goes way beyond your inbox. More than messages For help with the mod_rewrite, a Google search never goes amiss, first result I found for 'mod_rewrite example' is http://www.workingwith.me.uk/articles/scripting/mod_rewrite . I looked at it quickly and it does cover what you need. As for what you get as $_GET parameters, that's entirely up to you, and as you will see from the above link, it's fairly simple to mess about with. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] best function to use ~ file_get_contents or ?
There is no best function as such. Everything depends upon your requirement. You can also use fopen() to get the contents of the remote file and do some error handling that if you get any content then display image else a message etc.. Gaurav Kumar (Team Lead- open source) oswebstudio.com On Wed, Sep 16, 2009 at 4:06 AM, CRM c...@globalissa.com wrote: Hi All, Not sure of the best approach, need your feedback. I have 4 images on a website. These are used in navigation. When I load a reference webpage on my local machine the local page calls 4 images from an external website, each image will be on a different domain. What I want to see is if the navigation images/buttons can be loaded/displayed in my browser. If they can, then I will display the images on my local page. If the images cannot be loaded, then this indicates some connection issue and the result will be some text like 'Site Offline'. So just by glancing at my local machine reference page I can tell if one or more of the different sites is or is not available. So what is the best function to use? if ( @file_get_contents( DOMAIN_PATH . images/navigation/nav_globalissa.png )): or ??? Please also cc i...@globalissa.com Thanks for any helpful suggestions. Sincerely, Rob Global I.S. S.A. Software Powers the Net Email: crm at globalissa dot com * * * The Forge of Globalissa ~ PHP Foobar Machine * * * http://globalissa.com/forge/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php