Re: [PHP] /tmp/directory
At 11:50 AM 7/22/2013, Tedd Sperling wrote: On Jul 22, 2013, at 11:20 AM, Tedd Sperling t...@sperling.com wrote Hi gang: I should know this, but I don't. Where is the /tmp/ directory? You see, I have a client where his host has apparently changed the /tmp/ directory permissions such that old php/mysql scripts cannot write to the /tmp/ directory anymore -- they did at one time. So, how do I fix it? Cheers, tedd Let me add -- the PHP version I am working with is 4.3.10. I know... tedd The version of PHP should have nothing to do with this problem. The /tmp directory should be writable by everyone. If it's not, you need to talk to the hosting company support people. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Guaranteed Way to Get Error Message Wanted
Check the permissions on the files/directories involved. I get this on Linux when the files/directories are too open. Ken At 05:38 PM 7/5/2013, Brian Smither wrote: I have an application running under PHP-5.4.17-TS-VC9 (and .14 as of yesterday) with Aprelium's Abyss X1 v2.8 web server in FastCGI mode on WinXPSP3. An earlier version of this application works. The current version causes a 500 Internal Server Error. There is no entry in PHP's (fully active) error log. I cannot decipher Abyss's logging, so I cannot determine if a clue was reported by Abyss or not. The current version works on a different system (Server 2003, PHP 5.3.5-TS-VC6 (Apache module), Apache 2.2). What I would like to have is a method of getting PHP to report in some undeniable manner, short of total system failure, what it doesn't like about whatever killed it. -- 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
Re: [PHP] scandir doesn't find all files
Sent from my iPhone On Jun 22, 2013, at 3:10 PM, Daniel Pöllmann poellmann.dan...@gmail.com wrote: Hi, I have some files in a directory - some are uploaded via ftp and some other are created by a php script. Scandir just finds the uploaded files, but none of the created files. I can't run chown() because the server is part of shared hosting. I can't find anything about this behavour in the documentation. Best wishes, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scandir doesn't find all files
Did you try the glob function? http://php.net/glob Ken Sent from my iPhone On Jun 22, 2013, at 3:10 PM, Daniel Pöllmann poellmann.dan...@gmail.com wrote: Hi, I have some files in a directory - some are uploaded via ftp and some other are created by a php script. Scandir just finds the uploaded files, but none of the created files. I can't run chown() because the server is part of shared hosting. I can't find anything about this behavour in the documentation. Best wishes, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] iterate javascript verification
When you do validation of the form in the same script that shows the form, the normal way to do this is ?php if (isset($_POST['submit'])) { // // validation here // } ? This won't work if you're getting to the page via another form, since the $_POST['submit'] is set. There two ways of avoiding this: 1) use hidden fields in each form to indicate which form was submitted 2) use a different name for each form's submit button and use that in the above code Ken At 12:52 PM 5/27/2013, Tim Dunphy wrote: Hey guys, Thanks for the input! This is pretty nice, and DOES work. I like the fact that the fields have been into an iterative array. It's a very elegant solution. However the problem with this approach is that if you load the page directly it works. But if you call the page from the index.php page you get an initial error on all fields as they are all quite naturally empty when you first load the page. Here's the index.php page. All it is is HTML, no php: html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleLDAP Request Form/title body centerh3LDAP Request Form/h3 form name=form_request method=post action=ldap.php onsubmit=return validateForm() label for=requestor_emailYour Email Address:/labelbr / input type=text required id=requestor_email name=requestor_email /br /br / label for=num_formsHow Many Forms Do You Need:/labelbr / input type=text required maxlength=2 size=5 id=num_forms name=num_forms /br /br / input type=submit name=submit value=Submit / /form/center /body /html And here is ldap.php as was suggested: body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /br /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? Why this happens when you call the ldap.php page from index.php but not when you load the page directly beats me. But maybe someone can shed some light on that? Thanks! On Sat, May 25, 2013 at 3:45 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, May 24, 2013 at 9:51 PM, Ken Robinson kenrb...@rbnsn.com wrote: I took your code and modified it to use HTML5 validation (and few other changes). You can see the results at http://my-testbed.com/test1/form_validation.php http://my-testbed.com/test1/form_validation.php My code follows: ?php $fields = array('first_name','last_name','department','title','email','phone'); $num_forms = 1; $tmp = array(); $errors = array(); if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; for ($i = 1;$i = $num_forms; ++$i) { foreach ($fields as $fld) { if ($_POST[$fld][$i] == '') { $errors[] = ucwords(str_replace('_',' ',$fld)) . for account $i can not be blank; } } } } if (!empty($errors)) { $tmp[] = The following fields are in error:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp[] = div style='text-align:center'You will be creating $num_forms accounts today./divbr; $tmp[] = 'div style=text-align:centerform name=ldap_accounts method=post action='; $tmp[] = 'br /br /'; for($counter = 1;$counter
Re: [PHP] iterate javascript verification
You do realize that you shouldn't rely on Javascript to validate values returned in a form? Also, if you use HTML5, you can use the required attribute in the input tag and the browser won't let a user submit a form with a required field not filled. Of course, you should still validate within your PHP script, in case a user is using a browser that doesn't understand HTML5. At 08:07 PM 5/24/2013, Tim Dunphy wrote: Hello list, I have a php script that creates a variable number of forms based on a $_POST variable from a preceding page. It then takes the data input into the form and neatly packages the result into an email sent to an email address (eventually to be a ticketing system). Almost everything on the page works great. The only thing I can't seem to get working is how to verify that the fields in the form are not left empty using javascript. The syntax I'm using seems like it should work, however when I leave one or more of the fields empty, the email gets sent anyway with the missing data. Here's the app I was hoping someone might be able to suggest a successful approach: html head titleLDAP Form/title body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter.\ /br /br /; echo label for=\last_name_.$counter.\Last Name:/labelbr /; echo input type=\text\ id=\last_name_.$counter.\ name=\last_name_.$counter.\ /br /br /; echo label for=\department_.$counter.\Department:/labelbr /; echo input type=\text\ id=\department_.$counter.\ name=\department_.$counter.\ /br /br /; echo label for=\title_.$counter.\Title:/labelbr /; echo input type=\text\ id=\title_.$counter.\ name=\title_.$counter.\ /br /br /; echo label for=\email_.$counter.\Email:/labelbr /; echo input type=\text\ id=\email_.$counter.\ name=\email_.$counter.\ /br /br /; echo label for=\phone_$counter.\Phone:/labelbr /; echo input type=\text\ id=\phone_.$counter.\ name=\phone_.$counter.\ /br /br /; ? script function validateForm() { var a=document.forms[ldap_accounts][first_name_].value; if (a==null || a==) { alert(User $counter first name must be filled out.); return false; } var b=document.forms[ldap_accounts][last_name_].value; if (b==null || b==) { alert(User $counter last name must be filled out.); return false; } var c=document.forms[ldap_accounts][department_].value; if (c==null || c==) { alert(User $counter department must be filled out.); return false; } var d=document.forms[ldap_accounts][title_].value; if (d==null || d==) { alert(User $counter title must be filled out.); return false; } var d=document.forms[ldap_accounts][email_].value; if (d==null || d==) { alert(User $counter address must be filled out.); return false; } var d=document.forms[ldap_accounts][phone_].value; if (d==null || d==) { alert(User $counter phone name must be filled out.); return false; } } /script ?php } echo input type=\hidden\ id=\num_forms\ name=\num_forms\ value=\$num_forms\ /br /br /; echo input type=\hidden\ id=\requestor_email\ name=\requestor_email\ value=\$requestor_email\ /; echo input type=\submit\ name=\submit\ value=\Create Ticket\ /; echo /form/center; ? /body /html Thanks, Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] iterate javascript verification
I took your code and modified it to use HTML5 validation (and few other changes). You can see the results at http://my-testbed.com/test1/form_validation.phphttp://my-testbed.com/test1/form_validation.php My code follows: ?php $fields = array('first_name','last_name','department','title','email','phone'); $num_forms = 1; $tmp = array(); $errors = array(); if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; for ($i = 1;$i = $num_forms; ++$i) { foreach ($fields as $fld) { if ($_POST[$fld][$i] == '') { $errors[] = ucwords(str_replace('_',' ',$fld)) . for account $i can not be blank; } } } } if (!empty($errors)) { $tmp[] = The following fields are in error:br; $tmp[] = implode(br\n,$errors); $tmp[] = br; } $tmp[] = div style='text-align:center'You will be creating $num_forms accounts today./divbr; $tmp[] = 'div style=text-align:centerform name=ldap_accounts method=post action='; $tmp[] = 'br /br /'; for($counter = 1;$counter=$num_forms;$counter++) { $tmp[] = Enter user: $counterbr /; $tmp[] = label for='first_name_$counter'First Name:/labelbr/; $tmp[] = input type='text' required id='first_name_$counter' name='first_name[$counter]'br /br /; $tmp[] = label for='last_name_$counter'Last Name:/labelbr /; $tmp[] = input type='text' required id='last_name_$counter' name='last_name[$counter]' /br /br /; $tmp[] = label for='department_$counter'Department:/labelbr/; $tmp[] = input type='text' required id='department_$counter.' name='department[$counter]' /br /br /; $tmp[] = label for='title_$counter'Title:/labelbr /; $tmp[] = input type='text' required id'title_.$counter' name='title[$counter]' /br /br /; $tmp[] = label for='email_.$counter'Email:/labelbr /; $tmp[] = input type='email' required id='email_.$counter' name='email[$counter]' /br /br /; $tmp[] = label for='phone_$counter'Phone:/labelbr /; $tmp[] = input type='text' required id='phone_$counter' name='phone[$counter]' /br /br /; } $tmp[] = input type='hidden' id='num_forms' name='num_forms' value='$num_forms' /br /br /; $tmp[] = input type='hidden' id='requestor_email' name='requestor_email' value='$requestor_email' /; $tmp[] = input type='submit' name='submit' value='Create Ticket' /; $tmp[] = /form/div; ? !DOCTYPE html html head titleLDAP Form/title body ?php echo implode(\n,$tmp) . \n; ? /body /html You will notice that I moved the code for the form to above the HTML section. I believe that very little PHP should be interspersed with the HTML -- it makes for cleaner code. You can use single quotes around form attributes so you don't have to escape the double quotes. The names in the form are now arrays. This makes your life much easier when extracting the values later in PHP. When you check the page in a HTML5 aware brower, you will see how the validation is done. Ken At 10:17 PM 5/24/2013, musicdev wrote: You can validate via JS if required, for example: (JS CODE): if(element.value.length == 0){ // handle 0 length value } I do agree with Ken that you SHOULD NOT perform JS validation. It is preferable to use php or the new HTML5 features. JS can be turned-off by the user which will make JS validation impossible. On Fri, May 24, 2013 at 8:07 PM, Tim Dunphy bluethu...@gmail.com wrote: Hello list, I have a php script that creates a variable number of forms based on a $_POST variable from a preceding page. It then takes the data input into the form and neatly packages the result into an email sent to an email address (eventually to be a ticketing system). Almost everything on the page works great. The only thing I can't seem to get working is how to verify that the fields in the form are not left empty using javascript. The syntax I'm using seems like it should work, however when I leave one or more of the fields empty, the email gets sent anyway with the missing data. Here's the app I was hoping someone might be able to suggest a successful approach: html head titleLDAP Form/title body ?php if (isset($_POST['submit'])) { $requestor_email = $_POST['requestor_email']; $num_forms = $_POST['num_forms']; } echo centerYou will be creating $num_forms accounts today./centerbr /; for($counter = 1;$counter=$num_forms;$counter++) { echo 'centerform name=ldap_accounts method=post action=sendemail.php onsubmit=return validateForm()'; echo 'br /br /'; echo Enter user: $counterbr /; echo label for=\first_name_.$counter.\First Name:/labelbr /; echo input type=\text\ id=\first_name_.$counter.\ name=\first_name_.$counter
Re: [PHP] Symfony?
Drupal 8 is being built using Symfony, which means I have to learn it. Ken At 12:44 PM 5/20/2013, Bastien wrote: Bastien Koert On 2013-05-20, at 12:40 PM, Tedd Sperling t...@sperling.com wrote: Hi gang: Who uses Symfony? Cheers, tedd _ I do. It's not my preferred framework. It's very powerful, but very complex and has a ton of yaml config files for the app. The learning curve is steep. What's the question? Bastien -- 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
Re: [PHP] Updated PHP breaks processing-intense Procedure
THank all of you for your help. I think I got this thing licked. On Wed, Apr 24, 2013 at 7:14 PM, Ken Kixmoeller phph...@comcast.net wrote: Thank you very much, Jim --- On Wed, Apr 24, 2013 at 5:34 PM, Jim Lucas li...@cmsws.com wrote: On 04/24/2013 03:24 PM, Ken Kixmoeller wrote: Thanks, Jim --- Is this different from the max_input_vars discussion above? (from David OBrien) yes. For example... php.ini:[suhosin] php.ini:;suhosin.log.syslog = php.ini:;suhosin.log.syslog.**facility = php.ini:;suhosin.log.syslog.**priority = php.ini:;suhosin.log.sapi = php.ini:;suhosin.log.script = php.ini:;suhosin.log.phpscript = 0 php.ini:;suhosin.log.script.**name http://suhosin.log.script.name = php.ini:; variables registered in the current scope: SUHOSIN_ERRORCLASS and php.ini:; SUHOSIN_ERROR. The first one is the alert class and the second variable is php.ini:;suhosin.log.**phpscript.name http://suhosin.log.phpscript.name= php.ini:;suhosin.log.**phpscript.is_safe = Off php.ini:;suhosin.log.use-x-**forwarded-for = Off php.ini:;suhosin.executor.max_**depth = 0 php.ini:;suhosin.executor.**include.max_traversal = 0 php.ini:;suhosin.executor.**include.whitelist = php.ini:;suhosin.executor.**include.blacklist = php.ini:;suhosin.executor.**func.whitelist = php.ini:;suhosin.executor.**func.blacklist = php.ini:;suhosin.executor.**eval.whitelist = php.ini:;suhosin.executor.**eval.blacklist = php.ini:;suhosin.executor.**disable_eval = Off php.ini:;suhosin.executor.**disable_emodifier = Off php.ini:; by default in Suhosin = 0.9.6. Allowing symlink() while open_basedir is used php.ini:;suhosin.executor.**allow_symlink = Off php.ini:; If you fear that Suhosin breaks your application, you can activate Suhosin's php.ini:; simulation mode with this flag. When Suhosin runs in simulation mode, php.ini:;suhosin.simulation = Off php.ini:; first. It always uses resource slot 0. If Suhosin got this slot assigned APC php.ini:; will overwrite the information Suhosin stores in this slot. When this flag is php.ini:; set Suhosin will request 2 Slots and use the second one. This allows working php.ini:;suhosin.apc_bug_**workaround = Off php.ini:;suhosin.sql.bailout_**on_error = Off php.ini:;suhosin.sql.user_**prefix = php.ini:;suhosin.sql.user_**postfix = php.ini:;suhosin.multiheader = Off php.ini:suhosin.mail.protect = 1 php.ini:; memory_limit to whatever value they want. Suhosin changes this fact and php.ini:; that Suhosin will disallows scripts setting the memory_limit to a value above php.ini:;suhosin.memory_limit = 0 php.ini:suhosin.session.**encrypt = Off php.ini:;suhosin.session.**cryptkey = php.ini:;suhosin.session.**cryptua = On php.ini:;suhosin.session.**cryptdocroot = On php.ini:;suhosin.session.**cryptraddr = 0 php.ini:; session. The difference to suhosin.session.cryptaddr is, that the IP is not php.ini:;suhosin.session.**checkraddr = 0 php.ini:;suhosin.cookie.**encrypt = 0 php.ini:;suhosin.cookie.**cryptkey = php.ini:;suhosin.cookie.**cryptua = On php.ini:;suhosin.cookie.**cryptdocroot = On php.ini:;suhosin.cookie.**cryptraddr = 0 php.ini:; cookie. The difference to suhosin.cookie.cryptaddr is, that the IP is not php.ini:;suhosin.cookie.**checkraddr = 0 php.ini:;suhosin.cookie.**cryptlist = php.ini:;suhosin.cookie.**plainlist = php.ini:; Defines the reaction of Suhosin on a filter violation. php.ini:;suhosin.filter.action = php.ini:;suhosin.cookie.max_**array_depth = 50 php.ini:;suhosin.cookie.max_**array_index_length = 64 php.ini:;suhosin.cookie.max_**name_length = 64 php.ini:;suhosin.cookie.max_**totalname_length = 256 php.ini:;suhosin.cookie.max_**value_length = 1 php.ini:;suhosin.cookie.max_**vars = 100 php.ini:;suhosin.cookie.**disallow_nul = 1 php.ini:;suhosin.get.max_**array_depth = 50 php.ini:;suhosin.get.max_**array_index_length = 64 php.ini:;suhosin.get.max_name_**length = 64 php.ini:;suhosin.get.max_**totalname_length = 256 php.ini:;suhosin.get.max_**value_length = 512 php.ini:;suhosin.get.max_vars = 100 php.ini:;suhosin.get.disallow_**nul = 1 php.ini:;suhosin.post.max_**array_depth = 50 php.ini:;suhosin.post.max_**array_index_length = 64 php.ini:;suhosin.post.max_**name_length = 64 php.ini:;suhosin.post.max_**totalname_length = 256 php.ini:suhosin.post.max_**value_length = 2048000 php.ini:suhosin.post.max_vars = 500 php.ini:;suhosin.post.**disallow_nul = 1 php.ini:;suhosin.request.max_**array_depth = 50 php.ini:;suhosin.request.max_**array_index_length = 64 php.ini:;suhosin.request.max_**totalname_length = 256 php.ini:suhosin.request.max_**value_length = 2048000 php.ini:;suhosin.request.max_**vars = 200 php.ini:;suhosin.request.max_**varname_length = 64 php.ini:;suhosin.request.**disallow_nul = 1 php.ini:;suhosin.upload.max_**uploads = 25 php.ini:;suhosin.upload.**disallow_elf = 1 php.ini:;suhosin.upload.**disallow_binary = 0 php.ini:;suhosin.upload.**remove_binary = 0 php.ini:;suhosin.upload
[PHP] Updated PHP breaks processing-intense Procedure
Hey - -- I have a huge screen -- to make it simple for the user, it does 100s of calls to MySQL and has 1,000s (literally) of POST variables. We have done extensive research and see that upgrading from php 5.1.6-27 to 5.1.6-39 is the thing that caused it to break. All other issues (Apache, PHP and MySQL configuration and Versions) have been methodically ruled out. Anybody experience this? Heard of it? Suggest a repair (other than changing my screen)? *** Please don't tell me to redesign the screen -- this may come, but now is an urgent situation.*** Worked fine in prior versions for the last 3 years. Thanks, Ken
Re: [PHP] Updated PHP breaks processing-intense Procedure
From the link: The php_register_variable_ex function in php_variables.c in PHP 5.3.9 allows remote attackers to execute arbitrary code via a request containing a large number of variables, related to improper handling of array variables. NOTE: this vulnerability exists because of an incorrect fix === I wondered if it was memory handling, but what is it (I wonder out loud) that could be improper about my array handling. No error messages are thrown. Ken On Wed, Apr 24, 2013 at 4:14 PM, David OBrien dgobr...@gmail.com wrote: On Wed, Apr 24, 2013 at 5:09 PM, Ken Kixmoeller phph...@comcast.netwrote: Hey - -- I have a huge screen -- to make it simple for the user, it does 100s of calls to MySQL and has 1,000s (literally) of POST variables. We have done extensive research and see that upgrading from php 5.1.6-27 to 5.1.6-39 is the thing that caused it to break. All other issues (Apache, PHP and MySQL configuration and Versions) have been methodically ruled out. Anybody experience this? Heard of it? Suggest a repair (other than changing my screen)? *** Please don't tell me to redesign the screen -- this may come, but now is an urgent situation.*** Worked fine in prior versions for the last 3 years. Thanks, Ken Looks like they fixed the bug that allowed that to work... php-common-5.1.6-32.el5.x86_64http://linuxsoft.cern.ch/cern/slc5X/x86_64/yum/updates/php-common-5.1.6-32.el5.x86_64.rpm [153 KiB] *Changelog* by Joe Orton (2012-02-02): - add security fix for CVE-2012-0830 (#786756) http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0830
Re: [PHP] Updated PHP breaks processing-intense Procedure
Thanks so much. Yes, we found that because PHP threw an error that said that explicitly. A bit of research led us to add a line to php.ini to set the max_input_vars to a higher level. At first, that appeared to fix it (on the development machine). The appearance is wrong; it is still broken. No errors are being thrown. We are baffled. Ken On Wed, Apr 24, 2013 at 4:23 PM, David OBrien dgobr...@gmail.com wrote: On Wed, Apr 24, 2013 at 5:14 PM, David OBrien dgobr...@gmail.com wrote: On Wed, Apr 24, 2013 at 5:09 PM, Ken Kixmoeller phph...@comcast.netwrote: Hey - -- I have a huge screen -- to make it simple for the user, it does 100s of calls to MySQL and has 1,000s (literally) of POST variables. We have done extensive research and see that upgrading from php 5.1.6-27 to 5.1.6-39 is the thing that caused it to break. All other issues (Apache, PHP and MySQL configuration and Versions) have been methodically ruled out. Anybody experience this? Heard of it? Suggest a repair (other than changing my screen)? *** Please don't tell me to redesign the screen -- this may come, but now is an urgent situation.*** Worked fine in prior versions for the last 3 years. Thanks, Ken Looks like they fixed the bug that allowed that to work... php-common-5.1.6-32.el5.x86_64http://linuxsoft.cern.ch/cern/slc5X/x86_64/yum/updates/php-common-5.1.6-32.el5.x86_64.rpm [153 KiB] *Changelog* by Joe Orton (2012-02-02): - add security fix for CVE-2012-0830 (#786756) http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2012-0830 *I looked around google some more and found there is a hard limit of 1000 post variables in 5.1.6* After weeks of using it, a problem was reported about just one function of the app that would sometimes return a blank screen. It took me hours of debugging (read: echo) to figure out what's going on, digging through some old PHP code (fun!): It appeared that only 1000 post variables arrived on the server. (Well, 1006 actually, but 2 were added by PHP, and that sounded like a PHP-style limitation of 1000.) A quick google lookup revealed that PHP introduced a new feature where it would limit the number of post variables. For safety reasons. The variable is called max_input_vars with a default of 1000. PHP states that this feature was introduced in 5.3.9, but I'm running 5.1.6 and the limit is enforced. Because the server is for production, it was running with on-screen warnings turned off. PHP says that it prints a warning and cuts. For me, that's a real WTF. A post request should be processed as all-or-nothing. It should instead refuse the request completely. But for a technology named personal home page the priorities are different.
Re: [PHP] Updated PHP breaks processing-intense Procedure
Thanks, Jim --- Is this different from the max_input_vars discussion above? (from David OBrien) Ken On Wed, Apr 24, 2013 at 5:06 PM, Jim Lucas li...@cmsws.com wrote: On 04/24/2013 02:40 PM, Ken Kixmoeller wrote: Thanks so much. Yes, we found that because PHP threw an error that said that explicitly. A bit of research led us to add a line to php.ini to set the max_input_vars to a higher level. At first, that appeared to fix it (on the development machine). The appearance is wrong; it is still broken. No errors are being thrown. We are baffled. Ken If you have the Suhosin patch installed, it also introduces other limits to GET and POST variable counts within PHP. -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/
Re: [PHP] Updated PHP breaks processing-intense Procedure
Thank you very much, Jim --- On Wed, Apr 24, 2013 at 5:34 PM, Jim Lucas li...@cmsws.com wrote: On 04/24/2013 03:24 PM, Ken Kixmoeller wrote: Thanks, Jim --- Is this different from the max_input_vars discussion above? (from David OBrien) yes. For example... php.ini:[suhosin] php.ini:;suhosin.log.syslog = php.ini:;suhosin.log.syslog.**facility = php.ini:;suhosin.log.syslog.**priority = php.ini:;suhosin.log.sapi = php.ini:;suhosin.log.script = php.ini:;suhosin.log.phpscript = 0 php.ini:;suhosin.log.script.**name http://suhosin.log.script.name = php.ini:; variables registered in the current scope: SUHOSIN_ERRORCLASS and php.ini:; SUHOSIN_ERROR. The first one is the alert class and the second variable is php.ini:;suhosin.log.**phpscript.name http://suhosin.log.phpscript.name= php.ini:;suhosin.log.**phpscript.is_safe = Off php.ini:;suhosin.log.use-x-**forwarded-for = Off php.ini:;suhosin.executor.max_**depth = 0 php.ini:;suhosin.executor.**include.max_traversal = 0 php.ini:;suhosin.executor.**include.whitelist = php.ini:;suhosin.executor.**include.blacklist = php.ini:;suhosin.executor.**func.whitelist = php.ini:;suhosin.executor.**func.blacklist = php.ini:;suhosin.executor.**eval.whitelist = php.ini:;suhosin.executor.**eval.blacklist = php.ini:;suhosin.executor.**disable_eval = Off php.ini:;suhosin.executor.**disable_emodifier = Off php.ini:; by default in Suhosin = 0.9.6. Allowing symlink() while open_basedir is used php.ini:;suhosin.executor.**allow_symlink = Off php.ini:; If you fear that Suhosin breaks your application, you can activate Suhosin's php.ini:; simulation mode with this flag. When Suhosin runs in simulation mode, php.ini:;suhosin.simulation = Off php.ini:; first. It always uses resource slot 0. If Suhosin got this slot assigned APC php.ini:; will overwrite the information Suhosin stores in this slot. When this flag is php.ini:; set Suhosin will request 2 Slots and use the second one. This allows working php.ini:;suhosin.apc_bug_**workaround = Off php.ini:;suhosin.sql.bailout_**on_error = Off php.ini:;suhosin.sql.user_**prefix = php.ini:;suhosin.sql.user_**postfix = php.ini:;suhosin.multiheader = Off php.ini:suhosin.mail.protect = 1 php.ini:; memory_limit to whatever value they want. Suhosin changes this fact and php.ini:; that Suhosin will disallows scripts setting the memory_limit to a value above php.ini:;suhosin.memory_limit = 0 php.ini:suhosin.session.**encrypt = Off php.ini:;suhosin.session.**cryptkey = php.ini:;suhosin.session.**cryptua = On php.ini:;suhosin.session.**cryptdocroot = On php.ini:;suhosin.session.**cryptraddr = 0 php.ini:; session. The difference to suhosin.session.cryptaddr is, that the IP is not php.ini:;suhosin.session.**checkraddr = 0 php.ini:;suhosin.cookie.**encrypt = 0 php.ini:;suhosin.cookie.**cryptkey = php.ini:;suhosin.cookie.**cryptua = On php.ini:;suhosin.cookie.**cryptdocroot = On php.ini:;suhosin.cookie.**cryptraddr = 0 php.ini:; cookie. The difference to suhosin.cookie.cryptaddr is, that the IP is not php.ini:;suhosin.cookie.**checkraddr = 0 php.ini:;suhosin.cookie.**cryptlist = php.ini:;suhosin.cookie.**plainlist = php.ini:; Defines the reaction of Suhosin on a filter violation. php.ini:;suhosin.filter.action = php.ini:;suhosin.cookie.max_**array_depth = 50 php.ini:;suhosin.cookie.max_**array_index_length = 64 php.ini:;suhosin.cookie.max_**name_length = 64 php.ini:;suhosin.cookie.max_**totalname_length = 256 php.ini:;suhosin.cookie.max_**value_length = 1 php.ini:;suhosin.cookie.max_**vars = 100 php.ini:;suhosin.cookie.**disallow_nul = 1 php.ini:;suhosin.get.max_**array_depth = 50 php.ini:;suhosin.get.max_**array_index_length = 64 php.ini:;suhosin.get.max_name_**length = 64 php.ini:;suhosin.get.max_**totalname_length = 256 php.ini:;suhosin.get.max_**value_length = 512 php.ini:;suhosin.get.max_vars = 100 php.ini:;suhosin.get.disallow_**nul = 1 php.ini:;suhosin.post.max_**array_depth = 50 php.ini:;suhosin.post.max_**array_index_length = 64 php.ini:;suhosin.post.max_**name_length = 64 php.ini:;suhosin.post.max_**totalname_length = 256 php.ini:suhosin.post.max_**value_length = 2048000 php.ini:suhosin.post.max_vars = 500 php.ini:;suhosin.post.**disallow_nul = 1 php.ini:;suhosin.request.max_**array_depth = 50 php.ini:;suhosin.request.max_**array_index_length = 64 php.ini:;suhosin.request.max_**totalname_length = 256 php.ini:suhosin.request.max_**value_length = 2048000 php.ini:;suhosin.request.max_**vars = 200 php.ini:;suhosin.request.max_**varname_length = 64 php.ini:;suhosin.request.**disallow_nul = 1 php.ini:;suhosin.upload.max_**uploads = 25 php.ini:;suhosin.upload.**disallow_elf = 1 php.ini:;suhosin.upload.**disallow_binary = 0 php.ini:;suhosin.upload.**remove_binary = 0 php.ini:;suhosin.upload.**verification_script = php.ini:;suhosin.session.max_**id_length = 128 php.ini:; Undocumented: Controls if suhosin coredumps when the optional suhosin
[PHP] Commands which call exec() or shell_exec() ??
Hi -- - Strange problem. One of my applications was just moved to a new server. The new server has php configured to blacklist some functions (using disable_functions=). One of the banned functions is exec(). The error log is reporting shell_exec() has been disabled for security reasons --- but exec() or shell_exec() are not in my code *anywhere*. The program and line number being reported makes absolutely no sense. Are there other php commands that really call exec() or shell_exec() ??? Any clues how this could happen? Fixes (other than un-blacklisting the command, of course)? Many thanks, Ken
Re: [PHP] Commands which call exec() or shell_exec() ??
Thanks, Daniel - -- I do use passthru() -- in an entirely different part of the application (a place where it runs a mysqldump to do a manual backup). Of course, I have millions of backticks delimiting SQL fields and tables. The error log is reporting specifically shell_exec(). Would a stray backtick call that error? On Tue, Apr 9, 2013 at 2:39 PM, Daniel Brown danbr...@php.net wrote: On Tue, Apr 9, 2013 at 3:11 PM, Ken Kixmoeller phph...@comcast.net wrote: Hi -- - Strange problem. One of my applications was just moved to a new server. The new server has php configured to blacklist some functions (using disable_functions=). One of the banned functions is exec(). The error log is reporting shell_exec() has been disabled for security reasons --- but exec() or shell_exec() are not in my code *anywhere*. The program and line number being reported makes absolutely no sense. Are there other php commands that really call exec() or shell_exec() ??? Any clues how this could happen? Fixes (other than un-blacklisting the command, of course)? Many thanks, Ken If you're positive you aren't executing any command line code (backticks, passthru(), et cetera), then check to see if arbitrary code is somehow being attempted via your scripts. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/
Re: [PHP] Commands which call exec() or shell_exec() ??
Yes -- Thanks Matjen and Daniel --- There *was* a stray backtick in there. Weird that we haven't run into it before. Testing now. On Tue, Apr 9, 2013 at 2:41 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Apr 9, 2013 at 9:11 PM, Ken Kixmoeller phph...@comcast.netwrote: Hi -- - Strange problem. One of my applications was just moved to a new server. The new server has php configured to blacklist some functions (using disable_functions=). One of the banned functions is exec(). The error log is reporting shell_exec() has been disabled for security reasons --- but exec() or shell_exec() are not in my code *anywhere*. The program and line number being reported makes absolutely no sense. Are there other php commands that really call exec() or shell_exec() ??? Any clues how this could happen? Fixes (other than un-blacklisting the command, of course)? Many thanks, Ken The back tick(`) operator is also used for that same purpose. Maybe that's in your code? - Matijn
Re: [PHP] Commands which call exec() or shell_exec() ??
Yes --- it worked. Thank you so very much. I had searched the heck out of this to no avail. This is why I think developer communities are so great -- always someone smarter than me (not that it is a high bar s) and willing to help. On Tue, Apr 9, 2013 at 3:05 PM, Ken Kixmoeller phph...@comcast.net wrote: Yes -- Thanks Matjen and Daniel --- There *was* a stray backtick in there. Weird that we haven't run into it before. Testing now. On Tue, Apr 9, 2013 at 2:41 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Apr 9, 2013 at 9:11 PM, Ken Kixmoeller phph...@comcast.netwrote: Hi -- - Strange problem. One of my applications was just moved to a new server. The new server has php configured to blacklist some functions (using disable_functions=). One of the banned functions is exec(). The error log is reporting shell_exec() has been disabled for security reasons --- but exec() or shell_exec() are not in my code *anywhere*. The program and line number being reported makes absolutely no sense. Are there other php commands that really call exec() or shell_exec() ??? Any clues how this could happen? Fixes (other than un-blacklisting the command, of course)? Many thanks, Ken The back tick(`) operator is also used for that same purpose. Maybe that's in your code? - Matijn
Re: [PHP] Commands which call exec() or shell_exec() ??
Yes, but no further need. Problem solved. On Tue, Apr 9, 2013 at 4:06 PM, El Ale... alexissauc...@gmail.com wrote: you probe command system()? 2013/4/9 Ken Kixmoeller phph...@comcast.net Yes --- it worked. Thank you so very much. I had searched the heck out of this to no avail. This is why I think developer communities are so great -- always someone smarter than me (not that it is a high bar s) and willing to help. On Tue, Apr 9, 2013 at 3:05 PM, Ken Kixmoeller phph...@comcast.net wrote: Yes -- Thanks Matjen and Daniel --- There *was* a stray backtick in there. Weird that we haven't run into it before. Testing now. On Tue, Apr 9, 2013 at 2:41 PM, Matijn Woudt tijn...@gmail.com wrote: On Tue, Apr 9, 2013 at 9:11 PM, Ken Kixmoeller phph...@comcast.net wrote: Hi -- - Strange problem. One of my applications was just moved to a new server. The new server has php configured to blacklist some functions (using disable_functions=). One of the banned functions is exec(). The error log is reporting shell_exec() has been disabled for security reasons --- but exec() or shell_exec() are not in my code *anywhere*. The program and line number being reported makes absolutely no sense. Are there other php commands that really call exec() or shell_exec() ??? Any clues how this could happen? Fixes (other than un-blacklisting the command, of course)? Many thanks, Ken The back tick(`) operator is also used for that same purpose. Maybe that's in your code? - Matijn
Re: [PHP] significance of escape character in string in PHP
On 18.03.2013 09:10, Norah Jones wrote: I am having an string which was have few ' (single quote) and few (double quotes) and was not able to insert into the mysql database. I have replaced them with \' and \ and everything is fine. Though this are fine now but don't understand the working and I could have missed few corner cases also. Please suggest the working and also if there is some better way to achieve this. You should be using either mysql_real_escape_string or mysqli_real_escape_string (preferably the later) depending on how you're accessing the DB. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Configuration Issue (Error 310 ERR_TOO_MANY_REDIRECTS)
Hey, folks - One of my applications is being moved to a new server. Testing it out, I get the subject error. The error is reported this way in Chrome. In FireFox it says: Firefox has detected that the server is redirecting the request for this address in a way that will never complete. I suspect this is a PHP or Apache configuration issue, as neither the current test server, production server, nor my development server throw that error. I have searched for 2 days trying to find references for this. I see a lot of PHP-driven applications having the same problem (mostly blogs), but no under the hood fixes. Anyone experienced this? Ideas? Many thanks, Ken
Re: [PHP] date problem
At 04:57 PM 1/3/2013, Marc Fromm wrote: I am comparing to dates. define('WSOFFBEGIN','09/16/2012'); $jes = 01/03/2012; if ( date(m/d/Y, strtotime($jes)) date(m/d/Y, strtotime(WSOFFBEGIN)) ) { $error = MUST begin after . WSOFFBEGIN . \n; } I cannot figure out why the $error is being assigned inside the if statement, since the statement should be false. 01/03/2012 is not less than 09/16/2012. You shouldn't be comparing the date strings, but the UNIX timestamp values: define('WSOFFBEGIN','09/16/2012'); $jes = 01/03/2012; if ( strtotime($jes) strtotime(WSOFFBEGIN) ) { $error = MUST begin after . WSOFFBEGIN . \n; } Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Serial Comm problem
I'm pretty much a php newbie but have been programming for years in other languages Anyway... Using /dev/ttyS0. I need to set the serial port to 9600, send one command to an embedded processor board, then change the baud rate to 57600 and wait for a response. My code is working up to (and including) sending the command (and is being received correctly and acted on by the other device) but hangs up while waiting for the device to ACK back. - //set ttyS0 speed to 9600 to send command exec('stty -F /dev/ttyS0 9600'); // first open comport if it exists $fp = fopen (/dev/ttyS0, w+); if (!$fp) { die( Uh-oh. Port not opened.); } else { } //send command $fw = fwrite($fp, 1*21\r\n); //set ttyS0 speed to 57600 to for bootloader exec('stty -F /dev/ttyS0 57600'); // wait for bootloader to send ^ (does not send CR or LF) echo Waiting for Bootloader Active Character.\n ; // **Were good to here* Do { $InData = fgets($fp,1); } While ($InData != ^) ; - I have also tried both While ($InData !==^) ; and While ($InData ^) ; for the last line but it always hangs in this loop and times out after 30 seconds The ^ is sent by the remove device with \r\n so I assumed telling fgets to look for one character should be enough but apparently it isn't. Any help would be greatly appreciated Ken
Re: [PHP] Serial Comm problem
At 11:36 AM 12/25/2012, you wrote: The ^ is sent by the remove device with \r\n so I assumed telling fgets to look for one character should be enough but apparently it isn't. ---Sorry but the above is wrong. The ^ is sent by the remove device WITHOUT \r\n Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Nested loopa
So I cannot do nested do loops in php? ?php $a = 0 ; $b = 0 ; do { echo $a\n ; do { echo $b\n ; $b++ }while($b =10) ; $a++; }while($a = 20) ; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Strange string stuff -- maybe everything is ending...
A much easier way to do this would be to use a temporary array and then explode: $tmp = array(); while($row = mysql_fetch_array($result)) // pulling stuff from a database { $tmp[] = $row['category']; } $topic = explode('~',$tmp); // put the delimiter between each entry echo($topic); // this result is used in an AJAX script No more worrying about whether the delimiter is the last character. Ken At 04:38 PM 12/21/2012, Tedd Sperling wrote: Hi gang; I just ran into something I have never had a problem with before. Here's the code: --- start of code $topic = ''; while($row = mysql_fetch_array($result)) // pulling stuff from a database { $topic .= $row['category'] . '~'; // adding a delimiter between categories } $str_length = strlen($topic); if($topic[$str_length-1] == '~') { $topic[$str_length-1] = ''; // remove last ~ delimiter } echo($topic); // this result is used in an AJAX script --- end of code Now, when the result is displayed (i.e., echoed) to Javascript routines running in Safari and FireFox, everything is OK. But when the result is displayed on IE, the end of the string causes problems with the exact same javascript routine as used above. Now, I realize that I have altered the string by removing the last character and I have not shortened the string to reflect that, but I never thought it would cause any problems. Would someone please enlighten me as to why this would work in Safari, FireFox, but not in IE? Cheers, tedd PS: Also, please don't beg the answer by saying It's IE -- what do you expect? _ t...@sperling.com http://sperling.com -- 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
Re: [PHP] Strange string stuff -- maybe everything is ending...
Can you post the javascript that's causing the problem? And, yes, it's IE, what did you expect... :-) Ken At 05:10 PM 12/21/2012, Tedd Sperling wrote: On Dec 21, 2012, at 5:05 PM, Ken Robinson kenrb...@rbnsn.com wrote A much easier way to do this would be to use a temporary array and then explode: $tmp = array(); while($row = mysql_fetch_array($result)) // pulling stuff from a database { $tmp[] = $row['category']; } $topic = explode('~',$tmp); // put the delimiter between each entry echo($topic); // this result is used in an AJAX script No more worrying about whether the delimiter is the last character. Ken Ken: Slick -- I like it. But, the question remains -- if you make the last character in a string a '' (or null), then what's the problem with doing that? Cheers, tedd _ t...@sperling.com http://sperling.com -- 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
Re: [PHP] re:Switch - Case Statement Questions
At 07:10 AM 11/16/2012, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instead always I get the first case. 1.Using nested if statement {THE INTENDED BEHAVIOR}: if ($count 14) $boxes = 3; elseif($count 7 $count = 14) $boxes = 2; else $boxes = 1; 2. Using Switch {ALWAYS FIRST CASE!!!} //$boxes = 1; //switch ($count) { //case ($count 14): //$boxes = 3; //break; //case ($count 7 $count = 14): //$boxes = 2; //break; //case ($count = 7): //default : //$boxes = 1; //break; //} For the switch statement to work, you need to use switch (true) $boxes = 1; switch (true) { case ($count 14): $boxes = 3; break; case ($count 7 $count = 14): $boxes = 2; break; case ($count = 7): default : $boxes = 1; break; } BTW, you don't need the break statement at the end of the last case and you don't really need the case ($count = 7) since that condition is what remains anyway. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php can't insert data mysql table
At 12:32 AM 10/1/2012, Tim Dunphy wrote: Hello list, I'm trying to learn and get comfortable with HTML forms in PHP. In one example I am trying to include a file upload in one of the forms. I can connect to the database but for some reason the MySQL query string is bad. I've been over this for a while now and I think the problem is with the form. I was hoping to get the esteemed opinion of the list in where I may be going wrong. This code: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head meta http-equiv=Content-Type content=text/html; charset=utf-8 / titleGuitar Wars - Add Your High Score/title link rel=stylesheet type=text/css href=style.css / /head body h2Guitar Wars - Add Your High Score/h2 ?php if (isset($_POST['submit'])) { // Grab the score data from the POST $name = $_POST['name']; $score = $_POST['score']; $screenshot = $_FILES['screenshot']['name']; if (!empty($name) !empty($score)) { // Connect to the database $dbc = mysqli_connect('localhost', 'xxx', 'xxx', 'gwdb') or die('Cannot connect to database'); // Write the data to the database $query = INSERT INTO guitarwars VALUES (0, NOW(), '$name', '$score', '$screenshot'); mysqli_query($dbc, $query) or die('Cannot insert query'); // Confirm success with the user echo 'pThanks for adding your new high score!/p'; echo 'pstrongName:/strong ' . $name . 'br /'; echo 'strongScore:/strong ' . $score . '/p'; echo 'pa href=index.phplt;lt; Back to high scores/a/p'; // Clear the score data to clear the form $name = ; $score = ; mysqli_close($dbc); } else { echo 'p class=errorPlease enter all of the information to add your high score./p'; } } ? [snip] First -- NEVER post code with your database username/password. Since you did, change your db password immediately. Second, when debugging, if you use the die() function, put out something meaningful like ... or die(Problem with the insert query: $querybr . mysqli($dbc)); Once you see the database error, you will probably be able to figure out the problem. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array unset()
At 08:50 PM 9/23/2012, Ron Piggott wrote: I am wondering if there is a way to remove from an array where the value is 0 (âzeroâ) Array example: $total_points_awarded = array( 1 = 17, 3 = 14, 4 = 0, 5 = 1, 6 = 0 ); In this example I would like to remove element # 4 and # 6. The âkeyâ ( 1,3,4,5,6 ) represents the memberâs account #. It is an auto_increment value in a mySQL table The âvalueâ ( 17,14,0,1,0 ) represents their score. The application for this is a list of the top users. If someone has 0 points I donât want to include them. Any thoughts? Any help is appreciated. Look at array_filter() ... http://php.net/array_filter ?php $total_points_awarded = array( 1 = 17, 3 = 14, 4 = 0, 5 = 1, 6 = 0 ); print_r(array_filter($total_points_awarded)); Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Find/count different word in a text
At 12:59 PM 4/25/2012, Karl-Arne Gjersøyen wrote: Hello again. I am looking for a way to find and count different word in a text.. I am thinking on save the text as array and iterate through the array. Then I like to register all different words in the text. For example. If bread is used more than one time, I will not count it. After the check were I have found single (one) word of every words, I count it and tell how many different word that is in the text. Is this difficult to do? Can you give me a hint for were I shall look on www.php.net for a solution to fix this problem? What function am I in need of? I would use a combination of the functions str_word_count and array_count_values. ?php $str = This is a test of word counting and this sentence repeats words a a a a a is is is is; print_r(array_count_values(str_word_count($str, 1))); ? Ken Robinson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] http_referer. what's wrong with that?
At 12:27 AM 1/12/2012, Haluk Karamete wrote: Because I got this echo $_SERVER['HTTP_REFERER']; I end up with this Notice: Undefined index: HTTP_REFERER in D:\Hosting\5291100\html\blueprint\bp_library.php on line 16 die; Now, this is of course after the ?php error_reporting (E_ALL); ? change. One solution is to dodge it by echo @$_SERVER['HTTP_REFERER']; The better way to avoid the error is to do something like echo (isset($_SERVER['HTTP_REFERER']))?$_SERVER['HTTP_REFERER']:'No referrer set'; Which checks to see if it's set before echoing the value. If it's not set, you get a message saying so. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] number_format
Quoting Floyd Resler fres...@adex-intl.com: In the previous version of PHP we were using, I could pass a string to number_format and it would just change it to a 0 without complaint. With 5.3.6 I get an expects double error. I don't suppose there's a way to make it work like it used to??? I'm dealing with really old code that wasn't very well structured. The way I would get around this would be to create a function like this: function my_number_format($number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') { $number += 0; //convert value to a number. return number_format($number, $decimals, $dec_point, $thousands_sep); } The just do a global replace of number_format with my_number_format. That should work, although I haven't tested it... Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FW: parse error
At 01:26 PM 10/13/2011, Robert Williams wrote: On 10/13/11 10:06, David Savage dsav...@cytelcom.com wrote: php -l voip_cdrs.php PHP Parse error: parse error, unexpected T_STRING in /usr/local/cytrex/voip_cdrs.php on line 1050 Errors parsing voip_cdrs.php $alias_sql_stmt=SELECT ani FROM ldrates WHERE ani='$termnum10';// -this is line 1050 Could you please tell me what's wrong with the line 1050 ? I've been pulling my hair out (figuratively speaking) trying to understand why the compiler sees this line as a problem. Thanks for whatever help you can give. My suspicion is that there's is an unmatched curly brace earlier in the file. With this type of error, you'll generally get a report of a bad line further down the file--sometimes way down--because the parser can't recognize until it hits the later point that something is wrong. Try double-checking that the {} blocks prior to line 1050 properly balance, and you'll probably find there's an extra one, or that one is missing, etc. It's more likely an unterminated quoted string. It looks like PHP is giving up after finding unrecognizable stuff after either the first double or single quote on that line. If you're using an editor that doesn't do syntax high lighting, get one. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] FW: parse error
At 02:06 PM 10/13/2011, Steve Staples wrote : [snip] It's more likely an unterminated quoted string. It looks like PHP is giving up after finding unrecognizable stuff after either the first double or single quote on that line. If you're using an editor that doesn't do syntax high lighting, get one. Ken I would suggest that you figure out what is the value of the variable your passing into your query is it possible that the value is getting a ' character, in which case it would be crapping out the line... That would only occur when the script is actually executed. It's not getting that far yet, since it's dying on a syntax error during the parse. For now, try adding [addslashes]: $termnum10=addslashes(substr($dest, $start_from_which_offset,10)); $alias_sql_stmt=SELECT ani FROM ldrates WHERE ani='$termnum10';// -this is line 1050 No, mysql_real_escape_string (http://php.net/mysql_real_escape_string) should be used, not addslashes, although there are some people who have suggested that even that function is not enough and that only using stored procedures is good enough. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Local variable protection
Quoting Benjamin Coddington bcodd...@uvm.edu: Are there any assurances that function local variables are protected from code calling the function? For example, I would like to provide some cryptographic functions such as function org_secure_string($string) { $org_key = a very random key; return hash($string, $key); } function org_reveal_string($hash) { $org_key = a very random key; return unhash($hash, $key); } I'd like to protect $org_key from any code following or using these functions. I've not yet found a way that it can be revealed, but I wonder if anyone here can give me a definitive answer whether or not it is possible. It's called the scope of the variable. See http://us3.php.net/manual/en/language.variables.scope.php Variables defined in a function are only available to the function where they are defined. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help on number matching function
At 08:36 AM 9/16/2011, Dare Williams wrote: Dear PHP Group, I need a Function of any category in either PHP or MySQL RDBMS customize Function, Class, Methods or anything that could help me compare a particular set of number and return their matching result. e.g If I have a 5 Digits set of number and need to match it with another set of five digits and return how many number are match and the figures that are match. 1.(62,39,47,25,14) - (14,39,62,25,47) - match 5 (all) 2.(55,11,27,62,39) - (66,39,12,13,27) - match 2 (27,39) 3.(20,04,56,17,16) - (16,01,17,04,79) - match 3 (16,17,04) Any Help will be appreciated. Thank you. Turn your sets of number into an array and then use the function array_intersect, http://php.net/array_intersect Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] scroll down list -visible, but not possible to choose
You want: if($status == $selected) echo selected = ' selected' ; (I didn't bother with \s) And BTW, unless the support person is actually sitting on top of the customer (and I can see situations where that would help), you want it to say Waiting *for* Customer Ken On Wed, Aug 31, 2011 at 3:30 AM, rob...@myself.com wrote: echo option value=\$status\; if($status == $selected) echo ' selected'; echo $status/option; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP within XML?
Quoting Ron Piggott ron.pigg...@actsministries.org: I am trying to figure out if it is possible to have PHP work within an XML document. The application is tracking RSS subscribers IP addresses within the database. I have wrote functions so the PHP code required is below is minimal, after the XML declaration line. Prior to posting this question I tried to have the PHP at the very start, but that doesn’t work, the declaration line needs to be first. Right now the PHP is displayed as a comment. In order for your PHP code to be processed the file should be named with a .php extension. Since you're writing XML code, you need to send an XML header type first: ?php header (Content-Type:text/xml); #load RSS XML function require_once(rss_subscribers_xml.php); $ip_address = _ip; rss_subscriber_update($ip_address); echo '?xml version=1.0 encoding=utf-8?' . \n; ? Rest of your XML content. This should work. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] form handling
At 02:25 PM 8/11/2011, Chris Stinemetz wrote: I have two forms on the same php script. Is it possible to submit both forms to the same action=processform.php with a single submit button? If you want to submit at the same time, why do you have two forms? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem with inserting numbers...
At 09:22 PM 8/10/2011, Jason Pruim wrote: So here I am attempting to generate some numbers to be inserted into a database... eventually they will make up a phone number (Which I've emailed about before and know about the bad ideas with it.. But it's the customer :)) Here is the code I am working with: ?PHP function number_pad($number,$n) { return str_pad((int) $number,$n,0,STR_PAD_LEFT); } $SQL = SELECT * FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $result = mysql_query($SQL); while ($num != 1) { while($row = mysql_fetch_assoc($result)) { $padnum = number_pad($num, 4); echo $row['areacode'] . - . $row['prefix'] . - . $padnum . BR; $num++; } } ? Try to avoid putting a database query in a loop. In the query only ask for the fields you are going to use, it's faster. Why use your own function to pad a string, when there is a built-in function? Try this code (untested): ?php $nums = range(0,); $q = SELECT areacode, prefix FROM Test WHERE `areacode` = '907' AND `prefix` = '200' LIMIT 5; $rs = mysql_query($q); while ($row = mysql_fetch_assoc($rs)) { foreach ($nums as $n) { echo sprintf('%03d-%03d-%04d',$row['areacode'],$row['prefix'],$n) br\n; } } ? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] concatenating
At 12:03 AM 8/11/2011, Chris Stinemetz wrote: Is it possible to concatenate a string and an element from a mysql_fetch_assoc array? I haven't had much luck searching google. Such as concatenating results with ' . $posts_row['store_tptest'] . ' so that if there are no elements returned nothing will be displayed? Sure, do something like this: ?php echo ($posts_row['store_tptest'] != '')?results {$posts_row['stor_tptest']}:''; ? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Serveside Printing w/ PHP
At 02:06 PM 7/12/2011, Marc Guay wrote: Bonus feature: The server is running Windows 7. I suspect the crickets are going to win this one. Take a look at http://www.php.net/printer -- this might be what you're looking for. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Found this and I thought of you.
On Sun, Jun 5, 2011 at 11:44 AM, Jonesy gm...@jonz.net wrote: On Sun, 5 Jun 2011 00:34:30 +0100, Richard Quadling wrote: http://www.exxcire.com/login.php If nothing more than a good bad example. ROTFLMAO!!! Where Experts Exchange Sweet Jeezuz! At least they have a cute 404 page. Gotta count for *something*! g Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] iPhone sadness
On Mon, May 30, 2011 at 11:19 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Erm,... Most people who use Windows tend not to change basic settings from their defaults. Erm, most Winders users have no clue *how* to change them, nor that there might be some reason to do so. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] observer pattern
Lo, so, I'm wondering - how many of you use the observer pattern in php; and if so, do you implement it 'standalone' or with the spl classes? Is there any particular advantage to doing it your way; whichever your way is? Ken -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing a simple sql string in php
On Fri, May 6, 2011 at 10:05 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: Hiya, has anyone had any experience with parsing a string of sql to break it down into its component parts? At the moment I'm using several regex's to parse a string, which works, but I'm sure there's a more elegant solution. The general idea is to produce a nice looking page giving details of updated fields and values. I'm only concerned with update statements really, and the queries are very simple, operating on one table at a time, with no sub queries or selects. Thanks in advance if anyone is able to suggest anything! I'd suggest at least taking a look at pear's sql parser package - using it might save you some headaches ;) http://pear.php.net/package/SQL_Parser Thanks Ash -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Installing on a Mac: include_path issues
On Thu, May 5, 2011 at 4:40 AM, Richard Quadling rquadl...@gmail.com wrote: On 5 May 2011 05:51, David Robley robl...@aapt.net.au wrote: Ken Kixmoeller wrote: include_path should only contain directories, not filenames. [1] Thanks. Yes, both of those are directories. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Installing on a Mac: include_path issues
On Wed, May 4, 2011 at 11:51 PM, David Robley robl...@aapt.net.au wrote: php.ini shows the include_path correctly, as: If I remember correctly, include and friends have two parts to the error message but you've only shown us one. For a guess, is it possible the apache process doesn't have permissions for those directories and/or the files within them? Yes, it ia two-parter. I showed the second. The first is: Warning: include_once(smm_header.php) [function.include-once]: failed to open stream: No such file or directory in /Users/ken/Sites/smm_registration/smmcomputereducation.php on line 1 I am checking out the rights issue --- sounds like a great lead. Thank you. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Installing on a Mac: include_path issues
On Thu, May 5, 2011 at 5:59 AM, Mike Mackintosh mike.mackint...@angrystatic.com wrote: Run phpinfo() or php -I and see if the PHP.ini file is being loaded. php.ini shows the include_path correctly, as: /Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php Oops, that line was supposed to say phpinfo() shows the include_path correctly. Sorry for the confusion. phpinfo() runs just fine and shows me what I expected. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: iPhone apology - was Re: [PHP] Re: Installing on a Mac: include_path issues
On Thu, May 5, 2011 at 9:52 AM, Richard Quadling rquadl...@gmail.com wrote: On 5 May 2011 15:08, Mike Mackintosh mike.mackint...@angrystatic.com wrote: Sent from my iPhone Why do all iPhone users apologize for sending mail from their iPhone? 1. Apparently, iphone software top-posts replies. For some people, that alone constitutes a federal (if not intergalactic) crime. 2. This signature addition seems to have started with the Blackberry. Some people got upset with concise replies (like fine) thinking them to be snippy, when they were due to limited typing capabilities. 3. Advertising for Apple. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Installing on a Mac: include_path issues
On Thu, May 5, 2011 at 9:08 AM, Mike Mackintosh mike.mackint...@angrystatic.com wrote: What are the permissions on the include directory? -- Well, I swear that I had set the permissions to r/w for these directories, but after I did it (again?), now I get a whole *new* set of errors which seem to be about connecting to MySQL. So, pending further investigation, it seems like *this* problem is solved. Many, many thanks to all who responded. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Installing on a Mac: include_path issues
Hey, folks -- -- I am switching over my development (I hope) to a Mac. Having some trouble with the configuration. Rudimentary scripts run fine in the document_root, but beyond that, my scripts in the include_path are not found. The include_path has a couple of directories in which I have my foundation classes and a clients application classes and other programs. For various reasons, I put them into my Documents/Clients folder. When I create to set the path to these files in PHP, they are: /Users/ken/Documents/Clients/comped_php /Users/ken/Documents/Clients/jaguar_php PHP doesn't find them, which has me stumped. php.ini shows the include_path correctly, as: /Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php the document_root, configured in Apache is: /Users/ken/Sites/ The errors show as: include_once() [function.include]: Failed opening 'smm_header.php' for inclusion (include_path='/Users/ken/Documents/Clients/comped_php:/Users/ken/Documents/Clients/jaguar_php') in /Users/ken/Sites/smm_registration/smmcomputereducation.php on line 1 Any ideas or suggestions? Thanks, Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session variable problem
At 01:09 PM 3/25/2011, markb wrote: Very rusty with PHP. We moved our web site to a new hosting service (godaddy). PHP changed from 4x to 5.2.17. I can no longer change $_SESSION variables after the first use. First call to form - start session create variables Second call - can read variables, change existing ones (but they do not persist to next call) - cannot create new variable without an error What's the error you're getting? Also, do you have a call to session_start() at the beginning of each script before any output is sent to the browser? Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] looking for a newsgroup for JS
At 04:20 PM 3/23/2011, Jim Giner wrote: Anyone know of a working Javascript newsgroup? I googled and tried adding several to my OE newsgroups but couldn't find the servers. I frequent an on-line PHP forum at phpfreaks.com. There is a Javascript section there that seems to be quite active: http://www.phpfreaks.com/forums/index.php?board=6.0 Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning a recordset to a desktop app
On 3/7/2011 7:19 AM, Richard Quadling wrote: On 5 March 2011 13:48, Ken Watkins k...@atlanticbb.net wrote: On 3/5/2011 4:30 AM, Richard Quadling wrote: On 4 March 2011 23:48, Ken Watkins k...@atlanticbb.net wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins In general terms, the output of a PHP script is going to be text (html, xml, csv, etc.) or binary (images). Getting a PHP script to communicate natively with FoxPro is not going to be trivial task. It MAY be able to be done, but hopefully FoxPro has the capability of running a PHP script via the command line ... C:\PHP5\php.exe -f script.php -- script_arg1 script_arg2 PHP can either output the result set (in an appropriate form) directly and FoxPro could read it from STDIN (if it has that support) or PHP can write the answer to a file and FoxPro can use normal file and string functions to read the data. If FoxPro has XML support, then use it. It will be much cleaner in the long run if the data changes. If not, then a tab separated data file (rather than a CSV file). This assumes that your data does not contain tabs. If so, choose another separator. Richard. Richard, Foxpro does have XML support, so you answered that part of my question, thanks. And it is capable of calling any other executable on the local machine through the local OS shell - which seems to be what you are advocating. But I'm not sure how I would do that over the internet. I just discussed this issue with Larry, and I assume that I would use HTTP? Or is there a way to call a command line script on a remote web server without using HTTP? Sorry if this is a stupid question. Thanks for your help! Ken So, what you need to have is an HTTP Request from within FoxPro. http://www.example-code.com/foxpro/http_post_form.asp gives an example, but it seems to use a third party ActiveX component. If FoxPro can load any locally resident/installed ActiveX component, then maybe ... http://fox.wikis.com/wc.dll?Wiki~ReadUrl has better examples. So, using something from that to get the data (XML) and then using FoxPro's native support for XML and you should be on your way. But at this stage, I'd be looking to ask for further help in a FoxPro forum as this is really nothing to do with PHP. Good luck. Richard. Richard, Thanks for your comments. I ended up taking the simple approach - I installed an ODBC driver for MySQL and let Foxpro query the database directly from a remote workstation. I suppose that what I wanted to do originally was to introduce PHP into the mix just to have another option, and to gain more experience in PHP. Probably not a good idea anyway. Thanks again for the help. Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning a recordset to a desktop app
Larry, Yes, the PHP script will reside on my web server along with the MySQL database. I assumed that I would call the script over HTTP, but I guess that is part of my question too. Foxpro allows you to embed controls in its forms, and one of them is a browser control. But I don't really want to echo anything to the enduser, I just want to capture the data behind the scenes, so to speak. I think I can handle that with the browser control. If I understand you correctly, when I do an echo statement or a print statement (or a return()?), it will return the data to the desktop app. And the best way to return it is in xml. I'll investigate the methods you mention for converting xml since I'm not familiar with any of them. Thanks! Ken On 3/4/2011 6:51 PM, la...@garfieldtech.com wrote: Assuming you mean that the PHP script is on a web server somewhere and the desktop app is hitting it over HTTP, it's no different than any other response. Anything you print will be sent back to the client, in this case your desktop a.. So if you want to send XML back, you'd build a string with your XML (either manually or using the DOM or SimpleXML APIs or a 3rd party like QueryPath or whatever floats your boat) and print it, just as you would HTML. Note that you may need to explicitly set headers with header() to make sure the desktop app reads it properly. --Larry Garfield On 3/4/11 5:48 PM, Ken Watkins wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Returning a recordset to a desktop app
On 3/5/2011 4:30 AM, Richard Quadling wrote: On 4 March 2011 23:48, Ken Watkins k...@atlanticbb.net wrote: Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins In general terms, the output of a PHP script is going to be text (html, xml, csv, etc.) or binary (images). Getting a PHP script to communicate natively with FoxPro is not going to be trivial task. It MAY be able to be done, but hopefully FoxPro has the capability of running a PHP script via the command line ... C:\PHP5\php.exe -f script.php -- script_arg1 script_arg2 PHP can either output the result set (in an appropriate form) directly and FoxPro could read it from STDIN (if it has that support) or PHP can write the answer to a file and FoxPro can use normal file and string functions to read the data. If FoxPro has XML support, then use it. It will be much cleaner in the long run if the data changes. If not, then a tab separated data file (rather than a CSV file). This assumes that your data does not contain tabs. If so, choose another separator. Richard. Richard, Foxpro does have XML support, so you answered that part of my question, thanks. And it is capable of calling any other executable on the local machine through the local OS shell - which seems to be what you are advocating. But I'm not sure how I would do that over the internet. I just discussed this issue with Larry, and I assume that I would use HTTP? Or is there a way to call a command line script on a remote web server without using HTTP? Sorry if this is a stupid question. Thanks for your help! Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Returning a recordset to a desktop app
Hi All. I have a Windows desktop app that I created using Visual Foxpro (a database app). I want to write a PHP script that I will call from my desktop app. The script will simply query a MySQL database on my web server and return the recordset to the desktop app. My question is simply this: What is the preferred method for passing this recordset back to the desktop app? I'm assuming that there's no reasonable way to send a recordset back without converting it to an array or XML or an object or something? How do I return the data in the recordset to the desktop app? Thanks for your advice. Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help! Made a boo-boo encrypting credit cards
On Fri, Feb 11, 2011 at 4:42 PM, Brian Dunning br...@briandunning.com wrote: Hey all - I'm using mcrypt to store credit cards into MySQL. About 90% of them decrypt fine, but about 10% decrypt as nonsense (b1�\�JEÚU�A��� is a good example). Maybe there is a character that appears in about 10% of my encryptions that's not being encoded properly??? // Encryption is set up at the top of the script: $crypto = mcrypt_module_open('rijndael-256', '', 'ofb', ''); $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($crypto), MCRYPT_DEV_RANDOM); $ks = mcrypt_enc_get_key_size($crypto); $key = substr(md5('my_funky_term'), 0, $ks); // When the card number is collected by the form, it's encrypted: $cc_number = addslashes($_POST['cc_number']); mcrypt_generic_init($crypto, $key, $iv); $cc_encrypt = mcrypt_generic($crypto, $cc_number); mcrypt_generic_deinit($crypto); // This is written to the database: $query = update accounts set cc_encrypt='$cc_encrypt', encrypt_iv='$iv', other_fields='$other_stuff' where id='$account_id' limit 1; $result = mysql_query($query) or die(mysql_error()); Both the cc_encrypt and encrypt_iv fields are tinytext, latin1_swedish_ci, MyISAM, MySQL 5.0.91 In another script, when I retrieve, I first set it up at the top of the script exactly like step #1 above, then retrieve it like this: mcrypt_generic_init($crypto, $key, $row['encrypt_iv']); $cc_number = trim(mdecrypt_generic($crypto, $row['cc_encrypt'])); mcrypt_generic_deinit($crypto); Most of them are good, a few of them are bad. Can anyone see anything I'm doing wrong or a case I'm not covering? Thanks much. Just a WAG, but when I first was working with mcrypt, it would append spaces to the encrypted value. I would have to TRIM() everything for processing or decryption. BTW, we also elected *not* to store card numbers, only the last 4 digits. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Code formatter
replies inline... On Wed, Feb 2, 2011 at 3:23 PM, Hansen, Mike mike.han...@atmel.com wrote: -Original Message- From: ken.gu...@gmail.com [mailto:ken.gu...@gmail.com] On Behalf Of Ken Guest Sent: Monday, January 31, 2011 3:26 PM To: Hansen, Mike Cc: php-general@lists.php.net Subject: Re: [PHP] Code formatter On Mon, Jan 31, 2011 at 8:27 PM, Hansen, Mike mike.han...@atmel.com wrote: I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Have you found http://pear.php.net/package/PHP_Beautifier yet? ;) http://www.php.net/unsub.php Ken It mostly works ok. Unfortunately, there's a bug in it that removes blank lines. I found this one that seems to work: http://beta.phpformatter.com/ I'd rather have one I can run on the command line, but this will have to do. Just spotted that bug is reported at http://pear.php.net/package/PHP_Beautifier/bugs - it's a shame it's been logged since 2007 or so with no sign of it getting fixed. :( -- http://blogs.linux.ie/kenguest/
Re: [PHP] Code formatter
On Mon, Jan 31, 2011 at 8:27 PM, Hansen, Mike mike.han...@atmel.com wrote: I've got an application that I'm fixing up and I'd like to run it through a code formatter. Is there something like Perl Tidy for PHP? If so, what are you experiences with it. No prob running it on the command line. It'd be great if it followed the PEAR coding standards. Have you found http://pear.php.net/package/PHP_Beautifier yet? ;)http://www.php.net/unsub.php Ken -- http://blogs.linux.ie/kenguest/
Re: [PHP] Centralizled Authentication
On Thu, Dec 2, 2010 at 8:06 AM, AmirBehzad Eslami behzad.esl...@gmail.comwrote: Dear list, We have dozen of applications, mostly written in PHP and Python. They're distributed on different servers, but i'm trying to integrate them somehow. Each application has its own users. Is there a way to store all username/passwords into a single datasource and give each user, her proper permissions? Since i'm just a php-programmer, i *thought* of a MySQL database to hold these data, and then use a SOAP-Server to handle the authentication across those applications. Once a user provides her username/password, a SOAP Request will be made to a PHP-Driven Authentication Server, which handles the job to check the permissions and user's identity. It sounds slow, isn't it? Is there a better solution? How do you make authentication across a network of applications? OAuth comes to mind... -- http://blogs.linux.ie/kenguest/
Re: Re[2]: [PHP] Open Source PHP/ mySQL Project Management
With the exception of some work-mandated systems such as fogbugz, I've used mantis successfully for quite a long time. On Fri, Nov 12, 2010 at 1:09 AM, Andre Polykanine an...@oire.org wrote: Hello Jonathan, I tried to use Mantis, however it didn't send e-mails properly so I gave up. -- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion - Original message - From: Jonathan Tapicer tapi...@gmail.com To: Don Wieland d...@dwdataconcepts.com Date: Friday, November 12, 2010, 3:00:32 AM Subject: [PHP] Open Source PHP/ mySQL Project Management Hi, I don't know if it meets all of the features you enumerated but Mantis (http://www.mantisbt.org/) is very good, and it is PHP+MySQL (or Postgres, or MSSQL). Jonathan On Thu, Nov 11, 2010 at 7:23 PM, Don Wieland d...@dwdataconcepts.com wrote: Hi gang, I am looking into Project Management apps for my projects. Any suggestions: I am interested in tracking Projects, Milestones, Tickets, Files, Discussions, Documents, Time Tracking, etc... Also, would like to have the system have robust email integration Reminders, Email Ticket echos (where a user can reply it will post back into the PM system and echo back email to assigned users - with file attachments) Suggestions? Thanks! Don -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/
Re: [PHP] google maps API
Please consider using the OpenLayers API instead ( http://openlayers.org/ and http://openlayers.org/dev/examples/ for examples) as it will also allow end-users to choose a OpenStreetMap layer ( http://www.openstreetmap.org/ ) to be displayed which may render more up-to-date details than are available elsewhere. Ken On Mon, Aug 23, 2010 at 3:37 AM, David Mehler dave.meh...@gmail.com wrote: Hello, Has anyone worked with the google maps API to put a map on their site? If so, please contact me offlist i need to get it going. Thanks. Dave. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/
Re: [PHP] Unit testing in PHP
On Thu, Jun 17, 2010 at 10:51 AM, vikash.i...@gmail.com wrote: Hi, What do you use for unit testing in PHP? phpUnit, SimpleTest or any other? Ages ago, when it was new and shiny I did use SimpleTest. Now I mostly use phpunit - though where necessary (for example if I'm patching a PEAR package that uses them) I use phpt tests ( http://qa.php.net/write-test.php ). If you're starting out on something [new] that doesn't yet have unit tests, I'd suggest phpunit. hth Ken -- http://blogs.linux.ie/kenguest/
Re: [PHP] What is app.php?ph=cusid=4?
Michael Calkins wrote: How is it used for a website then? Some program is using the ID 4 and the value of cus to bring up information you requested on a prior page. Probably to query a database for those values. As Ashley said: it is GET ($_GET) data in a URL -- a way to pass values from one page to another using the URL. Look up $_GET or Predefined Variables in the PHP documentation online. If that doesn't help, you need to buy the most basic book on web programming you can find (and read it). Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Irish PHP User Group meeting tonight
Hi. Just to let any of ye know that might be interested, there's a php.ie meeting on tonight in Dublin - in the Longstone pub on Townsend Street starting at eight o'clock. It's located where the red diamond is on this map: http://www.openstreetmap.org/?mlat=53.34595mlon=-6.25559zoom=16layers=B000FTF Ken -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Irish PHP User Group meeting tonight
On Wed, Apr 28, 2010 at 3:38 PM, Daniel Brown danbr...@php.net wrote: On Wed, Apr 28, 2010 at 05:47, Ken Guest k...@linux.ie wrote: Hi. Just to let any of ye know that might be interested, there's a php.ie meeting on tonight in Dublin - in the Longstone pub on Townsend Street starting at eight o'clock. It's located where the red diamond is on this map: http://www.openstreetmap.org/?mlat=53.34595mlon=-6.25559zoom=16layers=B000FTF Ken, Do you want me to add that map link to your event listing on the calendar for today on php.net as well? that would be a handy idea ;-) Thanks! Ken -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
The PEAR Mail package does not fall back from one mechanism to another if the first fails. On Tue, Apr 20, 2010 at 9:16 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-04-20 at 22:17 +0200, Peter Lind wrote: On 20 April 2010 20:17, Alice Wei aj...@alumni.iu.edu wrote: From: peter.e.l...@gmail.com Date: Mon, 19 Apr 2010 10:15:08 +0200 Subject: Re: [PHP] Mail Function Using PEAR Issues To: aj...@alumni.iu.edu CC: php-general@lists.php.net Most, if not all, mail servers keep log files. You should look for the log files to see if the mail server has sent your mail properly or is experiencing problems (those may not feed back into PHP). Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 /hype You know where I can find that? I use Evolution Mail, a mail server? I found it through Ubuntu yesterday. Here is the link: http://projects.gnome.org/evolution/ It asks me to put in the type of mail service I used, it grabbed Google, which is smtp.google.com. I still cannot send mail. I start to wonder what is going on. Alice Evolution is a mail client, not a mail server. Apart from that, you're using the 'mail' (PHPs mail function) as the backend mailer in your PEAR script - try using smtp instead and pass the SMTP config data you normally use. Have a look at http://pear.php.net/manual/en/package.mail.mail.factory.php - the smtp part. Regards Peter -- hype WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 /hype If you've got Pear on Ubuntu, can Pear not default to sendmail if no SMTP connection is set up? Thanks, Ash http://www.ashleysheridan.co.uk -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replying to list (I give up)
Daniel Egeberg wrote: Then get a better email client if yours doesn't support reply to all or reply to group. It's hardly the mailing list's fault that your client doesn't support that. Nonsense. I have used lists like this for many, many years. PHP lists are the only ones I have ever used that behave this way. All the others I have used are configured that a simple Reply replies to the list. Sure, you can always Reply All but then you get multiple replies from the same person to the same post. Plus, it is really easy to forget. In my opinion, it is idiotic. OTOH, what is important to me is the quality of the information that comes in from you incredibly generous people. Thank you to all posters. You are the best. The list behavior is just an irritant, but it pales in comparison to the benefit. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
you have to install the net_smtp package, simply with this command: $ pear install net_smtp-1.4.2 (which will explicitly install version 1.4.2 of Net_SMTP) If that doesn't work. for whatever reason, you could download the package manually from http://pear.php.net/package/Net_SMTP/download and install it by hand; though for reasons I've outlined in a previous post to this list I'd suggest you use the pear installer. On Thu, Apr 22, 2010 at 12:12 AM, Alice Wei aj...@alumni.iu.edu wrote: Date: Wed, 21 Apr 2010 22:01:03 +0200 Subject: Re: [PHP] Mail Function Using PEAR Issues To: aj...@alumni.iu.edu CC: a...@ashleysheridan.co.uk; php-general@lists.php.net On 21 April 2010 21:58, Alice Wei aj...@alumni.iu.edu wrote: From: peter.e.l...@gmail.com Date: Wed, 21 Apr 2010 21:51:31 +0200 Subject: Re: [PHP] Mail Function Using PEAR Issues To: aj...@alumni.iu.edu CC: a...@ashleysheridan.co.uk; php-general@lists.php.net On 21 April 2010 18:44, Alice Wei aj...@alumni.iu.edu wrote: I have mentioned several posts earlier that I have done nothing about my php.ini file. From what you said, since I use U-Verse, am I supposed to do something as described here: http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf I thought with PEAR, you don't need to do that anymore. Or, am I wrong? Read the PEAR documentation: http://pear.php.net/manual/en/package.mail.mail.factory.php You can use other backends than just 'mail' - try using the smtp and fill in your smtp settings as needed. Regards Peter I saw something like that on http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm, and this is probably what you are talking about? $smtp = Mail::factory('smtp', array ('host' = $host, 'auth' = true, 'username' = $username, 'password' = $password)); Do I still need to install a mail server? I have Evolution Mail on my Linux box, and looks like that is a client and not a server. Or, can I use any of the mail smtp setup, like Google? Or, do use some authentication information from http://helpme.att.net/pdf/uverse/uverse_hsi_qsg_english.pdf, since I use U-Verse at home? Yes, the example you provide is the right direction - you can put in the smtp details you use to connect from Evolution to GMail, you don't need to setup a separate smtp server on your system. Regards Peter Well, hold it. I have edited my code to hold the information as we have discussed earlier, and this is the error I have now: Warning: include_once(Net/SMTP.php) [function.include-once]: failed to open stream: No such file or directory in /usr/share/php/Mail/smtp.php on line 348 Warning: include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/share/php') in /usr/share/php/Mail/smtp.php on line 348 Fatal error: Class 'Net_SMTP' not found in /usr/share/php/Mail/smtp.php on line 349 I am not sure what this means. If I have installed pear correctly, what else do I have to do here? I can see that I have some significant error messages than not getting anything at all. Thanks for your help. Alice _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_1 -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mail Function Using PEAR Issues
On Tue, Apr 20, 2010 at 2:10 AM, David McGlone da...@dmcentral.net wrote: On Mon, 2010-04-19 at 08:25 -0400, Alice Wei wrote: I have not changed any of my SMTP settings since my new installation of PHP with Pear. So, I am not sure what the settings are supposed to be. Would I need to install anything else even when the Pear Mail package has been installed? You might, depending on if you need to use the Mail_Mime or Mail_Queue packages also (for sending emails with attachments etc etc or for sending mails in bulk). Also there's some rather nice new functionality in the more recent versions of Mail and Net_SMTP that enable you to log the ESMTP Id of mails you have submitted to a mail server (along with the SMTP greeting sent by that server when you connect to it). Alice, I never use the PEAR install from my distro, I always download and install PEAR into my working folder. The benefit of doing it this way is so that when you move your project to a different server, nothing will break and you don't have to change anything. Sometimes when I create a new project, I'll just copy the PEAR folder from an older project to the new one. The only thing you may have to change in your PHP code is the path to the PEAR libs only if you don't put them in the same place every time. When some bug is fixed or dependencies of some of those PEAR packages change I think you'll find your attitude towards that will change - there's a pear installer so you don't have to update and track the dependencies by hand - you do regularly update your packages don't you? It's smart to do so because at the very least you don't have to implement work-arounds for bugs that have been fixed in later versions of those packages - and in the worst-case scenario it means you're not using versions that have PEAR Security Advisories issued against them. I believe it's possible to have seperate pear config files per project so you're not limited to having to use the same versions of packages across all projects. If you're using more than a handful of PEAR packages in your project you might want to write your own meta-package for the project; that way you don't have to install all those packages individually; you just do something like $pear install myProject.xml and the pear installer will download and install whichever pear packages you have described in your xml file. Details on doing this are at http://pear.php.net/manual/en/guide.users.dependencytracking.php For the record, this is the example script that I submitted to http://www.web-development-blog.com/archives/php-mail-scripts-using-smtp-transport-a-guide-for-beginners/ for demonstrating how to use the PEAR packages for sending a mail with a file attached.: ?php require_once Mail.php; require_once Mail/mime.php; $from = Fred Flintstone fli...@example.com“; $to = “Barney Rubble barn...@example.net“; $subject = “Mail Subject”; $message = “this is the text of the mail, sent using PEAR’s Mail packages.”; $host = “smtp.example.com”; $port = “25″; $headers = array (‘From’ = $from, ‘To’ = $to, ‘Subject’ = $subject); $smtp = Mail::factory(’smtp’, array (‘host’ = $host, ‘port’ = $port)); $mime = new Mail_mime(); $mime-setTxtBody($message); $mime-addAttachment(“/home/ken/logo.png”, ‘image/png’); $body = $mime-get(); $mail = $smtp-send($to, $mime-headers($headers), $body); if (PEAR::isError($mail)) { echo($mail-getMessage() . “!\n”); } else { echo(“Message successfully sent to $to!\n”); echo “Queued As (ESMTP Id): “, $smtp-queued_as, “\n”; echo “Greeting From Mailserver: “, $smtp-greeting, “\n”; } ? Blessings, David M. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array to csv or excel in php
For non-simple data I have been using PEAR's File_CSV package. It's proven itself very useful in regards to not having to determine in my own code whether something needs to be quoted etc etc - especially if the output CSV needs to be wholly RFC 4180 compliant. The documentation of it is rather minimal - at the moment you are dependant on the test/example files and the API docs but grokking how to use it is rather easy. k. On Mon, Apr 19, 2010 at 4:40 PM, Andrew Ballard aball...@gmail.com wrote: On Mon, Apr 19, 2010 at 11:14 AM, Peter Lind peter.e.l...@gmail.com wrote: On 19 April 2010 17:00, Andrew Ballard aball...@gmail.com wrote: On Mon, Apr 19, 2010 at 9:45 AM, Manolis Vlachakis 1. $save=split([|;],$listOfItems); and what i want i s after making some changes to the attributes on the array above to export them on an csv or excel format but directly as a message to the browser .. i dont want it to be saved on the server ... Often when outputting csv, I usually do something like this: ?php $fp = fopen('php://output', 'w') or die('Could not open stream'); foreach ($data as $row) { // Assumes that $row will be an array. // Manipulate the data in $row if necessary. fputcsv($fp, $row); } ? An interesting idea. I'd do: echo implode(',', $row); If it's very simple data that works, but it doesn't allow for the optional enclosure characters that fputcsv() uses in cases where a data element includes the column and/or row delimiter characters. I had originally written something using an array_map callback that did the optional enclosures as needed and then used echo implode() as you suggest, but found the solution I posted was shorter and faster. YMMV Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://blogs.linux.ie/kenguest/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP backup in Minnesota
Thanks to all! I got who I needed. Best regards - -- - Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Drawing Images Without Writing To a File
Floyd Resler wrote: I want to draw tabs in a tab bar without having to actually write the images to a file. Is it possible to generate the image and send the data back and make the browser think it's loading an image file? I know this can be done by sending the proper headers back for an entire page, but I just want to do basically the same thing for just part of the page. Thanks! Floyd I do something similar with my googled webcam :) Then you just use the script as the source for your image (i.e. src=img.php?arguments). Hopefully this is what you are looking for. (Note, this uses the processor pretty heavily when I run 100 images or so). If you are going to reuse the images for many clients, it may be a better alternative to reuse the generated image. ?php header(Content-type: image/jpeg); $file = $_GET[src]; //img/south-lawn1.jpg; $imgfile = img/ . $file; $fsize = filesize($file); $string = South Lawn @ . date(Y-m-d H:i:s, filemtime($file)); $im = imagecreatefromjpeg($file); $color = imagecolorallocate($im, 240, 240, 0); $px = (imagesx($im) - 9.5 * strlen($string)); $py = (imagesy($im) - 24); imagestring($im, 5, $px, $py, $string, $color); imagestring($im, 5, 10, $py, $file, $color); imagestring($im, 5, 10, $py - 16, round(( $fsize / 1024 ),1) . kB, $color); imagejpeg($im); imagedestroy($im); ? === 73, Ken Sande/KC8QNI-T -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP backup in Minnesota
Hey, folks --- - I have a new system going live shortly. Unfortunately, through some client delays (and mine, too, I suppose), we are butting up to a vacation I have planned. My client would like to have a *local* resource PHP person, in case, well I don't know, the whole system starts randomly launching ICBMs toward world capitals or something. So: anyone interested in being a backstop for me over the rest of this month, and a possible replacement in case the client sends a hit-man after me, please send me a note off-line. Some Details: -- St. Paul/Minneapolis area -- PHP 5.2x -- MySQL 5 -- OOP design, using data objects and an application object -- Interesting construction, in that I use a MySQL table as a screen controller object. -- Shopping site, home-built shopping cart. Low volume. -- Session-based, no cookies. -- Home-built Orbital CC processing module Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP backup in Minnesota
Manuel Lemos wrote: Hello, You may want to try posting an offer here to increase the chances of finding somebody. http://www.phpclasses.org/jobs/ You can also look some of the available people on the map of your region: http://www.phpclasses.org/professionals/country/us/ Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP backup in Minnesota
Jochem Maas wrote: Op 3/11/10 10:05 PM, Ken Kixmoeller schreef: Hey, folks --- - -- Session-based, no cookies. sessions are cookie based. unless your passing the session id around via a URL parameter, which is a no-no. Ja, bestimmt. I should have said no persistent cookies -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple cookies on the same computer
On 3/27/2009 at 8:10 PM, in message 49cd6b07.6010...@mac.com, Michael A. Peters mpet...@mac.com wrote: Ken Watkins wrote: I have set up a blog site where my family creates posts and they get emailed to members of the family. To keep up with their identities, I created a script for each family member to run (dad.php, mom.php, etc.), and it sets a cookie on each computer and uses sessions so I know who is connecting. It works great unless I want to share a computer between two users. I thought I had a solution: install both Firefox and IE on the same computer and set two different cookies. But this doesn't seem to work. My question is: Is it possible to set one cookie for IE and another for Firefox so that, depending on which browser is used, I can tell who is connecting to the blog? If this is not possible, is there another easy way to do it? Thanks for your help. - Ken Watkins Why not just use session cookies that expire as soon as a session is over (browser quits) and use a login? Hi Michael. Thanks for the suggestion. I'm trying to keep it as simple as possible with as few keystrokes (for the user) as possible, but your suggestion may be the best way to go. Thanks! Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple cookies on the same computer
On 3/26/2009 at 11:12 PM, in message 70.12.30978.2144c...@pb1.pair.com, Shawn McKenzie nos...@mckenzies.net wrote: Shawn McKenzie wrote: Ken Watkins wrote: Hi all. Newbie here. I have set up a blog site where my family creates posts and they get emailed to members of the family. To keep up with their identities, I created a script for each family member to run (dad.php, mom.php, etc.), and it sets a cookie on each computer and uses sessions so I know who is connecting. It works great unless I want to share a computer between two users. I thought I had a solution: install both Firefox and IE on the same computer and set two different cookies. But this doesn't seem to work. My question is: Is it possible to set one cookie for IE and another for Firefox so that, depending on which browser is used, I can tell who is connecting to the blog? If this is not possible, is there another easy way to do it? Thanks for your help. - Ken Watkins Even if you don't need it secure, have a login. Dad and mom can login with dad or mom with no password if all you need to do is give them their own cookie/session. Optionally, I just thought that if this was too much for them to do/remember, they could have their own bookmarks, like Dad - Yoursite (http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite (http://www.yoursite.com/index.php?person=mom) and set the session/cookie or whatever you're doing based on $_GET['person']. I would still opt for the login though, even if not secure. -- Thanks! -Shawn http://www.spidean.com Hi Shawn - I was hoping to avoid logging in every time, but that may be the best way. What I still don't understand is: I thought that Firefox and IE each had their own cookies, and that I could determine the user by which browser they used. In other words, Firefox's cookie would be for dad and IE's for mom. But I can't figure out how to do that. Do Firefox and IE share cookies? Thanks. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple cookies on the same computer
On 3/26/2009 at 10:24 PM, in message 0a88dc6e-0655-4565-b9a7-e21337fc0...@bluerodeo.com, dg dane...@bluerodeo.com wrote: On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote: To keep up with their identities, I created a script for each family member to run (dad.php, mom.php, etc.), and it sets a cookie on each computer and uses sessions so I know who is connecting. Each family member only uses her/his own page? Maybe set a unique cookie name based on each page? Hi. No, they all go to a common page. I may have to take Shawn's suggestion and just have them login if I can't figure another way to do it. Thanks. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multiple cookies on the same computer
On 3/27/2009 at 10:19 AM, in message 6f.57.30978.d60ec...@pb1.pair.com, Shawn McKenzie nos...@mckenzies.net wrote: Optionally, I just thought that if this was too much for them to do/remember, they could have their own bookmarks, like Dad - Yoursite (http://www.yoursite.com/index.php?person=dad) and Mom - Yoursite (http://www.yoursite.com/index.php?person=mom) and set the session/cookie or whatever you're doing based on $_GET['person']. I would still opt for the login though, even if not secure. No, they use their own cookies so if you want to do it that way, use: $_SERVER['HTTP_USER_AGENT'] and set the cookie based upon the browser. Another thought I had was if you can add domain aliases, dad.yoursite.com and mom.yoursite.com, then they will each have different cookies. Shawn - Yes, domain aliases sound good too. OK, you've given me a couple of good suggestions, and one of them should suit me :) Thanks much. Ken
Re: [PHP] Multiple cookies on the same computer
On 3/27/2009 at 11:15 AM, in message 1238166938.3522.5.ca...@localhost.localdomain, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2009-03-27 at 09:59 -0400, Ken Watkins wrote: On 3/26/2009 at 10:24 PM, in message 0a88dc6e-0655-4565-b9a7-e21337fc0...@bluerodeo.com, dg dane...@bluerodeo.com wrote: On Mar 26, 2009, at 7:14 PM, Ken Watkins wrote: To keep up with their identities, I created a script for each family member to run (dad.php, mom.php, etc.), and it sets a cookie on each computer and uses sessions so I know who is connecting. Each family member only uses her/his own page? Maybe set a unique cookie name based on each page? Hi. No, they all go to a common page. I may have to take Shawn's suggestion and just have them login if I can't figure another way to do it. Thanks. Ken You could have a landing page to the site, that consists of image links (you could use their photo for this?) and each link is in the order of page.php?person=mum etc. That would require an extra click, but no typing for a login, and should make the unique person process a bit more intuitive. Ash www.ashleysheridan.co.uk Hi Ash. Hey, I like it. Clicking beats typing in my book. Thanks! Ken
[PHP] Multiple cookies on the same computer
Hi all. Newbie here. I have set up a blog site where my family creates posts and they get emailed to members of the family. To keep up with their identities, I created a script for each family member to run (dad.php, mom.php, etc.), and it sets a cookie on each computer and uses sessions so I know who is connecting. It works great unless I want to share a computer between two users. I thought I had a solution: install both Firefox and IE on the same computer and set two different cookies. But this doesn't seem to work. My question is: Is it possible to set one cookie for IE and another for Firefox so that, depending on which browser is used, I can tell who is connecting to the blog? If this is not possible, is there another easy way to do it? Thanks for your help. - Ken Watkins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Testing HTTPS without certificate
Hi - - - - -- I have a typical setup -- my development machine, a testing server and, of course, the production server. My development machine, of course, doesn't have a Secure certificate, yet I need to be able to test https pages here, before getting to the testing server. (Currently, the testing server doesn't have one either, but that will be remedied shortly.) I know how to test for the existance of HTTPS, and stuff like that. So: Can one test https on a local machine? Resources, anyone? I have Googled my fingers off. Environment: PHP 5.2.5 Win 2K IIS 5 - or, if I need to - Mac OS-X 10.4 Apache? (I haven't set up the Mac as a server) - or - Linux (Ubuntu) with Apache (I am moving this direction and haven't yet learned how to run Apache) Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Testing HTTPS without certificate
On Apr 23, 2008, at 4:53 PM, Shawn McKenzie wrote: Ken Kixmoeller wrote: I know how to test for the existance of HTTPS, and stuff like that. So: Can one test https on a local machine? Resources, anyone? I have Googled my fingers off. Why not just generate a free self-signed certificate for use on the dev server or workstation? Thanks, Shawn Mike -- I'll research that. Many thanks... Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Membership Management
Jason -- - - - There are many, many membership management programs out there, though I doubt that there are any open source ones. It is a lucrative business for many-a-folk. I have always advised prospective clients to buy, not build, as the commercial software choices out there are many and very good. There are many tricks and traps to trying to build one from scratch, among them building a combined cycle and on-demand billing system. One place to look is the Society of Non-profit Executives, or improve your google search thusly: http://tinyurl.com/4yt5ru Ken On Apr 21, 2008, at 12:08 PM, Jason Pruim wrote: I have a client that wants me to fork a current project into a membership management piece of software. Does anyone know of any open source projects that I can look at? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] module access rights
On Apr 19, 2008, at 2:37 AM, Alain Roger wrote: Hi, i'm very surprised... i did not get any answer to my previous post. is it because it is good way to do it or because nobody knows ? --- Hi, i face now a little issue regarding how end user can access to some modules of my web portal. Let imagine we have several modules (let say: mod1, mod 2, mod3) and 2 users (usr1, usr2). i would like to use a simple way how to established access rights for each user to grant/forbidden access to modules... Or maybe the answer is as complicated as the question seems simple. I have my master application object. On __construct, it checks the current user's rights from somewhere (a config file or a database, for example), and instantiates the application based on the rights profile. Simple answer, but a lot of front-end work to implement. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] module access rights
Right. Thanks for the links. This type of approach is the basis of my software architecture. Ken (BTW, don't forget to Reply All so your reply goes to the list, too). On Apr 19, 2008, at 9:03 AM, Tony Marston wrote: What you are describing is a Role Based Access Control (RBAC) system, and it is not simple. Take a look at http://www.tonymarston.net/php-mysql/role-based-access-control.html and http://www.tonymarston.net/php-mysql/menuguide/index.html Tony Marston http://www.tonymarston.net http://www.radicore.org -Original Message- From: Ken Kixmoeller.com [mailto:[EMAIL PROTECTED] Sent: 19 April 2008 14:33 To: PHP General List Subject: Re: [PHP] module access rights On Apr 19, 2008, at 2:37 AM, Alain Roger wrote: Hi, i'm very surprised... i did not get any answer to my previous post. is it because it is good way to do it or because nobody knows ? --- Hi, i face now a little issue regarding how end user can access to some modules of my web portal. Let imagine we have several modules (let say: mod1, mod 2, mod3) and 2 users (usr1, usr2). i would like to use a simple way how to established access rights for each user to grant/forbidden access to modules... Or maybe the answer is as complicated as the question seems simple. I have my master application object. On __construct, it checks the current user's rights from somewhere (a config file or a database, for example), and instantiates the application based on the rights profile. Simple answer, but a lot of front-end work to implement. Ken -- 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
Re: [PHP] Re: Generating JavaScript menus on-the-fly
Thank you -- I don't know about those functions -- I'll check them out (for general knowledge, too)... Ken On Mar 10, 2008, at 12:01 PM, Roberto Mansfield wrote: If you are building select menus on the fly using javascript, look at php's json_encode function. It will create a JSON representation of your php data structure. Makes passing data sets to javascript very easy. Just build your array of allowed options in php, plug the data into your javascript via json_encode() and let javascript build the menu options. Ken Kixmoeller wrote: Hey - - -- - -- -- I keep a profile of a user's rights and responsibilities in tables. Since this profile defines what a user can do in the system I am designing, I'd like to build a JavaScript menu navigation scheme. I need it to be driven programmatically, because the Admin users can add and remove tasks to the system or to a given user at-will. I already built a similar thing using CSS-only menus, but it just wasn't aesthetically flexible enough. I am exploring other options, but I am wondering if any of you have done something similar and have any samples or advice. Ken -- 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
Re: [PHP] Generating JavaScript menus on-the-fly
On Mar 8, 2008, at 9:17 AM, tedd wrote: At 3:01 PM -0600 3/7/08, Ken Kixmoeller wrote: Hey - - -- - -- -- I keep a profile of a user's rights and responsibilities in tables. Since this profile defines what a user can do in the system I am designing, I'd like to build a JavaScript menu navigation scheme. I need it to be driven programmatically, because the Admin users can add and remove tasks to the system or to a given user at-will. I already built a similar thing using CSS-only menus, but it just wasn't aesthetically flexible enough. I am exploring other options, but I am wondering if any of you have done something similar and have any samples or advice. I use php and css to do navigation. The css handles client-side and php does the server-side. If you have links that are available for some, but not others and want to keep them secure/private, then don't go the javascript route -- it's a simple matter to break that. My advice, figure out what you want to present in php and then have php write the css for you. Hi, tedd --- - - - Thank you for the advice. I guess I'd better try the CSS route again. I think I may do a combination of CSS and the technique I'm using now. I appreciate the advice you gave on what is breakable, too. Just to amplify -- the tasks that are available to a user are in a session array. These are created on login (or session init. for a guest user) and only those tasks to which the user has access appear in the array -- links are not just disabled. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Generating JavaScript menus on-the-fly
Hey - - -- - -- -- I keep a profile of a user's rights and responsibilities in tables. Since this profile defines what a user can do in the system I am designing, I'd like to build a JavaScript menu navigation scheme. I need it to be driven programmatically, because the Admin users can add and remove tasks to the system or to a given user at-will. I already built a similar thing using CSS-only menus, but it just wasn't aesthetically flexible enough. I am exploring other options, but I am wondering if any of you have done something similar and have any samples or advice. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
(forgot to copy the list) On Jan 16, 2008, at 5:08 PM, Richard Lynch wrote: Is it possible that 4% of the time, you have spaces on the start/end of the string, which get trimmed before encryption? In this case, no. In trying to simplify the situation to narrow the possibilities of error, I am generating random character strings of only alphanumeric (or numeric-only) characters. Each is exactly 16 characters. And if rijndael is one of the algorithms which requires a fixed-size input, that also would be bad to trim it. No documentation that I was able to find suggests that requirement. Actually, I'd suggest that the encryption function has no business trimming the text anyway. Philosophically I agree with you, but mCrypt has this nasty habit of appending bunches of nulls to the decrypted string. So philosophical purity gives way to practical application. Good ideas, as usual. Thank you. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 15, 2008, at 10:48 PM, Casey wrote: It returns the correct value. If you look at the last example, and run base64_decode on MDAwMzEwMDI0NDA0MTMyOQ==, you will get 0003100244041329. Oops. Haste makes crappy programming. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 16, 2008, at 1:28 AM, Andrés Robinet wrote: 1 - Mike is right about first encrypting and then doing a base64_encode (then saving results to DB, cookies, etc). I don't know why replacing to + for decrypting, though. His other post explains that php didn't seem to like spaces. No spaces in the test strings -- I'll check for those when/if I can get the core en/decryption working. 2 - Mike is also right about $text = base64_decode($text) which should be $text = base64_decode($text_out) I think. Yup -- that's what i get for trying to do this hastily and late at night -- 3 - You are trimming the results on return, according to one post in the manual notes this will remove null padding on the decrypted string. This is desired, most of the time, but if the original (cleartext message) string ended in nulls you will get a difference and that may be the cause of the errors you are getting. I understand that, thank you. There are no trailing nulls on the original string. After correcting the my program, I still get the same results, about 4% wrong: 70: String: 5214006139804600 -|- Enc: Ϊ%bÇCsšBsìD%Å#z[ä. m…‡¿m§ð -|- Dec:àc8 -|- Nope 75: String: 1034702254251899 -|- Enc: !:Ã2ºÍé×»àe2s? :Ù0LµŒÕ[« -|- Dec:à`*' -|- Nope 89: String: 8245007043826594 -|- Enc: µÆ Íãd-‘Á´E3½yÍ×v‹,ZØWéûqüŽ‚ó -|- Dec:[EMAIL PROTECTED] -|- Nope etc. Wrong: 23/500 Phooey. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
Many thanks, Mike --- yours works great... 0 errors. On Jan 16, 2008, at 9:24 AM, mike wrote: function data_encrypt($data) { if(!$data) { return false; } return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $GLOBALS['config']['salt'], $data, 'cbc', md5($GLOBALS['config'][' salt'].$GLOBALS['config']['salt']))); } function data_decrypt($data) { if(!$data) { return false; } return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $GLOBALS['config']['salt'], base64_decode(str_replace(' ', '+', $data)), ' cbc', md5($GLOBALS['config']['salt'].$GLOBALS['config']['salt']))); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Encryption failing
Hey --- - - I am in the process of upgrading the encryption technology I am using from (64 bit) blowfish to (256 bit) rijndael. The code (and some explanations) is below, but the results are, um, unusual, and I can't see what I am doing wrong. For testing, I have a program that generates a random 16-character string, encrypts it to a variable, and decrypts it. Running it in 500 iteration loops, it fails roughly 4% of the time. By fails I mean that the original string and the eventual decrypted one don't match. Anybody able to spot why? Ken -- function jagencdecr($text,$EorD,$encpass='') { // parameters: // - $text = string to be en/decrypted, // - $EorD = Encrypt or Decrypt // - $encpass = key phrase if (empty($text)) {return ;} $text = trim($text); $cypher = mcrypt_module_open('rijndael-256', '', 'ecb', ''); // ecb mode produces the above results. // ofb mode produces 100% errors $size = mcrypt_enc_get_iv_size($cypher); $phprand = rand(1000,); $iv = mcrypt_create_iv($size,$phprand); // produces the same results as below, platform independent //$iv = mcrypt_create_iv($size,MCRYPT_RAND); // for Windows //$iv = mcrypt_create_iv($size,MCRYPT_DEV_RAND); // for 'NIX $ks = mcrypt_enc_get_key_size($cypher); /* Create key */ $key = substr(md5($encpass), 0, $ks); mcrypt_generic_init($cypher,$key,$iv); if ($EorD == D) { $text_out = mdecrypt_generic($cypher,$text); } else { $text_out = mcrypt_generic($cypher,$text); } // endif ($EorD == D) mcrypt_generic_deinit($cypher); mcrypt_module_close($cypher); return trim($text_out); } // endfunc jagencdecr Jaguar Ecnrypt/Decrypt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 15, 2008, at 7:06 PM, Casey wrote: Maybe you could echo the results of the failed ones and compare. I did that at first, thinking that something about these strings might cause the problem. But then I realized: I can't blame the data. I don't have any control over what users use for passwords, for example. this thing is supposed to en/decrypt the strings I gige it, so there must be some kind of programming flaw. FWIW, there was no discernible pattern to the failed strings, at least not to me. (Not that it matters.) Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Encryption failing
On Jan 15, 2008, at 11:08 PM, Andrés Robinet wrote: -Original Message- From: Bastien Koert [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 16, 2008 12:55 AM To: Ken Kixmoeller -- reply to [EMAIL PROTECTED]; php- [EMAIL PROTECTED] Subject: RE: [PHP] Encryption failing are you base64 encoding the resultant encryption string? I have found that there are problems with certain characters that can result from the encryption, usually a combination of characters that approximate a null or end of line bastien From: [EMAIL PROTECTED] Date: Tue, 15 Jan 2008 21:41:45 - 0600 To: php-general@lists.php.net Subject: Re: [PHP] Encryption failing On Jan 15, 2008, at 7:06 PM, Casey wrote: Maybe you could echo the results of the failed ones and compare. I did that at first, thinking that something about these strings might cause the problem. But then I realized: I can't blame the data. I don't have any control over what users use for passwords, for example. this thing is supposed to en/decrypt the strings I gige it, so there must be some kind of programming flaw. FWIW, there was no discernible pattern to the failed strings, at least not to me. (Not that it matters.) Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I second that, you should base64 encode values before encrypting and base64 decode them after decrypting to be safe. Rob Andrés Robinet | Lead Developer | BESTPLACE CORPORATION 5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 | TEL 954-607-4207 | FAX 954-337-2695 Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace | Web: http://www.bestplace.biz | Web: http://www.seo- diy.com -- 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