[PHP] Re: How to download a multi-part file at the server side?
I just came across http://www.w3schools.com/php/php_file_upload.asp, and tested it.. It works fine, when the file is uploaded via a form. It does seem that the client-method might indeed play a role. Here is my Java code for uploading the file :: ### HttpClient httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1); HttpPost httppost = new HttpPost(URL); File file = new File(/path/to/png/file.png); // Send the image-file data as a Multipart-data. MultipartEntity mpEntity = new MultipartEntity(); ContentBody cbFile = new FileBody(file, image/png); mpEntity.addPart(userfile, cbFile); httppost.setEntity(mpEntity); HttpResponse response = httpclient.execute(httppost); ### Any ideas if making a change at the client (Java) OR/AND server (PHP) might do the trick? On Sat, Nov 2, 2013 at 6:06 PM, Ajay Garg ajaygargn...@gmail.com wrote: Hi all. I intend to implement a use-case, wherein the client uploads a file in multi-part format, and the server then stores the file in a mysql database (after downloading it at the server side). I have been unable to find any immediate answers through googling; I will be grateful if someone could start me in a direction to achieve the downloading at server via php requirement. (Don't think it should matter, but I use Java to upload a file in multi-part format). I will be grateful for some pointers. Thanks in advance Thanks and Regards, Ajay -- Regards, Ajay
[PHP] Re: How to upstream code changes to php community
Shahina Rabbani wrote: Hi, I have done some modifications to the php source code and i tested it with php bench and I observed some improvement. I wanted to upstream these code changes to PHP community. I searched the wed but i didnt find proper guide to upstream the code to php. Please help me by providing the information how to upstream my code changes to php source code community. Thanks, Shahina Rabbani Start with https://github.com/php/php- src/blob/master/README.SUBMITTING_PATCH which is linked from the Community menu item on the PHP home page. -- Cheers David Robley Enter any 11-digit prime number to continue... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to see all sessions sets in server
Il Sun, 04 Aug 2013 20:47:37 +0430, Farzan Dalaee ha scritto: Please use better quoting. So best way is use a script(javascript) to send ajax to server every 5 second to check users is logged in or not? Is that okey? It depends. I want to write chat module like facebook and i need a solution to find online users and way to send messages when users chat together, does any one write similar module like that? Then knowing who is online is maybe the last of your problems. You have to find a way to send the message to user B when user A writes something. You absolutely need javascript. You just need to find out how to connect to the server. Have a look at socket.io, and find a php library that supports it. I think it is the easiets way. Be aware that the load on your server will be huge, growing exponentially with the number of online users. You can't escape it, except by using different technologies (XMPP as a protocol, with a javascript client, or using node.js with socket.io, for example) Bye. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to see all sessions sets in server
Il Sun, 04 Aug 2013 13:32:55 +0430, Farzan Dalaee ha scritto: hi i want to write online user module for my site and i want to check $_SESSION['userID'] to find all users id who loged in but when i echo this code its return only current user detail how i can see all sessions? You can't. or how i handle online users? Every user has its session. If you want to have a super user who has access to all the sessions, you can use the filesystem functions to read the directory in which the sessions get saved (it depends on the server configuration) or you can implement a session handler to save all the sessions in the database, and give access to that table to one user. Bye. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to see all sessions sets in server
On 04 Aug 2013 at 11:28, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Like Matijn said, unless you're using some kind of client-side method to continually poll the server, you can't know if they've just closed their browser. There are Javascript events for exiting a page, but they don't work correctly on Safari and iOS Safari. onbeforeunload works fine in Safari; I use it all the time. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to see all sessions sets in server
On Sun, 2013-08-04 at 13:27 +0100, Tim Streater wrote: On 04 Aug 2013 at 11:28, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Like Matijn said, unless you're using some kind of client-side method to continually poll the server, you can't know if they've just closed their browser. There are Javascript events for exiting a page, but they don't work correctly on Safari and iOS Safari. onbeforeunload works fine in Safari; I use it all the time. -- Cheers -- Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Apparently it has problems when browsing in porn mode, and mobile safari has major problems with it. I'm basing this on previous posts on forums I've been on, so it might have been fixed now, but I don't know for sure either way. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: How to delete 3 months old records in my database?
On 8/2/2013 6:58 AM, Karl-Arne Gjersøyen wrote: Hello again, folks! I wish to delete records in my database that is older than 3 months. $todays_date = date('Y-m-d'); $old_records_to_delete = ??? if($old_records_to_delete){ include(connect.php); $sql = DELETE FROM table WHERE date = '$old_records_to_delete'; mysql_query($sql, $connect_db) or die(mysql_error()); } Thank you very much for your help to understand also this question :) Karl So close! BUT - you need to reverse your test. where date = '$old_records_to_delete' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to extract php source code from joomla
On Jul 23, 2013, at 12:15 AM, elk dolk elkd...@yahoo.com wrote: I study for MSc degree at university. Are you in an advanced class? Ok, congratulations -- you are studying for an MSc -- but that didn't answer the question. So, let me repeat the question: [1] Are you in an advanced PHP class? [2] Or is this just an introductory class? If [1], then the coursework might be understandable, but still very difficult. If [2], that is far more than what I teach as an Introduction to PHP course. tedd _ tedd.sperl...@gmail.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to enable cURL php extension on Debian Wheezy?
Csanyi Pal csanyi...@gmail.com wrote: Tamara Temple tamouse.li...@gmail.com writes: Csanyi Pal csanyi...@gmail.com wrote: It is interesting.. that when I switch to English language for Moodle installation ( on the web interface ), then I get not this error, but if I switch back to Hungarian language for installation, I get it again. I am completely unfamiliar with Moodle, have no idea what it is or how it works with I18n stuff. But, if it works in one language and not the other, the problem probably isn't with curl, or necessarily with the php configuration, either. It doesn't work in Englis language either, just at this step of Moodle installation on the web interface, it doesn't complain for the missing cURL extension. But, when I proceed with the installation in English language, I come to the step where it shows up again the missing cURL extension. Ah, I'm sorry, my misundertanding. When you switch to Hungarian, what are the actual errors you are seeing? Stick the log in a gist or pastebin so it doesn't get mangled by email. I get no error message at this step of Moodle installation, when I use Hungarian language. The info.php file with the content of: ? phpinfo(); ? should show the enabled cURL extension? I missed this one, somehow. Yes, exactly, the cURL module should show up on phpinfo() output. Well, the phpinfo() output doesn't show up the cURL module yet. I have the following directories and files in the /etc/php5/ directory: /apache2 directory with the content: php.ini file /conf.d subdirectory with the content: gd.ini .. xcache.ini But here I don't have curl.ini xmlrpc.ini and I think that that it should be here curl.ini, xmlrpc.ini Why is not here curl.ini? My ../apache2/conf.d directory is a symlink to the ../conf.d directory. This might indeed be the problem. Not to make *your* ../apache2/conf.d a symlink, but to put symlinks inside it to the .ini files you need in ../conf.d. Give that go, and see? I'm sorry I'm not much better help -- this all came out of the box the way I needed it and I didn't think about it much. /conf.d directory with the content: @10-pdo.ini @20-curl.ini .. @20-xmlrpc.ini ldap.ini /mods-available subdirectory with the files: curl.ini .. xmlrpc.ini /cgi directory /cli directory -- Regards from Pal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to enable cURL php extension on Debian Wheezy?
Tamara Temple tamouse.li...@gmail.com writes: Csanyi Pal csanyi...@gmail.com wrote: Tamara Temple tamouse.li...@gmail.com writes: Csanyi Pal csanyi...@gmail.com wrote: It is interesting.. that when I switch to English language for Moodle installation ( on the web interface ), then I get not this error, but if I switch back to Hungarian language for installation, I get it again. I am completely unfamiliar with Moodle, have no idea what it is or how it works with I18n stuff. But, if it works in one language and not the other, the problem probably isn't with curl, or necessarily with the php configuration, either. It doesn't work in Englis language either, just at this step of Moodle installation on the web interface, it doesn't complain for the missing cURL extension. But, when I proceed with the installation in English language, I come to the step where it shows up again the missing cURL extension. Ah, I'm sorry, my misundertanding. OK When you switch to Hungarian, what are the actual errors you are seeing? Stick the log in a gist or pastebin so it doesn't get mangled by email. I get no error message at this step of Moodle installation, when I use Hungarian language. The info.php file with the content of: ? phpinfo(); ? should show the enabled cURL extension? I missed this one, somehow. Yes, exactly, the cURL module should show up on phpinfo() output. Well, the phpinfo() output doesn't show up the cURL module yet. I have the following directories and files in the /etc/php5/ directory: /apache2 directory with the content: php.ini file /conf.d subdirectory with the content: gd.ini .. xcache.ini But here I don't have curl.ini xmlrpc.ini and I think that that it should be here curl.ini, xmlrpc.ini Why is not here curl.ini? My ../apache2/conf.d directory is a symlink to the ../conf.d directory. This might indeed be the problem. Yes. My system was Debian Squeeze and I just upgraded it to Debian Wheezy. Some configuration files and directories remains from Squeeze and probably cause this problem. Not to make *your* ../apache2/conf.d a symlink, but to put symlinks inside it to the .ini files you need in ../conf.d. Give that go, and see? I'm sorry I'm not much better help -- this all came out of the box the way I needed it and I didn't think about it much. Yes, that help me out. Now the phpinfo() funktion gives the cURL module enabled. /conf.d directory with the content: @10-pdo.ini @20-curl.ini .. @20-xmlrpc.ini ldap.ini /mods-available subdirectory with the files: curl.ini .. xmlrpc.ini /cgi directory /cli directory -- Regards from Pal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to enable cURL php extension on Debian Wheezy?
Csanyi Pal csanyi...@gmail.com wrote: Tamara Temple tamouse.li...@gmail.com writes: My ../apache2/conf.d directory is a symlink to the ../conf.d directory. This might indeed be the problem. Yes. My system was Debian Squeeze and I just upgraded it to Debian Wheezy. Some configuration files and directories remains from Squeeze and probably cause this problem. Okay, I've not made that particular upgrade; perhaps there something that doesn't quite go along smoothly there. Not to make *your* ../apache2/conf.d a symlink, but to put symlinks inside it to the .ini files you need in ../conf.d. Give that go, and see? I'm sorry I'm not much better help -- this all came out of the box the way I needed it and I didn't think about it much. Yes, that help me out. Now the phpinfo() funktion gives the cURL module enabled. Excellent! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to enable cURL php extension on Debian Wheezy?
Adam Szewczyk adam...@gmail.com writes: On Sat, Jun 01, 2013 at 09:41:33PM +0200, Csanyi Pal wrote: Hi, I just upgraded Squeeze to Wheezy, and have difficulties with cURL PHP extension: I can't enable it. I have installed following packages related to this issue: curl, libcurl3, libcurl3-gnutls, php5-curl. I have in /etc/php5/mods-available/curl.ini ; configuration for php CURL module ; priority=20 extension=curl.so I know that cURL extension is not enabled because I want to install Moodle and it complains about cURL extension. How can I solve this problem? Hi, what error message do you get? Also, have you restarted apache after installing the extension? Yes, I have restarted apache after installing the extension. It is interesting.. that when I switch to English language for Moodle installation ( on the web interface ), then I get not this error, but if I switch back to Hungarian language for installation, I get it again. The info.php file with the content of: ? phpinfo(); ? should show the enabled cURL extension? -- Regards from Pal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to enable cURL php extension on Debian Wheezy?
Tamara Temple tamouse.li...@gmail.com writes: Csanyi Pal csanyi...@gmail.com wrote: I have installed following packages related to this issue: curl, libcurl3, libcurl3-gnutls, php5-curl. All good. I have in /etc/php5/mods-available/curl.ini ; configuration for php CURL module ; priority=20 extension=curl.so Have you enabled the extension as well? That looks like the standard set-up, which means that curl.ini is available, but you still have to enable it. Check in /etc/php5/conf.d to see if there's a symlink in there, otherwise look through the various bits to see if it's included somewhere in one of the stock php.ini files. Yes, it's enabled, because I have in /etc/php5/conf.d/ directory the symbolic link @20-curl.ini that is pointing to - ../mods-available/curl.ini If you make changes here, ensure you restart your sever. I already restarted apache2 after I made changes there. Still get error message when want to proceed with Moodle installation: must be installed and enabled The cURL PHP extension is now required by Moodle, in order to communicate with Moodle repositories. and it is not OK, the Moodle installation procedure can't find the cURL extension. Why? -- Regards from Pal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to enable cURL php extension on Debian Wheezy?
Csanyi Pal csanyi...@gmail.com wrote: It is interesting.. that when I switch to English language for Moodle installation ( on the web interface ), then I get not this error, but if I switch back to Hungarian language for installation, I get it again. I am completely unfamiliar with Moodle, have no idea what it is or how it works with I18n stuff. But, if it works in one language and not the other, the problem probably isn't with curl, or necessarily with the php configuration, either. When you switch to Hungarian, what are the actual errors you are seeing? Stick the log in a gist or pastebin so it doesn't get mangled by email. The info.php file with the content of: ? phpinfo(); ? should show the enabled cURL extension? I missed this one, somehow. Yes, exactly, the cURL module should show up on phpinfo() output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to enable cURL php extension on Debian Wheezy?
Tamara Temple tamouse.li...@gmail.com writes: Csanyi Pal csanyi...@gmail.com wrote: It is interesting.. that when I switch to English language for Moodle installation ( on the web interface ), then I get not this error, but if I switch back to Hungarian language for installation, I get it again. I am completely unfamiliar with Moodle, have no idea what it is or how it works with I18n stuff. But, if it works in one language and not the other, the problem probably isn't with curl, or necessarily with the php configuration, either. It doesn't work in Englis language either, just at this step of Moodle installation on the web interface, it doesn't complain for the missing cURL extension. But, when I proceed with the installation in English language, I come to the step where it shows up again the missing cURL extension. When you switch to Hungarian, what are the actual errors you are seeing? Stick the log in a gist or pastebin so it doesn't get mangled by email. I get no error message at this step of Moodle installation, when I use Hungarian language. The info.php file with the content of: ? phpinfo(); ? should show the enabled cURL extension? I missed this one, somehow. Yes, exactly, the cURL module should show up on phpinfo() output. Well, the phpinfo() output doesn't show up the cURL module yet. I have the following directories and files in the /etc/php5/ directory: /apache2 directory with the content: php.ini file /conf.d subdirectory with the content: gd.ini .. xcache.ini But here I don't have curl.ini xmlrpc.ini and I think that that it should be here curl.ini, xmlrpc.ini Why is not here curl.ini? /conf.d directory with the content: @10-pdo.ini @20-curl.ini .. @20-xmlrpc.ini ldap.ini /mods-available subdirectory with the files: curl.ini .. xmlrpc.ini /cgi directory /cli directory -- Regards from Pal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to insert html code with PHP
On 4/11/2013 7:34 AM, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. How many pages are we talking about? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to insert html code with PHP
On 11.04.2013 14:14, Jim Giner wrote: On 4/11/2013 7:34 AM, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. How many pages are we talking about? This really depends on CMS itself and its templates -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to insert html code with PHP
On 11.04.2013 13:34, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. Ok i can write an include_once('myfile.php'); however if i have an array in this file, other files where is the include_once(); do not recognize the array. here is an extract of this file to include (submenu.php): ?php $submenu = array(); $submenu[] = array('id' = 1,'class'='menuitem1'); $submenu[] = array('id' = 2,'class'='menuitem2'); // function in the same file function DisplayMenu($title){ // here i do not have access to the previous array $submenu define outside the function ... } as it is included the function DisplayMenu should also have access to $submenu array, no ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to insert html code with PHP
On 4/11/2013 10:48 AM, Rafnews wrote: On 11.04.2013 13:34, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. Ok i can write an include_once('myfile.php'); however if i have an array in this file, other files where is the include_once(); do not recognize the array. here is an extract of this file to include (submenu.php): ?php $submenu = array(); $submenu[] = array('id' = 1,'class'='menuitem1'); $submenu[] = array('id' = 2,'class'='menuitem2'); // function in the same file function DisplayMenu($title){ // here i do not have access to the previous array $submenu define outside the function ... } as it is included the function DisplayMenu should also have access to $submenu array, no ? basic php question. Variables within any function are local to that function (except for superglobals like $_POST, $_SESSION, etc.). In order to reference a var defined/used outside that function you must add a global statement in the function: function () { global $submenu; ... ... } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to insert html code with PHP
On 11.04.2013 19:19, Jim Giner wrote: On 4/11/2013 10:48 AM, Rafnews wrote: On 11.04.2013 13:34, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. Ok i can write an include_once('myfile.php'); however if i have an array in this file, other files where is the include_once(); do not recognize the array. here is an extract of this file to include (submenu.php): ?php $submenu = array(); $submenu[] = array('id' = 1,'class'='menuitem1'); $submenu[] = array('id' = 2,'class'='menuitem2'); // function in the same file function DisplayMenu($title){ // here i do not have access to the previous array $submenu define outside the function ... } as it is included the function DisplayMenu should also have access to $submenu array, no ? basic php question. Variables within any function are local to that function (except for superglobals like $_POST, $_SESSION, etc.). In order to reference a var defined/used outside that function you must add a global statement in the function: function () { global $submenu; ... ... } I solve my problem creating a class and now it works well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to insert html code with PHP
On Thu, Apr 11, 2013 at 1:12 PM, Rafnews raf.n...@gmail.com wrote: On 11.04.2013 19:19, Jim Giner wrote: On 4/11/2013 10:48 AM, Rafnews wrote: On 11.04.2013 13:34, Rafnews wrote: Hi, I would like to insert a piece of HTML code inside several pages. all pages are differently named. i need in each page to find a particular tag, let's say div id=#submenu.../div (so based on its ID and tagname) and inside it to insert my PHP/HTML code. how can i do that ? thx. A. Ok i can write an include_once('myfile.php'); however if i have an array in this file, other files where is the include_once(); do not recognize the array. here is an extract of this file to include (submenu.php): ?php $submenu = array(); $submenu[] = array('id' = 1,'class'='menuitem1'); $submenu[] = array('id' = 2,'class'='menuitem2'); // function in the same file function DisplayMenu($title){ // here i do not have access to the previous array $submenu define outside the function ... } as it is included the function DisplayMenu should also have access to $submenu array, no ? basic php question. Variables within any function are local to that function (except for superglobals like $_POST, $_SESSION, etc.). In order to reference a var defined/used outside that function you must add a global statement in the function: function () { global $submenu; ... ... } I solve my problem creating a class and now it works well. Probably the best solution. As you asked the question here, it would be nice to share your solution so others with a similar problem can benefit. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to limit source IP in PHP
On 14/09/2012 20:08, Curtis Maurand wrote: On 9/14/2012 7:20 AM, Ian wrote: On 12/09/2012 14:53, Tonix (Antonio Nati) wrote: Is there a way to force a PHP script to bind to a prefixed IP? Actually, while you can assign more IPs to Apache for listening, assigning domains to specific IPs, it looks like any PHP script can freely choose which IP to bind. Instead I'd love some domains are permitted to open connections only from the domain IP. In FreeBSD I do it easily, setting up dedicated jails for domains. But how to do it simply using PHP on Linux? Regards, Tonino Hi, I think its been established now that this cannot be done by any php configuration so you will have to use other methods. You could configure iptables to only allow outgoing packets from specific IPs using the 'owner' module: http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html (search for 'owner'). There is also SELINUX. Or you could look at container based virtualisation like OpenVZ. Regards Ian 1. |if (function_exists('stream_context_create') function_exists('stream_socket_client')) {| 2. |$socket_options = array('socket' = array('bindto' = '192.0.2.1:0'));| 3. |$socket_context = stream_context_create($socket_options);| 4. |$socket = stream_socket_client('ssl://xmlapi.example.org:9090', $errno,| 5. |$errstr, 30, STREAM_CLIENT_CONNECT, $socket_context);| 6. |} else {| 7. |$socket = @fsockopen( ssl://xmlapi.example.org , 9090 , $errno , $errstr , 30 );| 8. |}| Google is your friend. Hi Curtis, I am suffering from sleep deprivation due to a new family addition and I fail to see how your code will prevent a malicious user from binding to an IP that I do not want him to. It appears to be an example of how to bind to an IP, not how to prevent it. Could you please explain? Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to limit source IP in PHP
On Tue, Sep 18, 2012 at 9:15 AM, Ian php_l...@fishnet.co.uk wrote: Hi Curtis, I am suffering from sleep deprivation due to a new family addition and I fail to see how your code will prevent a malicious user from binding to an IP that I do not want him to. It appears to be an example of how to bind to an IP, not how to prevent it. Could you please explain? Congrats on the new little one, Ian, and if you don't already know, you're in for a long ride of sleepless nights. Get used to it. That aside, please start a new thread if you'd like to discuss that in greater detail, as it will go off-topic from and out of scope of the originally-posted question. Others subscribed to the thread may not want to be bothered with the discussion, while others who are ignoring the thread (thinking it's a long, drawn-out, beating-a-dead-horse discussion) may never see a valuable discussion take place. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to limit source IP in PHP
Il 18/09/2012 16:24, Daniel Brown ha scritto: On Tue, Sep 18, 2012 at 9:15 AM, Ian php_l...@fishnet.co.uk wrote: Hi Curtis, I am suffering from sleep deprivation due to a new family addition and I fail to see how your code will prevent a malicious user from binding to an IP that I do not want him to. It appears to be an example of how to bind to an IP, not how to prevent it. Could you please explain? Congrats on the new little one, Ian, and if you don't already know, you're in for a long ride of sleepless nights. Get used to it. That aside, please start a new thread if you'd like to discuss that in greater detail, as it will go off-topic from and out of scope of the originally-posted question. Others subscribed to the thread may not want to be bothered with the discussion, while others who are ignoring the thread (thinking it's a long, drawn-out, beating-a-dead-horse discussion) may never see a valuable discussion take place. Please, continue in this thread. I do not see too how your suggestion can avoid malicious coding. Regards, Tonino -- Inter@zioniInterazioni di Antonio Nati http://www.interazioni.it to...@interazioni.it -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to limit source IP in PHP
On 12/09/2012 14:53, Tonix (Antonio Nati) wrote: Is there a way to force a PHP script to bind to a prefixed IP? Actually, while you can assign more IPs to Apache for listening, assigning domains to specific IPs, it looks like any PHP script can freely choose which IP to bind. Instead I'd love some domains are permitted to open connections only from the domain IP. In FreeBSD I do it easily, setting up dedicated jails for domains. But how to do it simply using PHP on Linux? Regards, Tonino Hi, I think its been established now that this cannot be done by any php configuration so you will have to use other methods. You could configure iptables to only allow outgoing packets from specific IPs using the 'owner' module: http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html (search for 'owner'). There is also SELINUX. Or you could look at container based virtualisation like OpenVZ. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to limit source IP in PHP
On 9/14/2012 7:20 AM, Ian wrote: On 12/09/2012 14:53, Tonix (Antonio Nati) wrote: Is there a way to force a PHP script to bind to a prefixed IP? Actually, while you can assign more IPs to Apache for listening, assigning domains to specific IPs, it looks like any PHP script can freely choose which IP to bind. Instead I'd love some domains are permitted to open connections only from the domain IP. In FreeBSD I do it easily, setting up dedicated jails for domains. But how to do it simply using PHP on Linux? Regards, Tonino Hi, I think its been established now that this cannot be done by any php configuration so you will have to use other methods. You could configure iptables to only allow outgoing packets from specific IPs using the 'owner' module: http://www.netfilter.org/documentation/HOWTO/packet-filtering-HOWTO-7.html (search for 'owner'). There is also SELINUX. Or you could look at container based virtualisation like OpenVZ. Regards Ian 1. |if (function_exists('stream_context_create') function_exists('stream_socket_client')) {| 2. |$socket_options = array('socket' = array('bindto' = '192.0.2.1:0'));| 3. |$socket_context = stream_context_create($socket_options);| 4. |$socket = stream_socket_client('ssl://xmlapi.example.org:9090', $errno,| 5. |$errstr, 30, STREAM_CLIENT_CONNECT, $socket_context);| 6. |} else {| 7. |$socket = @fsockopen( ssl://xmlapi.example.org , 9090 , $errno , $errstr , 30 );| 8. |}| Google is your friend.
Re: [PHP] Re: How to use wsdl files?
Hi there 2012/8/31 Michelle Konzack linux4miche...@tamay-dogan.net Hello Matijn Woudt, Am 2012-08-30 16:44:53, hacktest Du folgendes herunter: You could start by looking at the PHP SoapClient [1], which takes a URI to a WSDL descriptor as argument. You can enter the URL to the WSDL file there, like this: $client = new SoapClient( http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl;); Now you need to know which function you want to call, let's say it's called SomeFunction, then you can do: $client-SomeFunction($paramA, $paramB); Hope this gets you started. Ah thanks... Interesting how it works. However, I have found wsdl2php and converted the wsdl file to a PHP class, but I hate classes... Never used it in 12 years. :-D --8 ?php class checkVat{ var $countryCode; //string var $vatNumber; //string } class checkVatResponse{ var $countryCode; //string var $vatNumber; //string var $requestDate; //date var $valid; //boolean var $name;//string var $address; //string } class checkVatApprox{ var $countryCode; //string var $vatNumber; //string var $traderName; //string var $traderCompanyType; //companyTypeCode var $traderStreet;//string var $traderPostcode; //string var $traderCity; //string var $requesterCountryCode;//string var $requesterVatNumber; //string } class checkVatApproxResponse{ var $countryCode; //string var $vatNumber; //string var $requestDate; //date var $valid; //boolean var $traderName; //string var $traderCompanyType; //companyTypeCode var $traderAddress; //string var $traderStreet;//string var $traderPostcode; //string var $traderCity; //string var $traderNameMatch; //matchCode var $traderCompanyTypeMatch; //matchCode var $traderStreetMatch; //matchCode var $traderPostcodeMatch; //matchCode var $traderCityMatch; //matchCode var $requestIdentifier; //string } class checkVatService{ var $soapClient; private static $classmap = array('checkVat' = 'checkVat' ,'checkVatResponse' = 'checkVatResponse' ,'checkVatApprox' = 'checkVatApprox' ,'checkVatApproxResponse' = 'checkVatApproxResponse'); function __construct($url=' http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl') { $this-soapClient = new SoapClient($url,array(classmap = self::$classmap, trace = true, exceptions = true)); } function checkVat(checkVat $checkVat) { $checkVatResponse = $this-soapClient-checkVat($checkVat); return $checkVatResponse; } function checkVatApprox(checkVatApprox $checkVatApprox) { $checkVatApproxResponse = $this-soapClient-checkVatApprox($checkVatApprox); return $checkVatApproxResponse; } } ? --8 OK, tried $VALS = new checkVat; $VALS-countryCode = 'DE'; $VALS-vatNumber = '278049239'; $OBJECT = new checkVatService; $OBJECT-checkVat; and up the here I have no error. But How do I get the answer now? $ANS = $OBJECT-checkVat; or $ANS = $OBJECT-checkVat(); do not seem to work print_r($ANS); Also $RET = new checkVatResponse; print_r($RET); seems not to work What I am missing? Thanks, Greetings and nice Day/Evening Michelle Konzack The method checkVatService::checkVat is expecting an object of type checkVat to work. So you'll have to use something like this: $VALS = new checkVat(); $VALS-countryCode = 'DE'; $VALS-vatNumber = '278049239'; $OBJECT = new checkVatService(); $ANS = $OBJECT-checkVat($VALS); Sincerely Louis H.
[PHP] Re: How to use wsdl files?
Hello Matijn Woudt, Am 2012-08-30 16:44:53, hacktest Du folgendes herunter: You could start by looking at the PHP SoapClient [1], which takes a URI to a WSDL descriptor as argument. You can enter the URL to the WSDL file there, like this: $client = new SoapClient(http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl;); Now you need to know which function you want to call, let's say it's called SomeFunction, then you can do: $client-SomeFunction($paramA, $paramB); Hope this gets you started. Ah thanks... Interesting how it works. However, I have found wsdl2php and converted the wsdl file to a PHP class, but I hate classes... Never used it in 12 years. :-D --8 ?php class checkVat{ var $countryCode; //string var $vatNumber; //string } class checkVatResponse{ var $countryCode; //string var $vatNumber; //string var $requestDate; //date var $valid; //boolean var $name;//string var $address; //string } class checkVatApprox{ var $countryCode; //string var $vatNumber; //string var $traderName; //string var $traderCompanyType; //companyTypeCode var $traderStreet;//string var $traderPostcode; //string var $traderCity; //string var $requesterCountryCode;//string var $requesterVatNumber; //string } class checkVatApproxResponse{ var $countryCode; //string var $vatNumber; //string var $requestDate; //date var $valid; //boolean var $traderName; //string var $traderCompanyType; //companyTypeCode var $traderAddress; //string var $traderStreet;//string var $traderPostcode; //string var $traderCity; //string var $traderNameMatch; //matchCode var $traderCompanyTypeMatch; //matchCode var $traderStreetMatch; //matchCode var $traderPostcodeMatch; //matchCode var $traderCityMatch; //matchCode var $requestIdentifier; //string } class checkVatService{ var $soapClient; private static $classmap = array('checkVat' = 'checkVat' ,'checkVatResponse' = 'checkVatResponse' ,'checkVatApprox' = 'checkVatApprox' ,'checkVatApproxResponse' = 'checkVatApproxResponse'); function __construct($url='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl') { $this-soapClient = new SoapClient($url,array(classmap = self::$classmap, trace = true, exceptions = true)); } function checkVat(checkVat $checkVat) { $checkVatResponse = $this-soapClient-checkVat($checkVat); return $checkVatResponse; } function checkVatApprox(checkVatApprox $checkVatApprox) { $checkVatApproxResponse = $this-soapClient-checkVatApprox($checkVatApprox); return $checkVatApproxResponse; } } ? --8 OK, tried $VALS = new checkVat; $VALS-countryCode = 'DE'; $VALS-vatNumber = '278049239'; $OBJECT = new checkVatService; $OBJECT-checkVat; and up the here I have no error. But How do I get the answer now? $ANS = $OBJECT-checkVat; or $ANS = $OBJECT-checkVat(); do not seem to work print_r($ANS); Also $RET = new checkVatResponse; print_r($RET); seems not to work What I am missing? Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux Internet Service Provider, Cloud Computing http://www.itsystems.tamay-dogan.net/ itsystems@tdnet Jabber linux4miche...@jabber.ccc.de Owner Michelle Konzack Gewerbe Strasse 3 Tel office: +49-176-86004575 77694 Kehl Tel mobil: +49-177-9351947 Germany Tel mobil: +33-6-61925193 (France) USt-ID: DE 278 049 239 Linux-User #280138 with the Linux Counter, http://counter.li.org/ --8 Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux Internet Service Provider, Cloud Computing http://www.itsystems.tamay-dogan.net/ itsystems@tdnet Jabber linux4miche...@jabber.ccc.de Owner Michelle Konzack Gewerbe Strasse 3 Tel
[PHP] Re: How to best set per-site PHP session storage under suPHP/WordPress?
On 13/08/2012 06:01, Philip Amadeo Saeli wrote: I'm administering WordPress sites under suPHP on a CentOS LAMP server and would like to know how I can set PHP to keep the session files under the WP user's dir without having do duplicate the entire php.ini file for each WP site while still maintaining adequate security. The problems I'm encountering are that, AFAICT, I have basically two choices: 1. Use the suPHP suPHP_ConfigPath to set the path to a per-site php.ini file containing a session.save_path directive. 2. Put php.ini files with the session.save_path directive within the WP dir hier. The problems with the above two options (I have found no other options so far) are that, for the former, the system php.ini file is not read so the per-site php.ini file(s) have to duplicate most if not all of what's in the system php.ini file; this is for each WP site (if not a WP Net (AKA WPMU) install); and for the latter, -any-and-every- subdir in the WP dir hier that has code that may reference the PHP session must have its own php.ini file in it. Either way it becomes a significant maintenance problem, especially once there are more than one or two such sites. I have not been able to find much documentation on this, either in the PHP site or in the various help forums. I've searched quite extensively and have run some tests of my own using phpinfo.php to see how things are set. I do not desire to open up file permissions to bypass this PHP settings issue altogether due to security concerns (though I do wish an answer could be so simple). What's canonical in such a case? If nothing, are there any other alternatives? My desired solution would be to be able to put one php.ini (or equivalent) file per site that would contain the needed directive which would be merged with the settings from the system php.ini, overriding only the session.save_path, but, AFAICT, PHP does not seem to allow this. Any other ideas? Thanks! --Phil Hi, You can add php.ini variables to the Apache Virtual Host section for each site, for example: php_admin_value session.save_path /path/to/new/session/folder [http://php.net/manual/en/configuration.changes.php] This will override the save path for each site you add it to, but all other values will be picked up from the system default. You must make sure the Apache user has write access to the new folder. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to best set per-site PHP session storage under suPHP/WordPress?
* Ian php_l...@fishnet.co.uk [2012-08-13 09:50:51 +0100]: On 13/08/2012 06:01, Philip Amadeo Saeli wrote: I'm administering WordPress sites under suPHP on a CentOS LAMP server and would like to know how I can set PHP to keep the session files under the WP user's dir without having do duplicate the entire php.ini file for each WP site while still maintaining adequate security. The problems I'm encountering are that, AFAICT, I have basically two choices: 1. Use the suPHP suPHP_ConfigPath to set the path to a per-site php.ini file containing a session.save_path directive. 2. Put php.ini files with the session.save_path directive within the WP dir hier. The problems with the above two options (I have found no other options so far) are that, for the former, the system php.ini file is not read so the per-site php.ini file(s) have to duplicate most if not all of what's in the system php.ini file; this is for each WP site (if not a WP Net (AKA WPMU) install); and for the latter, -any-and-every- subdir in the WP dir hier that has code that may reference the PHP session must have its own php.ini file in it. Either way it becomes a significant maintenance problem, especially once there are more than one or two such sites. I have not been able to find much documentation on this, either in the PHP site or in the various help forums. I've searched quite extensively and have run some tests of my own using phpinfo.php to see how things are set. I do not desire to open up file permissions to bypass this PHP settings issue altogether due to security concerns (though I do wish an answer could be so simple). What's canonical in such a case? If nothing, are there any other alternatives? My desired solution would be to be able to put one php.ini (or equivalent) file per site that would contain the needed directive which would be merged with the settings from the system php.ini, overriding only the session.save_path, but, AFAICT, PHP does not seem to allow this. Any other ideas? Thanks! --Phil Hi, You can add php.ini variables to the Apache Virtual Host section for each site, for example: php_admin_value session.save_path /path/to/new/session/folder [http://php.net/manual/en/configuration.changes.php] This will override the save path for each site you add it to, but all other values will be picked up from the system default. You must make sure the Apache user has write access to the new folder. Regards Ian -- Thanks, Ian, for the suggestion. I had tried that without success and had neglected to mention that in my post. The reason that it doesn't work, AFAICT, is that, since suPHP runs PHP as CGI and not DSO, the Apache directives are not available to it. Any other ideas? I'd especially like to better understand how PHP handles php.ini files and any rationale behind the way it handles them. Thanks, --Phil -- Philip Amadeo Saeli openSUSE, RHEL, CentOS psa...@zorodyne.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to write and read serial or parallel port
On 26/07/2012 13:37, Alex Nikitin wrote: snip Real question is why in the world would you want to use PHP for this to begin with. snip Hi, I cannot speak for the OP, but personally I am doing this so I can hook up to a web application and re-use existing code. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to write and read serial or parallel port
On 26/07/2012 11:12, viper wrote: hi all! is it possible to write and read data on a COM or LPT port? is there any function or class in PHP? anyone has already done something similar? thanks, viper Hi, There is a class here: php-serial http://code.google.com/p/php-serial/source/browse/trunk/ I will be trying this myself tonight as I need to hook up to an arduino and retrieve some sensor readings. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to walk async recursively over an object, doing work (in right order) per leaf
I think I've got it figured out now.. My solution is to async build up a flat list of items (from the recursive object) to process first, then do another async loop (which I'll build soon) to do the work per item, and when that's done, replace the placeholder with the result. This code works on a custom datastructure that looks like this; { hmData : { mijnDataA : 'a', mijnDataB : 'b', mijnSubKeyA : { hmData : { mijnDataX : 'x' }, hmSettings : { // app-specifc values for the object with key 'mijnDataX' } } }, hmSettings : { // app-specific values for the object with keys 'mijnDataA', 'mijnDataB', and 'mijnSubKeyA' } } Then, the actual code to build up a flat work list of this recursive array, up to a certain level deep (levelsAtOnce) is; printNextLevel : function (pvCmd) { if ( typeof pvCmd.val == 'object' typeof pvCmd.val.hmStats == 'object' typeof pvCmd.val.hmData == 'object' ) { //if (pvCmd.keyValueName pvCmd.keyValueName!='') pvCmd.val.hmStats.keyValueName=pvCmd.keyValueName; //bit of a hack, i agree. var td = typeof pvCmd.val.hmData; var d = pvCmd.val.hmData; } else { var td = typeof pvCmd.val; var d = pvCmd.val; }; rajmv.hms.tools.printNextLevel_scan (pvCmd, rajmv.hms.tools.printNextLevel_buildDatanodes); return { html : 'trtdHave Yet To Render This/td/tr' }; }, printNextLevel_scan : function (pvCmd, callback) { if (!pvCmd.scanResults) { pvCmd.scanResults = [{level:1, datanode:pvCmd.scanPointer}]; pvCmd.scanIdx = 0; pvCmd.scanCount = 0; pvCmd.lastPause = 0; pvCmd.scanCallback = callback; } rajmv.hms.tools.printNextLevel_scanItem (pvCmd); pvCmd.scanCount++; //rajmv.log (2, 'pvCmd.scanIdx='+pvCmd.scanIdx+', scanResults.length-1='+(pvCmd.scanResults.length-1)); if (pvCmd.scanIdx==pvCmd.scanResults.length-1) { if (typeof pvCmd.scanCallback=='function') { pvCmd.scanCallback (pvCmd); } return true; // scanning done! } var pauseFactor = pvCmd.scanCount / 7; if (pauseFactor pvCmd.lastPause + 1) { setTimeout (function () { pvCmd.lastPause = pauseFactor; rajmv.hms.tools.printNextLevel_scan(pvCmd); }, 50); } else { rajmv.hms.tools.printNextLevel_scan(pvCmd); }; return false; // not done yet }, printNextLevel_scanItem : function (pvCmd) { var it = pvCmd.scanResults[pvCmd.scanIdx]; if (!it || !it.datanode) return false; var tit = typeof it.datanode; if (tit=='object' it.datanode!==null it.datanode!==undefined) { if (!it.keys it.level=pvCmd.levelsAtOnce) { it.keys = Object.keys (it.datanode); it.keyIdx = 0; } } if (it.keys) { if (it.keyIdxit.keys.length) { var doUntil = it.keyIdx+20; while (it.keyIdxdoUntil it.keyIdxit.keys.length-1) { rajmv.hms.tools.printNextLevel_scanKey (pvCmd); it.keyIdx++; pvCmd.scanCount++; if (it.keyIdx==it.keys.length-1) {
[PHP] Re: how to walk async recursively over an object, doing work (in right order) per leaf
oops; printNextLevel : function (pvCmd) { if ( typeof pvCmd.val == 'object' typeof pvCmd.val.hmStats == 'object' typeof pvCmd.val.hmData == 'object' ) { //if (pvCmd.keyValueName pvCmd.keyValueName!='') pvCmd.val.hmStats.keyValueName=pvCmd.keyValueName; //bit of a hack, i agree. var td = typeof pvCmd.val.hmData; var d = pvCmd.val.hmData; } else { var td = typeof pvCmd.val; var d = pvCmd.val; }; pvCmd.scanPointer = d; rajmv.hms.tools.printNextLevel_scan (pvCmd, rajmv.hms.tools.printNextLevel_buildDatanodes); return { html : 'trtdHave Yet To Render This/td/tr' }; }, -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to send XML requests from PHP?
Michelle Konzack linux4miche...@tamay-dogan.net hat am 8. Mai 2012 um 20:25 geschrieben: Hello Jim Lucas, Am 2012-05-08 11:08:13, hacktest Du folgendes herunter: Look into cURL http://php.net/curl I know curl but I do not know, HOW to send the XML stuff. $ch = curl_init (); curl_setopt ( $ch , CURLOPT_URL , http://www.example.com/; ); Look at http://de.php.net/manual/en/function.curl-setopt.php and set all other options you need - post method i guess - post body with your xml - curl_exec ( $ch ); curl_close ( $ch ); I you have build up you try and have some code, come back to the list and tell us what didn't work and what you expect it to do. Then we can help you. Do have a documentation how the request should look like? Headers to be sent? Post/Get Parameters? Protocol? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to send XML requests from PHP?
Hello Jim Lucas, Am 2012-05-08 11:08:13, hacktest Du folgendes herunter: Look into cURL http://php.net/curl I know curl but I do not know, HOW to send the XML stuff. The XML code is generated using a temp file for logging, which mean, I can see any changes on the system... Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux Internet Service Provider, Cloud Computing http://www.itsystems.tamay-dogan.net/ itsystems@tdnet Jabber linux4miche...@jabber.ccc.de Owner Michelle Konzack Gewerbe Strasse 3 Tel office: +49-176-86004575 77694 Kehl Tel mobil: +49-177-9351947 Germany Tel mobil: +33-6-61925193 (France) USt-ID: DE 278 049 239 Linux-User #280138 with the Linux Counter, http://counter.li.org/ signature.pgp Description: Digital signature
Re: [PHP] Re: How to send XML requests from PHP?
On 05/08/2012 11:25 AM, Michelle Konzack wrote: Hello Jim Lucas, Am 2012-05-08 11:08:13, hacktest Du folgendes herunter: Look into cURL http://php.net/curl I know curl but I do not know, HOW to send the XML stuff. The XML code is generated using a temp file for logging, which mean, I can see any changes on the system... Thanks, Greetings and nice Day/Evening Michelle Konzack It is data, you send it in the data section of a post. Typically you must also assign it to a variable as you would any other value that you are submitting. What you should do is capture (using Firefox and viewing the headers) the communication that your browser would perform when submitting the data via FireFox. Once you have that, you will then see how the data needs to be associated. Sending post data via curl is a matter of formatting the data right and inserting it into the curl request. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I convert these to hex or strings?
Did you do a search of the php manual? I did one on hex and found function bin2hex. Not sure how you mac address is actually built, but I would try converting it char by char and see what the function returns. Or maybe just pass the whole string to it. Just a guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can I convert these to hex or strings?
Damn I'm an idiot... sorry :\ On Wed, Mar 21, 2012 at 9:34 AM, Jim Giner jim.gi...@albanyhandball.comwrote: Did you do a search of the php manual? I did one on hex and found function bin2hex. Not sure how you mac address is actually built, but I would try converting it char by char and see what the function returns. Or maybe just pass the whole string to it. Just a guess. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can I convert these to hex or strings?
Not until you find out if it actually works. Then, maybe David OBrien dgobr...@gmail.com wrote in message news:CAF=yd_3rbr-gkonpjdbtogssiufwzeqteanqneproh6hhyu...@mail.gmail.com... Damn I'm an idiot... sorry :\ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I debug wsf/php in eclipse?
Can anybody help me in this regard? On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: Hi. I'm developing a wsf/php web service. I'm using doc/lit messaging format and every thing is OK. But I don't know how i can debug my web services using eclipse. Although I can directly run my web service in debug mode, Unfortunately when I debug my client it never jump into web service code and I only can see if that service has returned a correct value or not! I'd be glad to know if it's possible or not to do something like this in eclipse. Thanks for any help.
Re: [PHP] Re: How can I debug wsf/php in eclipse?
在 2012-02-07二的 12:11 +0330,Ali Asghar Toraby Parizy写道: Can anybody help me in this regard? On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: Hi. I'm developing a wsf/php web service. I'm using doc/lit messaging format and every thing is OK. But I don't know how i can debug my web services using eclipse. Although I can directly run my web service in debug mode, Unfortunately when I debug my client it never jump into web service code print the log to console or something else. and I only can see if that service has returned a correct value or not! I'd be glad to know if it's possible or not to do something like this in eclipse. Thanks for any help. -- Best regards, Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**) Using Gmail? Please read this important notice: http://www.fsf.org/campaigns/jstrap/gmail?10073. signature.asc Description: This is a digitally signed message part
Re: [PHP] Re: How can I debug wsf/php in eclipse?
:( Thanks for your help. Is it the only way? On Tue, Feb 7, 2012 at 12:44 PM, Sharl.Jimh.Tsin amoiz.sh...@gmail.comwrote: 在 2012-02-07二的 12:11 +0330,Ali Asghar Toraby Parizy写道: Can anybody help me in this regard? On Mon, Feb 6, 2012 at 10:15 PM, Ali Asghar Toraby Parizy aliasghar.tor...@gmail.com wrote: Hi. I'm developing a wsf/php web service. I'm using doc/lit messaging format and every thing is OK. But I don't know how i can debug my web services using eclipse. Although I can directly run my web service in debug mode, Unfortunately when I debug my client it never jump into web service code print the log to console or something else. and I only can see if that service has returned a correct value or not! I'd be glad to know if it's possible or not to do something like this in eclipse. Thanks for any help. -- Best regards, Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED**) Using Gmail? Please read this important notice: http://www.fsf.org/campaigns/jstrap/gmail?10073.
[PHP] Re: How to use a variable variable in an array walk?
Anyone?:-( is my description too unclear? On 11.12.2011, at 11:25, Nils Leideck wrote: this is my first post to the PHP general list. I have an issue with a variable variable (http://php.net/manual/en/language.variables.variable.php) My use case: I have an array called $myArray. The structure is as following: array(1) { [user_interface]= array(1) { [design]= array(1) { [“my_colors]= array(5) { [item_number_one]= string(6) red [item_number_two]= string(40) '[user_interface][design][my_colors][item_number_one]' } } } } As you can see, the item_number_one has no direct color value assigned but the structure of the path to item_number_one in the $myArray variable. I tried with array_wal_resursive. During this step (the array building is completed) I want to find these values (I use a static value in my example, in the real code I will use regular expressions) and assign the value of the virtually related item to the considered item. So in my example above, I want to have the following values after the process is done: $myArray[user_interface][design][my_colors][item_mumber_one] = red; // this is item number 1 $myArray[user_interface][design][my_colors][item_mumber_two] = red; // this should be item number 2 The second issue here is, how do I evaluate at which point the process is exactly, because the value and the key that is transferred to the function by array_walk_recursive has only the value itself but not array path to the current item. Any idea how get this done? Or am I too complicated maybe? I tried several combinations of ${$var}, $myArray{$var}, {$myArray}{$var} ... and many more. Any help is much much appreciated! Cheers, Nils -- http://webint.cryptonode.de / a Fractal project -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to use a variable variable in an array walk?
On 12/13/2011 5:43 PM, Nils Leideck wrote: Anyone?:-( is my description too unclear? On 11.12.2011, at 11:25, Nils Leideck wrote: this is my first post to the PHP general list. I have an issue with a variable variable (http://php.net/manual/en/language.variables.variable.php) My use case: I have an array called $myArray. The structure is as following: array(1) { [user_interface]= array(1) { [design]= array(1) { [“my_colors]= array(5) { [item_number_one]= string(6) red [item_number_two]= string(40) '[user_interface][design][my_colors][item_number_one]' } } } } As you can see, the item_number_one has no direct color value assigned but the structure of the path to item_number_one in the $myArray variable. I tried with array_wal_resursive. During this step (the array building is completed) I want to find these values (I use a static value in my example, in the real code I will use regular expressions) and assign the value of the virtually related item to the considered item. So in my example above, I want to have the following values after the process is done: $myArray[user_interface][design][my_colors][item_mumber_one] = red; // this is item number 1 $myArray[user_interface][design][my_colors][item_mumber_two] = red; // this should be item number 2 The second issue here is, how do I evaluate at which point the process is exactly, because the value and the key that is transferred to the function by array_walk_recursive has only the value itself but not array path to the current item. Any idea how get this done? Or am I too complicated maybe? I tried several combinations of ${$var}, $myArray{$var}, {$myArray}{$var} ... and many more. Any help is much much appreciated! Cheers, Nils I'm short of time to conjure this in detail; but, on the surface it seems like nested foreach()s would do the trick. foreach($myArray as $key1 = $userArray) { foreach($userArray as $key2 = $designArray) { foreach($designArray as $key3 = $colorsArray) { foreach($colorsArray as $key4=$itemsArray){ //do stuff here. All keys are available } } } } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: How can I check for characters in a $_POST[] variable?
if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) { echo p style=\color:red;font-weight:bold;margin-left:95px\; echo Username must only contain A-Z and 0-9/p; include(register.html); exit; } I used the code above but I now get this error message Warning: preg_match() [function.preg-match]: Unknown modifier '^' in C:\Documents and Settings\iceweasel\Desktop\XAMPP\relik.ath.cx\forum\register.php on line 2 I don't like to run php with errors off so I wanna ask how I can fix this.
Re: [PHP] RE: How can I check for characters in a $_POST[] variable?
Il 22/09/2011 17:54, Eric ha scritto: if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) { Whi this '(.*)'? For '.' and '..' problem use is_file(). Bye, Marco -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I check for characters in a $_POST[] variable?
On 09/22/2011 10:54 AM, Eric wrote: if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) { echo p style=\color:red;font-weight:bold;margin-left:95px\; echo Username must only contain A-Z and 0-9/p; include(register.html); exit; } I used the code above but I now get this error message Warning: preg_match() [function.preg-match]: Unknown modifier '^' in C:\Documents and Settings\iceweasel\Desktop\XAMPP\relik.ath.cx\forum\register.php on line 2 I don't like to run php with errors off so I wanna ask how I can fix this. if(!ctype_alnum($_POST['username'])) { // is not alpha numeric } -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] RE: How can I check for characters in a $_POST[] variable?
On 09/22/2011 09:24 PM, Eric wrote: if(preg_match('(.*)^[A-Za-z0-9]+', $_POST['username']) !== 0) { echo p style=\color:red;font-weight:bold;margin-left:95px\; echo Username must only contain A-Z and 0-9/p; include(register.html); exit; } I used the code above but I now get this error message Warning: preg_match() [function.preg-match]: Unknown modifier '^' in C:\Documents and Settings\iceweasel\Desktop\XAMPP\relik.ath.cx\forum\register.php on line 2 I don't like to run php with errors off so I wanna ask how I can fix this. Oh damn, I just forgot that the pattern is to be enclosed between delimiters. Glad that you found the fix using ctype_alnum though. A new learning for me. -- Nilesh Govindarajan http://nileshgr.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to use echo checkboxes in php when i don't have access to $_POST
i mean my tables in Mysql
[PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On 4/14/2011 6:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ OK, maybe not the most elegant ... but it works for my purposes ... and it was my first attempt at these directory functions. You can navigate up and down the directory hierarchy. It flags files older than 1 year for potential cleanup. Hope it gives you some ideas and a place to start... Mitch #! /usr/bin/php4 html head titleDiskspace Analyzer/title ?php foreach ($_REQUEST as $key=$value){ $$key = $value; } ? /head body form name=form1 method=POST action=?php $PHP_SELF ? p align=centerfont color=#FF size=+2Enter Directory Name Here/font/p p align=center input name=dName type=text id=dName value=?php $dName ? size=50 maxlength=256 input type=submit name=Submit value=Submit /p /form br ?php if (isset($dName) is_dir($dName)){ print(hr\n); print(font size=\+2\strong$dName Directory Information/strong/fontbrnbsp;\n); print(font color=\yellow\strongHighlighted/strong/font files are older than 1 year and candidates for cleanupbrnbsp;\n); print(table border=\1\ bordercolor=\gray\ cellspacing=\0\ cellpadding=\5\\n); print(th bgcolor=\black\font color=\white\File Name/font/thth bgcolor=\black\font color=\white\File Size/font/thth bgcolor=\black\font color=\white\File Date/font/th\n); $d = @dir(trim($dName)); while ($entry = @$d-read()){ $total++; $fileExt = explode(., $entry); if(is_dir($d-path . / . $entry)){ if($fileExt[0] ==){ $fileExt[1] = SysDirectories; } else { $fileExt[1] = Directories; } $dirSize = filesize($d-path . / . $entry); $totaldirSize += $dirSize; $dirList[$entry] = $dirSize; } else { $fileExt[1] = Files; $fileStats = @stat($d-path . / . $entry); $fileSize = $fileStats[7]; $totalSize += $fileSize; $currDate = getdate(); $fdDay = date(z, $fileStats[10]); $fdYear = date(Y, $fileStats[10]); $ckDay = $currDate[yday]; $ckYear = ($currDate[year] - 1); if (($fdYear $ckYear) || (($fdYear == $ckYear) ($fdDay = $ckDay))){ $highlight = yellow; $totalSavings += $fileStats[7]; } else { $highlight = white; } print(\ttr\n); print(\t\ttd bgcolor=\$highlight\$entry/tdtd bgcolor=\$highlight\ align=\right\$fileSize/tdtd align=\right\ bgcolor=\$highlight\); printf(%s, date(m/d/Y, $fileStats[10])); print(/td\n); print(\t/tr\n); } $fileTypes[$fileExt[1]]++; } print(\ttr\n); print(\t\ttd bgcolor=\gray\strongTotal Bytes in Files/strong/tdtd align=\right\ bgcolor=\gray\strong$totalSize/strong/tdtd align=\right\ bgcolor=\gray\); if ($totalSavings 0){ print(strongPotential Savings: $totalSavings/strong); } print(/td\n); print(\t/tr\n); print(/tablebrnbsp;\n); if(count($dirList) 1){ ksort($dirList); print(table border=\1\ bordercolor=\gray\ cellspacing=\0\ cellpadding=\5\\n); print(th bgcolor=\black\font color=\white\Directories/font/th\n); foreach ($dirList as $key=$value){ print(\ttr\n); if ($key == .){ print(\t\ttd$key nbsp;(Current)/td\n); } elseif ($key == ..){ $truncPoint = strrpos($dName, /); $parentDir = substr($dName, 0, $truncPoint); if ($parentDir == ){ $parentDir = /; } print(\t\ttda href=\ . $PHP_SELF . ?dName= . $parentDir . Submit=Submit\$key/a (Parent)/td\n); } else { print(\t\ttda href=\ .
[PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On 04/14/2011 06:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ I prefer glob(). Give it a shot and ask for help on code that you have tried. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to write a PHP coding to list out all files and directories aslinks to them?
On Sat, 2011-04-16 at 15:02 -0500, Shawn McKenzie wrote: On 04/14/2011 06:16 PM, Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ I prefer glob(). Give it a shot and ask for help on code that you have tried. -- Thanks! -Shawn http://www.spidean.com There is a setting of Apache that will do this automatically for directories that have no index, I don't remember exactly what it is right now, but a quick Google should yield results -- Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: How to write a PHP coding to list out all files and directories as links to them?
Mikhail S wrote: How to write a PHP coding to list out all files and directories as links to them? This is somewhat similar to some index pages. When new file or folder is added to the directory, HTML page should display the newly created file/folder together with previous ones after it is being refreshed. (prefer in alphabatical order) How to achieve this sort of functionality in PHP? Please provide sample coding as well. (and any references) Thanks. -- Mike http://jp.shopsloop.com/ Start with http://php.net/manual/en/function.opendir.php for a basic method. Alternatively you can use the SPL DirectoryIterator class http://php.net/manual/en/class.directoryiterator.php http://php.net is your first resource for php Cheers -- David Robley Hm..what's this red button fo:=/07NO CARRIER Today is Setting Orange, the 32nd day of Discord in the YOLD 3177. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How is this possible???? (addslashes)
On Thu, 17 Feb 2011 06:56:33 +0700, Paul S wrote: Can anyone please tell me how the addslashes output (note = Everyone''s a card on the \earth) in the following example is possible. It is addslashes output but this result is consistent with the output from post when runtime is set: 1): a single quote is inserted before a single quote and nothing is added before or \. ... ?php $note = Everyone's a card on the \earth; echo br$notebr; $note = addslashes($note); echo brnote = $notebr; ? ... output: Everyone's a card on the \earth note = Everyone''s a card on the \earth http://se.php.net/manual/en/function.addslashes.php Having the PHP directive magic_quotes_sybase set to on will mean ' is instead escaped with another '. Both \e and \\e produces the same output. /Nisse -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to send a GPG signed EMail with a PDF attached?
Hello Tommy Pham, Am 2010-12-29 10:38:39, hacktest Du folgendes herunter: Phpclasses.org naturally may not have all possible solutions. Thus, the existence of search engines like google. Try keywords 'php mime encode gpg'. Already done and it returns 56.000 results where the first 500 where notvery useful. But I found via the gnupgp site gpg_encrypt() and now I changed my setup to let users upload there public key and then they get the invoices crypted. Otherwise as normal EMail or alternative as SMail. Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux itsyst...@tdnet France EURL itsyst...@tdnet UG (limited liability) Owner Michelle KonzackOwner Michelle Konzack Apt. 917 (homeoffice) 50, rue de Soultz Kinzigstraße 17 67100 Strasbourg/France 77694 Kehl/Germany Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil Tel: +33-9-52705884 fix http://www.itsystems.tamay-dogan.net/ http://www.flexray4linux.org/ http://www.debian.tamay-dogan.net/ http://www.can4linux.org/ Jabber linux4miche...@jabber.ccc.de ICQ#328449886 Linux-User #280138 with the Linux Counter, http://counter.li.org/ signature.pgp Description: Digital signature
[PHP] Re: how would I do this?
Hello David McGlone, Am 2010-12-27 16:13:50, hacktest Du folgendes herunter: foreach ($services as $service){ echo ulliraquo; a href=index.php?page=$service$service/a/li/ul; } Could anyone give me a hand? Obviously I don't understand arrays very well :-/ Maybe: echo ulliraquo; a href=index.php?page=$service?php str_replace(_, , $service); =?/a/li/ul; Thanks, Greetings and nice Day/Evening Michelle Konzack -- # Debian GNU/Linux Consultant ## Development of Intranet and Embedded Systems with Debian GNU/Linux itsyst...@tdnet France EURL itsyst...@tdnet UG (limited liability) Owner Michelle KonzackOwner Michelle Konzack Apt. 917 (homeoffice) 50, rue de Soultz Kinzigstraße 17 67100 Strasbourg/France 77694 Kehl/Germany Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil Tel: +33-9-52705884 fix http://www.itsystems.tamay-dogan.net/ http://www.flexray4linux.org/ http://www.debian.tamay-dogan.net/ http://www.can4linux.org/ Jabber linux4miche...@jabber.ccc.de ICQ#328449886 Linux-User #280138 with the Linux Counter, http://counter.li.org/ signature.pgp Description: Digital signature
Re: [PHP] Re: how would I do this?
On Monday, December 27, 2010 04:47:34 pm Michelle Konzack wrote: Hello David McGlone, Am 2010-12-27 16:13:50, hacktest Du folgendes herunter: foreach ($services as $service){ echo ulliraquo; a href=index.php?page=$service$service/a/li/ul; } Could anyone give me a hand? Obviously I don't understand arrays very well :-/ Maybe: echo ulliraquo; a href=index.php?page=$service?php str_replace(_, , $service); =?/a/li/ul; Hehehehe :) I'm gonna try this too. Earlier I was thinking of str_replace, but couldn't figure out how I would incorporate it. I love PHP! -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how would I do this?
On Monday, December 27, 2010 04:53:08 pm David McGlone wrote: On Monday, December 27, 2010 04:47:34 pm Michelle Konzack wrote: Hello David McGlone, Am 2010-12-27 16:13:50, hacktest Du folgendes herunter: foreach ($services as $service){ echo ulliraquo; a href=index.php?page=$service$service/a/li/ul; } Could anyone give me a hand? Obviously I don't understand arrays very well :-/ Maybe: echo ulliraquo; a href=index.php?page=$service?php str_replace(_, , $service); =?/a/li/ul; Hehehehe :) I'm gonna try this too. Earlier I was thinking of str_replace, but couldn't figure out how I would incorporate it. I love PHP! Ok here's another variation with the str_replace suggestion function links() { $services = array(lawn_maintenance, core_areation, over_seeding, hedge_trimming, mulch_installation, natural_debris_removal, leaf_removal, snow_plowing); foreach ($services as $service){ $replace = str_replace(_, , $service); echo ulliraquo; a href=index.php?page=$service$replace/a/li/ul; } } Thanks everyone. I'm stoked! :) I know this probably wasn't much for the veteran coders here, but for me it was awesome. I was proud of myself when I thought of using the array for the links and now this was an added bonus. my next step will be using a database instead of a hard coded array, but at this point I don't want to make things any harder on myself. -- Blessings David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How does one reply to messages on this list?
As I use outlook, I just hit Reply to Group. -- João Cândido de Souza Neto Sam Smith a...@itab.com escreveu na mensagem news:aanlktikarnvhn-gzexe8qedngeewgqqgs7cpchzav...@mail.gmail.com... If I just hit 'Reply' I'll send my reply to the individual who created the message. If I hit 'Reply All' my reply will be sent to: Govinda govinda.webdnat...@gmail.com, PHP-General List php-general@lists.php.net and the creator of the message. Neither option seems correct. What's up with that? Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to handle a submitted form with no changes -- best practices sought
On Sep 11, 2010, at 10:46 PM, Shawn McKenzie wrote: It could however be a problem if there is a BOT or something that continually submits to your page. In that case (and in general) I would recommend using a form token that helps guard against this. I've seen this on some sites, but I'm unclear how to implement this. How is this generally done? Thanks, Tamara -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to handle a submitted form with no changes -- best practices sought
On 09/12/2010 02:38 AM, Tamara Temple wrote: On Sep 11, 2010, at 10:46 PM, Shawn McKenzie wrote: It could however be a problem if there is a BOT or something that continually submits to your page. In that case (and in general) I would recommend using a form token that helps guard against this. I've seen this on some sites, but I'm unclear how to implement this. How is this generally done? Thanks, Tamara You generate a token before you display the form, something like: $token = md5(uniqid(rand(), TRUE)); Then stick this in a session var and add it as a hidden input on your form. Then on the receiving page check that the session token matches the posted token. viraj's idea sounds cool for your particular problem as well. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to handle a submitted form with no changes -- best practices sought
On 09/11/2010 11:52 AM, Tamara Temple wrote: I have a general question and am looking for best practices. Suppose I present a user with a form for editing an entry in a table, i.e., the form has filled in values from the existing table entry. Now, suppose they click on 'submit' without making any changes in the form. (Perhaps, say, rather than clicking 'Cancel' or 'Return to Main' or some other option which would get them out of that screen without submitting the form). Is it worth the overhead of passing along the previous values in the table in hidden fields so that fields can be checked to see if they've been updated or not after the submit? Or is it worth reloading the old values from the table to check against the newly submitted form? Or is all that overhead not worth the time because an update that overwrites existing values with the same values is not that onerous? (Is that question clear enough?) I would just submit the query. Unless you have hundreds or thousands of users per second that load the form and submit the form with no changes, then there really is no problem. It could however be a problem if there is a BOT or something that continually submits to your page. In that case (and in general) I would recommend using a form token that helps guard against this. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
2010/8/19 Andre Polykanine an...@oire.org: Hello Nathan, Sorry, could you provide any links to read for a security noob?) Actually, I know that the md5 is decryptable (there are bases with words encrypted in md5), but I thought the SHA1 was secure... -- With best regards from Ukraine, Andre - Original message - From: Nathan Rixham nrix...@gmail.com To: tedd t...@sperling.com Date: Thursday, August 19, 2010, 12:03:12 PM Subject: [PHP] Re: How safe is a .htaccess file? tedd wrote: Hi gang: The subject line says it all. How secure is a .htaccess file to store passwords and other sensitive stuff? Can a .htaccess file be viewed remotely? Semi-safe, .htaccess is prevented from being served by configuration options (which come as default), however these can be overwritten so best to check by doing a GET on the resource URI. This doesn't prevent them from being exposed via other processes though, for instance a poorly coded 'download.php?path=/path/to/.htaccess' could still expose the file. Typically, its obviously better to store only a hash of a password rather than the pass in plain text, choosing the strongest algorithm you can; password security is of course relative though, a sha-512 of 'password1' is far from secure. A good way to approach encryption for files is to openssl_seal them using a public key which is only available to your application - this doesn't negate insecure code, but it at least ensures the raw files are encrypted securely enough to negate any of these worries. (just keep your private key safe, preferably in a pkcs12 w/a strong 64char+ pass) Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi Nathan, I'm not a crypto expert.. but I'll try to explain it: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... When you use test as a secret password, then no hashing algorythm at can be considered as safe. The first two passwords a cracker will try might be 1234 and test.. No big deal. Databases of MD5-hashes exists. And so can exist Databases of SHA-* hashes. To get around these databases you can just salt your hash.. that way the Hash of the word test will not be the same as the hash in the database without *your* salt. No matter if you use MD5 or SHA256 $ echo -ne test | md5sum 098f6bcd4621d373cade4e832627b4f6 - $ echo -ne test-mySecretSalt | md5sum c62fb41567c476e36ba46e5b53ae6d59 - Only the first string will be available in a hash-database. So you see - as long as a cracker only get's your salted hashes WITHOUT the used salt, it's pretty safe.. as long as you don't think about ignore collisions! Back to topic: - as mentioned before the biggest risk in authentication via .ht* files is that one can try to get these files via a bug in an application.. (e.g. ?read_file=.htaccess%00) - that's why you don't want to use plain text-passwords in .htaccess files. most used is the htdigest algorythm. Be sure to use a STRONG password: long string with letter, numbers and more chars. - if you're curious, get a copy of John the Ripper password cracker and try to decode your passwords.. that's what the bad guys use once they get your .htaccess file. Regards Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: How safe is a .htaccess file?
One thing I would do, and I have done this in many of my applications: a) Store the username / password in a database. b) Encrypt passwords (with a salt) with AES-256 using a key stored in a file OUTSIDE the document path. c) Add code to the beginning of the included file to ensure it is only executed by approved files. ?php if( 0 == preg_match( /maplerunfarm-secure\/admin.php/, $_SERVER[SCRIPT_FILENAME] ) ) { exit(Error: invalid inclusion of file. Please contact your system administrator); } $CONST_SECURE_KEY = DKTAZ+2EFaSHexdE0hbKJKiO/mQeF1hd; ? -Original Message- From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] Sent: Tuesday, August 24, 2010 9:09 AM To: Andre Polykanine Cc: Nathan Rixham; tedd; php-general@lists.php.net Subject: Re: [PHP] Re: How safe is a .htaccess file? 2010/8/19 Andre Polykanine an...@oire.org: Hello Nathan, Sorry, could you provide any links to read for a security noob?) Actually, I know that the md5 is decryptable (there are bases with words encrypted in md5), but I thought the SHA1 was secure... -- With best regards from Ukraine, Andre - Original message - From: Nathan Rixham nrix...@gmail.com To: tedd t...@sperling.com Date: Thursday, August 19, 2010, 12:03:12 PM Subject: [PHP] Re: How safe is a .htaccess file? tedd wrote: Hi gang: The subject line says it all. How secure is a .htaccess file to store passwords and other sensitive stuff? Can a .htaccess file be viewed remotely? Semi-safe, .htaccess is prevented from being served by configuration options (which come as default), however these can be overwritten so best to check by doing a GET on the resource URI. This doesn't prevent them from being exposed via other processes though, for instance a poorly coded 'download.php?path=/path/to/.htaccess' could still expose the file. Typically, its obviously better to store only a hash of a password rather than the pass in plain text, choosing the strongest algorithm you can; password security is of course relative though, a sha-512 of 'password1' is far from secure. A good way to approach encryption for files is to openssl_seal them using a public key which is only available to your application - this doesn't negate insecure code, but it at least ensures the raw files are encrypted securely enough to negate any of these worries. (just keep your private key safe, preferably in a pkcs12 w/a strong 64char+ pass) Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi Nathan, I'm not a crypto expert.. but I'll try to explain it: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... When you use test as a secret password, then no hashing algorythm at can be considered as safe. The first two passwords a cracker will try might be 1234 and test.. No big deal. Databases of MD5-hashes exists. And so can exist Databases of SHA-* hashes. To get around these databases you can just salt your hash.. that way the Hash of the word test will not be the same as the hash in the database without *your* salt. No matter if you use MD5 or SHA256 $ echo -ne test | md5sum 098f6bcd4621d373cade4e832627b4f6 - $ echo -ne test-mySecretSalt | md5sum c62fb41567c476e36ba46e5b53ae6d59 - Only the first string will be available in a hash-database. So you see - as long as a cracker only get's your salted hashes WITHOUT the used salt, it's pretty safe.. as long as you don't think about ignore collisions! Back to topic: - as mentioned before the biggest risk in authentication via .ht* files is that one can try to get these files via a bug in an application.. (e.g. ?read_file=.htaccess%00) - that's why you don't want to use plain text-passwords in .htaccess files. most used is the htdigest algorythm. Be sure to use a STRONG password: long string with letter, numbers and more chars. - if you're curious, get a copy of John the Ripper password cracker and try to decode your passwords.. that's what the bad guys use once they get your .htaccess file. Regards Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
On 24 August 2010 15:43, Gary php-gene...@garydjones.name wrote: Jan G.B. wrote: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... http://en.wikipedia.org/wiki/MD5#cite_note-1 It's worth noting that that essentially does not touch upon whether or not MD5 can be considered safe or not as a means to store password information. The researchers have discovered ways of crafting inputs to easily find colliding hashes - they have not discovered any easy means to craft an input that will collide with a given hash. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: How safe is a .htaccess file?
From: Peter Lind On 24 August 2010 15:43, Gary php-gene...@garydjones.name wrote: Jan G.B. wrote: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... http://en.wikipedia.org/wiki/MD5#cite_note-1 It's worth noting that that essentially does not touch upon whether or not MD5 can be considered safe or not as a means to store password information. The researchers have discovered ways of crafting inputs to easily find colliding hashes - they have not discovered any easy means to craft an input that will collide with a given hash. That's a simple matter of brute force, which can be done once and saved for instant use later. However, putting a salt into your algorithm pretty much eliminates the chances of success using that attack. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
2010/8/24 Bob McConnell r...@cbord.com: From: Peter Lind On 24 August 2010 15:43, Gary php-gene...@garydjones.name wrote: Jan G.B. wrote: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... http://en.wikipedia.org/wiki/MD5#cite_note-1 It's worth noting that that essentially does not touch upon whether or not MD5 can be considered safe or not as a means to store password information. The researchers have discovered ways of crafting inputs to easily find colliding hashes - they have not discovered any easy means to craft an input that will collide with a given hash. That's a simple matter of brute force, which can be done once and saved for instant use later. However, putting a salt into your algorithm pretty much eliminates the chances of success using that attack. Bob McConnell Thanks.. actually it's quite annoying when you post an answer which tries to explain a subject and people just post a link as response to one citation which somehow lacks relevance on the topic. My intro-sentence was I'm not a crypto expert. Gary, do you expect me to read the full detail report of Tao Xie and Dengguo Feng? Can you sum it up in two or three sentences? Regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
On 24 August 2010 16:25, Jan G.B. ro0ot.w...@googlemail.com wrote: 2010/8/24 Bob McConnell r...@cbord.com: From: Peter Lind On 24 August 2010 15:43, Gary php-gene...@garydjones.name wrote: Jan G.B. wrote: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... http://en.wikipedia.org/wiki/MD5#cite_note-1 It's worth noting that that essentially does not touch upon whether or not MD5 can be considered safe or not as a means to store password information. The researchers have discovered ways of crafting inputs to easily find colliding hashes - they have not discovered any easy means to craft an input that will collide with a given hash. That's a simple matter of brute force, which can be done once and saved for instant use later. However, putting a salt into your algorithm pretty much eliminates the chances of success using that attack. Bob McConnell Thanks.. actually it's quite annoying when you post an answer which tries to explain a subject and people just post a link as response to one citation which somehow lacks relevance on the topic. The link posted was all the relevance there is. MD5 is not weak in the sense that it is easy to find collisions when all you have is a hash (which is what you were implying). MD5 is only weak in the sense that it's possibly to generate two input texts such that the MD5 hashes of both will collide. The other weakness of MD5 (the more relevant one here) is that calculating an MD5 hash is relatively fast today. Which means you can generate rainbow tables of the most common inputs in relatively little time. Of course, these rainbow tables are worthless against more secure passwords and/or against salted passwords. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 /hype -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
2010/8/24 Peter Lind peter.e.l...@gmail.com: On 24 August 2010 16:25, Jan G.B. ro0ot.w...@googlemail.com wrote: 2010/8/24 Bob McConnell r...@cbord.com: From: Peter Lind On 24 August 2010 15:43, Gary php-gene...@garydjones.name wrote: Jan G.B. wrote: The weakness of MD5 is mainly because MD5 collisions are possible. That means, that different strings can have the same MD5-hash... http://en.wikipedia.org/wiki/MD5#cite_note-1 It's worth noting that that essentially does not touch upon whether or not MD5 can be considered safe or not as a means to store password information. The researchers have discovered ways of crafting inputs to easily find colliding hashes - they have not discovered any easy means to craft an input that will collide with a given hash. That's a simple matter of brute force, which can be done once and saved for instant use later. However, putting a salt into your algorithm pretty much eliminates the chances of success using that attack. Bob McConnell Thanks.. actually it's quite annoying when you post an answer which tries to explain a subject and people just post a link as response to one citation which somehow lacks relevance on the topic. The link posted was all the relevance there is. MD5 is not weak in the sense that it is easy to find collisions when all you have is a hash (which is what you were implying). MD5 is only weak in the sense that it's possibly to generate two input texts such that the MD5 hashes of both will collide. The other weakness of MD5 (the more relevant one here) is that calculating an MD5 hash is relatively fast today. Which means you can generate rainbow tables of the most common inputs in relatively little time. Of course, these rainbow tables are worthless against more secure passwords and/or against salted passwords. Regards Peter Hi peter, this clears it up for me. So I was quite correct with my post. :-) Have a nice day. Regards, Jan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How safe is a .htaccess file?
tedd wrote: Hi gang: The subject line says it all. How secure is a .htaccess file to store passwords and other sensitive stuff? Can a .htaccess file be viewed remotely? Semi-safe, .htaccess is prevented from being served by configuration options (which come as default), however these can be overwritten so best to check by doing a GET on the resource URI. This doesn't prevent them from being exposed via other processes though, for instance a poorly coded 'download.php?path=/path/to/.htaccess' could still expose the file. Typically, its obviously better to store only a hash of a password rather than the pass in plain text, choosing the strongest algorithm you can; password security is of course relative though, a sha-512 of 'password1' is far from secure. A good way to approach encryption for files is to openssl_seal them using a public key which is only available to your application - this doesn't negate insecure code, but it at least ensures the raw files are encrypted securely enough to negate any of these worries. (just keep your private key safe, preferably in a pkcs12 w/a strong 64char+ pass) Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How safe is a .htaccess file?
Hello Nathan, Sorry, could you provide any links to read for a security noob?) Actually, I know that the md5 is decryptable (there are bases with words encrypted in md5), but I thought the SHA1 was secure... -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion - Original message - From: Nathan Rixham nrix...@gmail.com To: tedd t...@sperling.com Date: Thursday, August 19, 2010, 12:03:12 PM Subject: [PHP] Re: How safe is a .htaccess file? tedd wrote: Hi gang: The subject line says it all. How secure is a .htaccess file to store passwords and other sensitive stuff? Can a .htaccess file be viewed remotely? Semi-safe, .htaccess is prevented from being served by configuration options (which come as default), however these can be overwritten so best to check by doing a GET on the resource URI. This doesn't prevent them from being exposed via other processes though, for instance a poorly coded 'download.php?path=/path/to/.htaccess' could still expose the file. Typically, its obviously better to store only a hash of a password rather than the pass in plain text, choosing the strongest algorithm you can; password security is of course relative though, a sha-512 of 'password1' is far from secure. A good way to approach encryption for files is to openssl_seal them using a public key which is only available to your application - this doesn't negate insecure code, but it at least ensures the raw files are encrypted securely enough to negate any of these worries. (just keep your private key safe, preferably in a pkcs12 w/a strong 64char+ pass) Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How safe is a .htaccess file?
tedd wrote: tedd wrote: Hi gang: The subject line says it all. How secure is a .htaccess file to store passwords and other sensitive stuff? Can a .htaccess file be viewed remotely? Semi-safe, .htaccess is prevented from being served by configuration options (which come as default), however these can be overwritten so best to check by doing a GET on the resource URI. This doesn't prevent them from being exposed via other processes though, for instance a poorly coded 'download.php?path=/path/to/.htaccess' could still expose the file. Typically, its obviously better to store only a hash of a password rather than the pass in plain text, choosing the strongest algorithm you can; password security is of course relative though, a sha-512 of 'password1' is far from secure. A good way to approach encryption for files is to openssl_seal them using a public key which is only available to your application - this doesn't negate insecure code, but it at least ensures the raw files are encrypted securely enough to negate any of these worries. (just keep your private key safe, preferably in a pkcs12 w/a strong 64char+ pass) Best, Nathan Nathan: I keep in running in circles because I keep getting differing recommendations as to how to keep data secure. If you read Chris Shiflett's book on Essential PHP Security -- he says to keep everything in a database. This means keeping both encrypted data AND the keys for decryption in the database. I contacted Chris specifically and told him of what I was doing (all the steps) and he approved. However, he said the main weakness in all security practices is how one protects access to the database. So that is my quest. How can I protect the username and password for the database? Keep in mind that my scripts must also be able to read and use them in accessing the database. So they must be accessible to scripts. I figure using SetEnv to set the user and password in a .htaccess file is about as secure as I can make it, but now you say even that could be exposed. So specifically, how would you hide the username and password for access to a database WITHOUT using an out of root solution? Please be specific. Hi Tedd, Firstly, advising to keep the keys to your car in the ignition at all times is pretty bad advise - I'll let you relate that to Chris's advice yourself :-) If your stuck in an environment where third parties have access to the files on the file system and you need to put your username/password (real keys to the data) on that filesystem, then I have to point out that no file extension is more secure than another, there's no difference between doing `cat .htaccess` and `cat config.php` you'll still see the output - there's is a measure of difference however between putting it in a web source-viewable file and non-source-viewable file, but again your only a config setting away from being exposed to the world. Given the aforementioned and that the data is sensitive, I'd strongly recommend moving to a different hosting environment: - which is secure filesystem wise and only you have access to your files - where the db server (or data tier) is on a private lan (preventing the db server from public web attacks) - where access to the db server (or data tier) is via a secured connection [1] (encrypting data across the wire to prevent man in the middle attacks and packet inspection) In addition to application specific security measures such as encrypting all sensitive data *before* sending to the database and storing the encryption keys in a secure lockbox far away from the db or at least in a pcks12 password protected file outside of the web root. Now, to answer your specific question, specifically :p If available I would use ioncube or suchlike to encrypt the source of my PHP files (with the username pass in a php file as standard), and if I still didn't feel like that was secure enough then I would: create an pcks12 wrapped x509 certificate for my application: http://pastebin.com/THW00RHt (fill in lines 34+36 stick on web server, view in browser cert will dl) Then I'd store the produced certificate.p12 on the file system (preferably outside of web root, or with access restricted by .htaccess config) I'd then create a crypto class which provided methods to seal and open (encrypt/decrypt) data using the keys from the x509 certificate, and which could read the .p12 wrapped x509, like this: http://pastebin.com/4FSx1XDa I'd then instantiate the crypto class in my application as such: $crypto = ApplicationCrypto::instantiate( file_get_contents('certificate.p12'), 'PASSWORD-FOR-PKCS-HERE' ); Then I'd load my database settings in to an object, serialize it, encrypt the serialization and save it to a file on the filesystem as such: $dbSettings = (object)array( 'username' = 'dbuser', 'password' = 'dbpass', 'host' = 'dbhost', 'database' = 'dbname' ); $sealed = $crypto-seal(
[PHP] Re: How to set socket_read time out
On Mon, Jul 19, 2010 at 9:45 AM, Gary wrote: How can I get calls to scoket_read to timeout if the server stops responding? Sorry. Found it: socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' = 1, 'usec' = 0)); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to use HTML Symbol Entities with mail() ?
From: Ashley Sheridan To: Manuel Lemos Cc: cr.vege...@gmail.com ; php-general@lists.php.net Sent: Saturday, July 03, 2010 1:22 PM Subject: Re: [PHP] Re: how to use HTML Symbol Entities with mail() ? On Fri, 2010-07-02 at 22:58 -0300, Manuel Lemos wrote: Hello, on 07/01/2010 10:34 AM cr.vege...@gmail.com said the following: Hi List, I am working on generated emails, using the mail() function. Works fine, but when including characters like #8743 (= and;) or #8744; (= or;) in the message, these characters are displayed as ? in the emails. Snippet: $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; ... $bool = mail ($mailto, $subject, $body, $headers); also tested with: $headers .= 'Content-type: text/html; charset=UTF-8' . \r\n; but without result. Any ideas ? TIA, Cor When those characters appear as question marks is because you are using a font in the messages that does not have characters with those codes. Try including the sections of those characters with some span tags like this span style=font-family: font-name-here#8744;/span -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ I don't believe it is the font issue, and don't forget that outputting HTML for an email is very different, so there are some things that you can specify that will be ignored by some email clients when they render your email. Those glyphs should be available to any system, as the email client should use whatever font on the system is set up for the extended glyphs where they are not available in the current font. What email clients are you testing this on? Are they web based, or local? It's a good idea to test HTML emails on a variety of email clients, as they all can behave very differently. Thanks, Ash http://www.ashleysheridan.co.uk Sorry for the delay; was away a few days. The special characters (#8743; #8744;) are part of td tags. I tested both: tdspan style=font-family: arial,courier,times#8744;/span/td and td style=font-family: arial,courier,times#8744;/td but without the desired result. BTW, I wrote that the spec. characters are displayed in my email as ? In fact they are displayed as little squares, but copying it here makes it a ? mark. I am testing the HTML emails web based with Outlook Express, with the Format - Encoding setting to UTF-8. The only reason to use the spec. chars is to simulate arrows, without img. TIA, Cor
Re: [PHP] Re: how to use HTML Symbol Entities with mail() ?
On Fri, 2010-07-02 at 22:58 -0300, Manuel Lemos wrote: Hello, on 07/01/2010 10:34 AM cr.vege...@gmail.com said the following: Hi List, I am working on generated emails, using the mail() function. Works fine, but when including characters like #8743 (= and;) or #8744; (= or;) in the message, these characters are displayed as ? in the emails. Snippet: $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; ... $bool = mail ($mailto, $subject, $body, $headers); also tested with: $headers .= 'Content-type: text/html; charset=UTF-8' . \r\n; but without result. Any ideas ? TIA, Cor When those characters appear as question marks is because you are using a font in the messages that does not have characters with those codes. Try including the sections of those characters with some span tags like this span style=font-family: font-name-here#8744;/span -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ I don't believe it is the font issue, and don't forget that outputting HTML for an email is very different, so there are some things that you can specify that will be ignored by some email clients when they render your email. Those glyphs should be available to any system, as the email client should use whatever font on the system is set up for the extended glyphs where they are not available in the current font. What email clients are you testing this on? Are they web based, or local? It's a good idea to test HTML emails on a variety of email clients, as they all can behave very differently. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: how to use HTML Symbol Entities with mail() ?
Hello, on 07/01/2010 10:34 AM cr.vege...@gmail.com said the following: Hi List, I am working on generated emails, using the mail() function. Works fine, but when including characters like #8743 (= and;) or #8744; (= or;) in the message, these characters are displayed as ? in the emails. Snippet: $headers = 'MIME-Version: 1.0' . \r\n; $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n; ... $bool = mail ($mailto, $subject, $body, $headers); also tested with: $headers .= 'Content-type: text/html; charset=UTF-8' . \r\n; but without result. Any ideas ? TIA, Cor When those characters appear as question marks is because you are using a font in the messages that does not have characters with those codes. Try including the sections of those characters with some span tags like this span style=font-family: font-name-here#8744;/span -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to update array keys and keep element order ?
On 5/21/2010 5:56 AM, cr.vege...@gmail.com wrote: How do I update an array key without disturbing the element order ? Suppose an existing array(FR, values ...) where I want to change 0 = FR to country = FR and keep the original element order. TIA, Cor I short on time; but, it seems array_combine() or array_fill_keys() would do it for you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to prevent duplicate record insertion after refreshing php page
Deva wrote: Hi, If I do refresh after submission of a form, records are getting stored multiple times. I have two pages. /submission-form/ and /thank-you/ I was trying header('Location: /thank-you/'); on submission-form page after successful validation and insertion into db. Still if I do refresh on thank-you page it adds one more record in database. How to prevent it without token? if you use POST for the form then the user agent should pop up a nice do you want to send the data again type dialogue box. if you add a unique key over a few of the columns then this will prevent duplicates at the table level (regardless of the scenario). to handle POST data, well no point me repeating it, see the spec: http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-09#section-7.5 Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How define if javascript is on with php
Hello, on 04/16/2010 08:50 AM Paulo-WORK said the following: Hello and thanks for any replies that this message may get. I have a issue to solve regarding PHP. My website relies heavlly on jquery and does not dowgrade properly. I use codeigniter framework as this website has a backend . Is it possible to detect if js is on with php? And if so can it be set into a variable? Paulo Carvalho This class does exactly what you are asking: http://www.phpclasses.org/package/5297-PHP-Check-whether-Javascript-is-enabled-in-the-browser.html -- Regards, Manuel Lemos Find and post PHP jobs http://www.phpclasses.org/jobs/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to overload accessible methods
thanks for all your reply, since all these classes have main entry in cron.php, I have moved validation there. Richard, your solution seems interesting, maybe I can use it later :) On Thu, Apr 15, 2010 at 4:46 AM, Richard Quadling rquadl...@googlemail.com wrote: On 13 April 2010 17:25, Ryan Sun ryansu...@gmail.com wrote: this is a class for corntab job, and the validation is very simple, just check if the status of user is active when cron job runs, if not, throws an exception, other developers won't want to overwrite this validation. which method of user class will be called is configurable via website backed page(we write the name of methods directly in to schedule table). Using private methods will solve the problem but since we write public methods for all the other cron classes, I just want to keep the style to make less confusion. On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham nrix...@gmail.com wrote: Ryan Sun wrote: I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? This may call for a back to roots approach, what exactly are you trying to accomplish, as in: what is the validation doing? perhaps if we see the full picture, we can recommend another perhaps more suited approach to the full thing, feel free to post the full code if you want / can, the more info the better! Regards, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Would this be better ... abstract class baseValidate() { final public function __construct($params) { // Determine if user is active. // If OK, then call abstract function postConstruct($params) } abstract function postConstruct($params); } You can't override the constructor, so the validation will always be called. The developer's can implement their own postConstruct as if they where extending __construct. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to overload accessible methods
On 13 April 2010 17:25, Ryan Sun ryansu...@gmail.com wrote: this is a class for corntab job, and the validation is very simple, just check if the status of user is active when cron job runs, if not, throws an exception, other developers won't want to overwrite this validation. which method of user class will be called is configurable via website backed page(we write the name of methods directly in to schedule table). Using private methods will solve the problem but since we write public methods for all the other cron classes, I just want to keep the style to make less confusion. On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham nrix...@gmail.com wrote: Ryan Sun wrote: I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? This may call for a back to roots approach, what exactly are you trying to accomplish, as in: what is the validation doing? perhaps if we see the full picture, we can recommend another perhaps more suited approach to the full thing, feel free to post the full code if you want / can, the more info the better! Regards, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Would this be better ... abstract class baseValidate() { final public function __construct($params) { // Determine if user is active. // If OK, then call abstract function postConstruct($params) } abstract function postConstruct($params); } You can't override the constructor, so the validation will always be called. The developer's can implement their own postConstruct as if they where extending __construct. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to overload accessible methods
Ryan Sun wrote: As we all know, __call() can overload non-accessible methods, eg. Class User { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } $user = new User(); $user-update() // will call _validate before _update automatically BUT, if I want to make this update a public function, how can I call the validate without call it inside update function explicitly? why would you want to, is there a technical reason for wanting magic functionality instead of normal functionality (+ wouldn't it make the code much easier to maintain and debug if developers can see what is called where, instead of just magic). to answer though, you're best bet is probably to make an abstract class with magic functionality and then extend with an implementing public class. abstract class MagicUser { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } class User extends MagicUser { public function update($args) { parent::update($args); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to overload accessible methods
I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? On Tue, Apr 13, 2010 at 11:46 AM, Nathan Rixham nrix...@gmail.com wrote: Ryan Sun wrote: As we all know, __call() can overload non-accessible methods, eg. Class User { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } $user = new User(); $user-update() // will call _validate before _update automatically BUT, if I want to make this update a public function, how can I call the validate without call it inside update function explicitly? why would you want to, is there a technical reason for wanting magic functionality instead of normal functionality (+ wouldn't it make the code much easier to maintain and debug if developers can see what is called where, instead of just magic). to answer though, you're best bet is probably to make an abstract class with magic functionality and then extend with an implementing public class. abstract class MagicUser { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } class User extends MagicUser { public function update($args) { parent::update($args); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how to overload accessible methods
On Tue, 2010-04-13 at 12:03 -0400, Ryan Sun wrote: I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? On Tue, Apr 13, 2010 at 11:46 AM, Nathan Rixham nrix...@gmail.com wrote: Ryan Sun wrote: As we all know, __call() can overload non-accessible methods, eg. Class User { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } $user = new User(); $user-update() // will call _validate before _update automatically BUT, if I want to make this update a public function, how can I call the validate without call it inside update function explicitly? why would you want to, is there a technical reason for wanting magic functionality instead of normal functionality (+ wouldn't it make the code much easier to maintain and debug if developers can see what is called where, instead of just magic). to answer though, you're best bet is probably to make an abstract class with magic functionality and then extend with an implementing public class. abstract class MagicUser { public function __call($name, $args) { //validate user $this-_validate(); $this-_{$name}($args); } private function _validate() { // } private function _update($args) { // } } class User extends MagicUser { public function update($args) { parent::update($args); } } That would mean that the class can only be extended as far as your validation code allows, and the developers extending your class will have little control over how anything is validated. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] Re: how to overload accessible methods
Ryan Sun wrote: I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? This may call for a back to roots approach, what exactly are you trying to accomplish, as in: what is the validation doing? perhaps if we see the full picture, we can recommend another perhaps more suited approach to the full thing, feel free to post the full code if you want / can, the more info the better! Regards, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to overload accessible methods
this is a class for corntab job, and the validation is very simple, just check if the status of user is active when cron job runs, if not, throws an exception, other developers won't want to overwrite this validation. which method of user class will be called is configurable via website backed page(we write the name of methods directly in to schedule table). Using private methods will solve the problem but since we write public methods for all the other cron classes, I just want to keep the style to make less confusion. On Tue, Apr 13, 2010 at 12:11 PM, Nathan Rixham nrix...@gmail.com wrote: Ryan Sun wrote: I'm writing an abstract parent class which only contain a validate method, other developers will extend this class and add many new public methods, every new methods will need to perform a validate first. Won't it be good if validate get called automatically before every method call so that they don't have to write more code and they won't miss this validate? This may call for a back to roots approach, what exactly are you trying to accomplish, as in: what is the validation doing? perhaps if we see the full picture, we can recommend another perhaps more suited approach to the full thing, feel free to post the full code if you want / can, the more info the better! Regards, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to get the local time
You should be able to get the local time for Sweden by adding ?php date_default_timezone_set('Stockholm/Sweden'); echo date('l F jS, o');? However, I dont know about getting the local time of someone visiting from a different time zone. gary saeed ahmed saeed@gmail.com wrote in message news:b10025e1003151310j483caed1mef9ec76874a53...@mail.gmail.com... hi friends, I'm trying to set local time in my php script. I was trying date and time function but its always show the server time not local time. i need help on this problem. how can i set the local time. i need sweden time zone - Regards Saeed Ahmed http://saeed05.wordpress.com - __ Information from ESET Smart Security, version of virus signature database 4946 (20100315) __ The message was checked by ESET Smart Security. http://www.eset.com __ Information from ESET Smart Security, version of virus signature database 4946 (20100315) __ The message was checked by ESET Smart Security. http://www.eset.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
Daniel P. Brown wrote: (Typing from the DROID, so forgive the top-posting.) Shawn, would you take a few moments to submit this as a bug at http://bugs.php.net/? I know you well enough that, if you say the docs suck, they probably do. On Jan 29, 2010 10:47 PM, Shawn McKenzie nos...@mckenzies.net wrote: Eric Lee wrote: On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.net wrote: ... So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com Done. Thanks Dan. http://bugs.php.net/bug.php?id=50886 -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
On Sat, Jan 30, 2010 at 12:18, Shawn McKenzie nos...@mckenzies.net wrote: Done. Thanks Dan. http://bugs.php.net/bug.php?id=50886 Thank you, sir. I thanked you on Facebook when I saw the report come in, but wanted to thank you properly here as well. -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ Looking for hosting or dedicated servers? Ask me how we can fit your budget! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how do I use php://memory?
Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.netwrote: Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. Shawn I did a sample test from the manual with fopen like this, ?php $fp = fopen('php://memory', 'r+'); if ($fp) { fputs($fp, line 1\n); } rewind($fp); echo stream_get_contents($fp); ? console output F:\wc\trunkphp -f m.php line 1 Regards, Eric, -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
Eric Lee wrote: On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.netwrote: Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. Shawn I did a sample test from the manual with fopen like this, ?php $fp = fopen('php://memory', 'r+'); if ($fp) { fputs($fp, line 1\n); } rewind($fp); echo stream_get_contents($fp); ? console output F:\wc\trunkphp -f m.php line 1 Regards, Eric, So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
(Typing from the DROID, so forgive the top-posting.) Shawn, would you take a few moments to submit this as a bug at http://bugs.php.net/? I know you well enough that, if you say the docs suck, they probably do. On Jan 29, 2010 10:47 PM, Shawn McKenzie nos...@mckenzies.net wrote: Eric Lee wrote: On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.net wrote: ... So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubsc...
[PHP] Re: How to change a filename for download (e.g. jpeg, pdf etc.)
Hi, Can anyone point me to tutorials on how to change a filename for each download? My goal is to give the downloader a random name for a picture or a document, so he will never know what the original filename is. Try adding a Content-Disposition header: ?php header('Content-disposition: attachment; filename=fname.ext'); ? -- Richard Heyes HTML5 canvas graphing: RGraph - http://www.rgraph.net (updated 23rd January) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how to retrieve a dom from innerHTML......
I am on the top of the world! Borlange University wrote: hello, i can obnot retrieve a select ject from div innerHTML. what i want to do is that when a page is loaded, first selector,say #1, would be shown in the first div by sending a request.then i choose one option from #1, fire change event of #1, the second selector #2 will be shown in div two, then choose option from #2 .blabla.. but the problem is when selector #1 was loaded, the object #1 could not be obtained. codes: window.addEvent('domready', function() { var option=1; var result = new Request({ url:'getInfo_gx.php'https://mail.google.com/mail/html/compose/static_files/'getInfo_gx.php' , method:'get', onSuccess:function(response) { if(option==1) $('list_sch').innerHTML = response; //response = select id='sch_list...'; else if(option==2) $('list_gg').innerHTML = response; else $('list_gx').innerHTML = response; } }); result.send('type=1');// page loaded,sending a request. $('list_sch').innerHTML = select id='sch_list'option value='123'123312/option/select; if($('sch_list')) // heres the problem... object can not be obtained. { $('sch_list').addEvent('change',function(){ // events can not be fired option=2; result.send('type=2'+'sch='+$('sch_list').value.replace('+','%2B')); }); } }); You probably ought to ask a Javascript forum about javascript problems... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How do I remove unused GET parameters from the URL?
Daevid Vincent wrote: BTW, I want to use GET so that the page can be bookmarked for future searches of the same data (or modified easily with different dates, etc.), so that's why I don't use POST. to do as you say on the clientside you'd probably be best to write a short js script to build the get url from the form data; and on the serverside just take the klunky approach you mentioned. worth thinking about scenarios where a field is empty on the initial search though; but a user may want to modify it by entering in a value to a previously blank field (which would at this point be stripped); so maybe removal isn't the best option. possibly worth considering having a GET url which (p)re-populates the form (rather than direct to the search results) so the search can be easily modified before submitting it..? also you could just pass the url through to an url shrinker; if you use the api of bit.ly or suchlike you could do this serverside; and reap the benefits of stats for each search too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to make the PHP know the real SCRIPT_FILENAME?
Dong Wang wrote: I am trying to use PHP as backend, which communicate with apache-2.3's mod_proxy_fcgi But I have noticed that the SCRIPT_FILENAME has been changed to proxy:balancer://xx, it cann't be recognized by the remote PHP backend. So the request failed. In my opinion, the remote PHP backend use the SCRIPT_FILENAME to find the script file. But the PHP and the Apache may be in different computer, so the Document Root may be different. is that means the PHP shouldn't rely on the SCRIPT_FILENAME? how can I configure the PHP to know the real script file to execute? Thank you $real_script_file = __FILE__; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to call DLL in Javascript
Peter wrote: Hi All, I want to call dll in javascript I tried the following script, but i got the error message 'ActiveXObject is undefined' (Note : i have the feedback.dll in the same path only) HTML HEAD script type='text/javascript' language='javascript' function comEventOccured() { try{ var myobject; myobject = new ActiveXObject(feedback.dll); }catch(e){ alert(e.description); return false; } } /script/head body input type=button value=Call the DLL onClick=comEventOccured() /body /html Regards Peter. usually .dll should be running client side not server side jscript and javascript are two different beasts based on ecmascript; you'll be wanting to get some JScript (microsofts own version) help for this.. http://msdn.microsoft.com/en-us/library/7sw4ddf8%28VS.85%29.aspx but as somebody else mentioned, you won't get it working on all browsers AFAIK.. so running DLL on server side and calling wrapper functions via ajax is more appropriate. an asp.net forum or suchlike will probably yield a more useful response regards -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to make the PHP know the real SCRIPT_FILENAME?
ur... you mean use this in the php script? but the php-cgi still doesn't know which scriptfile to execute, isn't it? php-cgi tries to find the aimed script using SCRIPT_FILENAME, but this variable is changed by the mod_proxy_fcgi, so php-cgi can not find the real scriptfile, that's the point, I think. Or maybe there is something I misunderstand? On Tue, Nov 17, 2009 at 9:19 PM, Nathan Rixham nrix...@gmail.com wrote: Dong Wang wrote: I am trying to use PHP as backend, which communicate with apache-2.3's mod_proxy_fcgi But I have noticed that the SCRIPT_FILENAME has been changed to proxy:balancer://xx, it cann't be recognized by the remote PHP backend. So the request failed. In my opinion, the remote PHP backend use the SCRIPT_FILENAME to find the script file. But the PHP and the Apache may be in different computer, so the Document Root may be different. is that means the PHP shouldn't rely on the SCRIPT_FILENAME? how can I configure the PHP to know the real script file to execute? Thank you $real_script_file = __FILE__;