Re: [PHP] json_decode mistery
On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: $d = '{result_ok:true,result_message:null,client_name:Radek Krej\u010da}'; echo Initial: $d\n; echo Decoded:\n; var_dump(json_decode($d)); echo \n\nPHP Version: .phpversion().\n; Output == Initial: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} Decoded: object(stdClass)#1 (3) { [result_ok]= bool(true) [result_message]= NULL [client_name]= string(13) Radek Krejča } PHP Version: 5.3.10-1ubuntu3.6 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Sat, May 25, 2013 at 3:14 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: Which I now see was what the second part was about. Perhaps there is actually something in $decrypted_data that is not legal JSON data that doesn't appear when you echo it? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Sat, May 25, 2013 at 3:21 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Sat, May 25, 2013 at 3:14 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 2:06 AM, Radek Krejča radek.kre...@starnet.cz wrote: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} How odd -- when i run that through json_decode, it works fine: Which I now see was what the second part was about. Perhaps there is actually something in $decrypted_data that is not legal JSON data that doesn't appear when you echo it? try checking json_last_error() after you attempt to decode $decrypted_data. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] .htaccess and user file/folder access outside public_html
Hi, i'm facing a problem and i don't know where to start and in fact, how to do it. Situation: Users of my website should be able to save their resume files + cover letters on my webserver. problem: how to make their file SECURED from any hack ? I mean only file owner and web administrator (so in this case... myself) should have access to those files. never user B should be able to access, read or download files of user A. my guess: i was thinking to store files outside public_html folder, in the following way: /resumes/user A/resume A /resumes/user A/cover letter A /resumes/user B/resume B - US /resumes/user B/resume B - ES /resumes/user B/cover letter B Questions: 1. how can i allow user to have access to folder/files outside public_html ? 2. how can i secure that user A has access to his own files ONLY ? i searched on internet for some help but i did not find anything really revelent...only theory and no really in details. I need your help. thx. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] .htaccess and user file/folder access outside public_html
On May 25, 2013, at 13:38, Rafnews raf.n...@gmail.com wrote: Hi, i'm facing a problem and i don't know where to start and in fact, how to do it. Situation: Users of my website should be able to save their resume files + cover letters on my webserver. problem: how to make their file SECURED from any hack ? I mean only file owner and web administrator (so in this case... myself) should have access to those files. never user B should be able to access, read or download files of user A. my guess: i was thinking to store files outside public_html folder, in the following way: /resumes/user A/resume A /resumes/user A/cover letter A /resumes/user B/resume B - US /resumes/user B/resume B - ES /resumes/user B/cover letter B Questions: 1. how can i allow user to have access to folder/files outside public_html ? 2. how can i secure that user A has access to his own files ONLY ? i searched on internet for some help but i did not find anything really revelent...only theory and no really in details. I need your help. thx. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You will have to make a few scripts that check whether User A is logged in or not, read the files with PHP, change the default headers and print the output, which should be the exact same document. A quick example would be: ?php // file_exists also checks whether a directory exists if (!empty($_SESSION['userId']) file_exists(dirname(__FILE__).'/../resumes/'.$_SESSION['userId']) { // all the necesary headers, check out the documentation for header() function on php.net header('(all the needed headers)'); echo file_get_contents(dirname(__FILE__).'/../resumes/'.$_SESSION['userId'].'/resume A.doc'); } Above is basic pseudo-code, not tested. Now all you have to care about is that userId is correctly set and that nobody can hijack that user account. Greetings. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] json_decode mistery
On Fri, May 24, 2013 at 9:06 AM, Radek Krejča radek.kre...@starnet.czwrote: Hello, I am usin json regulary, but in one script I have mistery: echo($decrypted_data).\n\n; var_dump(json_decode($decrypted_data, true)); echo \n; var_dump(json_decode('{result_ok:true,result_message:null,client_name:Radek Krej\u010da}', true)); I got: {result_ok:true,result_message:null,client_name:Radek Krej\u010da} NULL array(3) { [result_ok]= bool(true) [result_message]= NULL [client_name]= a } string(13) Radek KrejÄ You can see, that in $decrypted_data, is stored valid (by my opinion) json data. If I use this variable in json_decode, I got null. And if I manualy use data displayed on screen, I got valid array. Where I do mistake? If I remove client_name (so no utf8 is in json data), situation is the same. Radek Hi, It could be there are NUL-bytes or other unprintable ASCII characters in the original $decrypted_data. Try this: var_dump(json_encode($decrypted_data)); Yes, json_encode, as it will show \u or any other low unicode value. - Matijn
[PHP] Can javascript or php help with this
Hi all, I have a php form that has a pull down select for MONTH and one for YEAR - usually when the form is submitted you would combine them at the other end like 0517 (like credit card exp date) - but in this case I need to combine them prior to submitting the form... I don't know javascript but I'm curious if someone might know a way to use javascript (or some other method) to set another input field - EXPDATE - to contain the value MONTH YEAR combined prior to submitting the form? ... and in this case the form is going outside my site and other reasons so it's best to set this up prior to submitting the form. -- Thanks, Dave - DealTek deal...@gmail.com [db-3] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can javascript or php help with this
On 5/25/2013 4:33 PM, dealTek wrote: Hi all, I have a php form that has a pull down select for MONTH and one for YEAR - usually when the form is submitted you would combine them at the other end like 0517 (like credit card exp date) - but in this case I need to combine them prior to submitting the form... I don't know javascript but I'm curious if someone might know a way to use javascript (or some other method) to set another input field - EXPDATE - to contain the value MONTH YEAR combined prior to submitting the form? ... and in this case the form is going outside my site and other reasons so it's best to set this up prior to submitting the form. -- Thanks, Dave - DealTek deal...@gmail.com [db-3] So - create another field on your form. Add an onclick event to your submit button. Have it run a js function that takes the two fields and places them into the new field. function combineFields() { var mm = document.getElementById(monthfld).value; var yy = document.getElementById('yearfld).value; document.getElementByID(mmyy).value = +mm+yy; return true; } Might have to play with this syntax to avoid the values being arithmetically added instead of concatenated, but this is one way. And of course - you could try posting on a js site instead of a php one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Can javascript or php help with this
On 5/25/2013 4:33 PM, dealTek wrote: Hi all, I have a php form that has a pull down select for MONTH and one for YEAR - usually when the form is submitted you would combine them at the other end like 0517 (like credit card exp date) - but in this case I need to combine them prior to submitting the form... I don't know javascript but I'm curious if someone might know a way to use javascript (or some other method) to set another input field - EXPDATE - to contain the value MONTH YEAR combined prior to submitting the form? ... and in this case the form is going outside my site and other reasons so it's best to set this up prior to submitting the form. -- Thanks, Dave - DealTek deal...@gmail.com [db-3] So - create another field on your form. Add an onclick event to your submit button. Have it run a js function that takes the two fields and places them into the new field. function combineFields() { var mm = document.getElementById(monthfld).value; var yy = document.getElementById('yearfld).value; document.getElementByID(mmyy).value = +mm+yy; return true; } Might have to play with this syntax to avoid the values being arithmetically added instead of concatenated, but this is one way. And of course - you could try posting on a js site instead of a php one. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Can javascript or php help with this
On May 25, 2013, at 4:30 PM, Jim Giner jim.gi...@albanyhandball.com wrote: So - create another field on your form. Add an onclick event to your submit button. Have it run a js function that takes the two fields and places them into the new field. function combineFields() { var mm = document.getElementById(monthfld).value; var yy = document.getElementById('yearfld).value; document.getElementByID(mmyy).value = +mm+yy; return true; } Might have to play with this syntax to avoid the values being arithmetically added instead of concatenated, but this is one way. And of course - you could try posting on a js site instead of a php one. Thanks so much Jim - I will check into this (and I did just join a javascript list) -- Thanks, Dave - DealTek deal...@gmail.com [db-3]