[PHP] RE: search is not case insensitive
I have a fix. Thanks to the list for steering me in the right direction Just in case anyone else is lost, here it is, via use of the CONVERT function to convert the binary data to text which can then be searched case insensitively in mysql: Replace this line: AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; with: AND CONVERT(C.description USING latin1) LIKE '%.($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; (the only bit that changes is the text betw the first two 'ANDS') It comes from PBCS online appointment software. Thanks Michael -Original Message- From: Dr Michael Daly [mailto:g...@holisticgp.com.au] Sent: Sunday, 31 October 2010 3:47 PM To: php-general@lists.php.net Subject: search is not case insensitive Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C. WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include html
On Nov 2, 2010, at 12:37 AM, Nathan Nobbe wrote: On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers k...@designdrumm.com wrote: I need to basically grab the source of the page as text. Then I can do a replace() on the link tag. Then insert the text into an Iframe. In theory, this I thought would be handled better server side. Is this possible? yes, there are a few options, fopen wrappers, curl or raw sockets all come to mind. fopen wrappers sound like they may be easiest for you. Any examples or urls to make a fopen wrapper? Or is there a simple function for getting the source text from a URL? Thats all I really need, if I can get html.../html in text, I'm good! From that point I can insert the text into a hidden form field and grab the text via javascript if need be (but very hackish) or with php. I think that may be a solution, if I assign an include statement or echo of the url inside a hidden form field. A hidden form field will force the text to be saved and not parsed. I think. I think the problem I'm having is that the domain I'm requesting from is not the same domain as mine so their may be some security issue. right, this is why you would setup a server side proxy, to avoid client side cross domain security restrictions, however you'll have to change all the instances of the remote domain to your domain, and ensure that your server actually is able to fulfill requests for those resources. Server side proxy.. I have heard of this, but do not know exactly what a proxy does to know if it would be a solution. I also have not seen one in action nor made one (that I know of), any beginner tuts you can lend? I also thought about injecting a link tag into the iframe at the same time I load the HTML. when you say link tag are you talking about a tags? you lost me on this last line here. IE: [code] Get the text from their source, something like: $htmlTextresult = html head link href=css/fromtheirsite.css rel=stylesheet type=text/css media=all / /head body ... their content /body /html then do a string replace on the link tag.. $newTextresult = str_replace($htmlTextresult, 'link href=css/ fromtheirsite.css rel=stylesheet type=text/css media=all /', 'link href=css/frommysite.css rel=stylesheet type=text/css media=all /'); or $newTextresult = str_replace($htmlTextresult, 'css/ fromtheirsite.css', 'css/frommysite.css'); insert new text into the iframe.. $newTextresult = html head link href=css/frommysite.css rel=stylesheet type=text/css media=all / /head body ... their content/ my style :) /body /html Or is there a way to strip the text that is in the head , body and script tags? I could then insert those into a blank html file? Browsers load the last style sheet on top of others. this is true, but i doubt you'll be able to have it load a css file from your domain atop a css file from a remote domain. Well contrary, I think, only because all css tuts I found warned about using the !important in your css as it would override an external css. Imported css has the least priority out of all and their css is imported, maybe if I wrote the css as a style inline within the text I received from the source? I know that would work as far as my css beating out theirs. And the idea is to get the source and replace the text that points to their css (the link tag) with mine before its parsed. If I could just get the link tag into the iframes contents right after I get the source text in there, it may work. But there is also the issue of correctly assigning the classes and I'd that are used in the iframe. Like iframe.holder .someclassusedbythem {} Or do I do? iframe#holder .someclassusedbythem {} Or #holder .someclassusedbythem {} Sorry if I'm OT with that. shrug, no worries, but im too lazy to dig into the details of client side options. :) Hey thanks for your help Nathan. I was starting to think I needed to scrap. You have sparked the curiosity again. Best, -nathan Karl DeSaulniers Design Drumm http://designdrumm.com
[PHP] Re: Implementing optional methods in a concrete class, but calling themfrom an abstract class.
Richard Quadling wrote: Hi. I have an abstract base class (call it genericServiceHandler). I have concrete classes (FaxService, EmailService). ... What would you all do? If you've got fixed logic then just add all the onStart onPause and similar methods to the abstract class, stub them to accept the correct params but simply return immediately, call them in the correct places with $this-onStart($arg0...) Then any class which extends it, like EmailService, can simply overwrite which ever methods it needs to implement. The other approach which can be nice is to decouple it and go for an event or message based system, that way you can hook in multiple different callbacks to do something when the onSomething [event/message] is dispatched. Best, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fwd: Mail delivery failed: returning message to sender
Ben Brentlinger wrote: it could be that you tried a cheap hosting account with a company that have a bulk mailing script meant for sending spam. I can imagine a spammer hijacking your site to send malware from it, one of the more likely possibilities especially if you have a hosting account with cpanel. Cheap webhosting companies are more likely breading grounds for those kinds of shady charachters. I'd recommend changing webhosts immediately, and I'd recommend hostgator http://secure.hostgator.com/%7Eaffiliat/cgi-bin/affiliates/clickthru.cgi?id=BenBrent. They're not 11 or Godaddy, but there one of the biggest webhosting companies that use cpanel. I would recommend any webhosting company that use cpanel because its either harder to use, not as secure or both. Did you really say all of that and then drop an affiliate link in? Awesome. Yours, Snippily, Nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Fwd: Mail delivery failed: returning message to sender
On Tue, 2010-11-02 at 11:10 +, Nathan Rixham wrote: Ben Brentlinger wrote: it could be that you tried a cheap hosting account with a company that have a bulk mailing script meant for sending spam. I can imagine a spammer hijacking your site to send malware from it, one of the more likely possibilities especially if you have a hosting account with cpanel. Cheap webhosting companies are more likely breading grounds for those kinds of shady charachters. I'd recommend changing webhosts immediately, and I'd recommend hostgator http://secure.hostgator.com/%7Eaffiliat/cgi-bin/affiliates/clickthru.cgi?id=BenBrent. They're not 11 or Godaddy, but there one of the biggest webhosting companies that use cpanel. I would recommend any webhosting company that use cpanel because its either harder to use, not as secure or both. Did you really say all of that and then drop an affiliate link in? Awesome. Yours, Snippily, Nathan Yeah, I think he did... now, since you all have crap hosting, let me recommend my hosting provider... http://mind.yourownbusiness.com :) I love how he plugs them, says they are not as BIG as 1and1 or GoDaddy... BUT THEY USE CPANEL then go on to say use cpanel because it's harder to use, less secure, or both? makes me want to jump right on that... brb... switching hosting providers... LOL! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 12:29 AM, Nathan Nobbe quickshif...@gmail.com wrote: a few thoughts, 1. set error_reporting to E_ALL to see if the engine is trying to tell you something you may be overlooking Sorry, failed to mention that I did this, and it says nothing. 2. for grins, maybe see if the TZ environment variable is set on your system var_dump(getenv('TZ')); I didn't post the phpinfo() output originally but had checked and no, TZ isn't set. 3. another test would be to set date.timezone to something else and see if date_default_timezone_get() returns that new value, which would indicate it's falling through to the third option in the precedence chain. AHA! I had tried checking validity by setting a BOGUS time zone (which showed that it was taking effect), but I had not tried checking by setting an alternate VALID time zone. Guess what? It works. If I set it to America/Denver, I get correct output. Thus, something is corrupt in the timezone DB itself (which I believe is internal to PHP from what I understand from the threads I've read). America/Chicago is completely broken but America/Denver works just fine. Incidentally, I have noticed that CentOS is completely broken in their tz distro. Every time it updates, it includes a US/Central file that is completely invalid. This has persisted for months--at the OS level I've fixed it by copying in a valid US/Central file from another box. But doing that does not fix PHP (tried that just now)--which again I'd expect it not to anyway, since I believe PHP (as of PHP5) has an internal timezone DB. But I tried it just in case. So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? Thanks much, Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 9:19 AM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search is not case insensitive
At 10:23 PM -0700 11/1/10, Tommy Pham wrote: -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Sunday, October 31, 2010 9:00 AM To: g...@holisticgp.com.au; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id. AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case-sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ IIRC, the VARCHAR (for MySQL) has a limit of 255 chars. You may have to use one of the *TEXT variants if you need to store a lot of text. Regards, Tommy Tommy: If you are using a version of MySQL that is older than v 5.0.3, then you are right -- but after that version VARCHAR can hold up to 65,535 characters. How much does the OP need? If that is not enough room, then why not use LONGTEXT (4G)? The differences are how the data is stored. In BLOBS the data is stored in binary strings with no char set and comparisons are based on numeric values of bytes. Whereas, TEXT data are treated as character strings which have a char set and can be sorted and compared based upon collation of the char set. Cheers, tedd -- --- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 8:44 AM, Dan Yost yod...@gmail.com wrote: On Tue, Nov 2, 2010 at 9:19 AM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Nov 2, 2010 at 7:52 AM, Dan Yost yod...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? -nathan
RE: [PHP] search is not case insensitive
-Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Tuesday, November 02, 2010 8:09 AM To: Tommy Pham; g...@holisticgp.com.au; php-general@lists.php.net Subject: RE: [PHP] search is not case insensitive At 10:23 PM -0700 11/1/10, Tommy Pham wrote: -Original Message- From: tedd [mailto:tedd.sperl...@gmail.com] Sent: Sunday, October 31, 2010 9:00 AM To: g...@holisticgp.com.au; php-general@lists.php.net Subject: Re: [PHP] search is not case insensitive At 3:47 PM +1100 10/31/10, Dr Michael Daly wrote: Hi Using a php search form produces a nil return on any information that is capitalised within a mysql database; retrieval is fine for non-capitalised data. Could someone tweak this please? The relevant code I think is as follows: // Description is a BLOB in MySQL... we need to UPPER the blob //values to make the search case-insensitive. $query = SELECT C.*, A.surname, A.name, A.surname_prefix, A.id AS user FROM pbcs_user A, pbcs_join_table_user_app B, pbcs_appointment C . WHERE A.id = B.user_id AND B.appointment_id = C.id . AND LOWER(C.description) LIKE '%.strtolower($search_for).%' AND C.start_time $start_time AND C.start_time $end_time ORDER BY C.start_time; $result = pbcs_db_query($query); Thanks Michael Melb, Aust. Why are you using a BLOB? You are just storing text data, right? If so, then a VARCHAR will work. Additionally, using a BLOB changes things somewhat in that all data are stored as binary strings and as such makes all comparisons case- sensitive. Too many double negatives for me. Cheers, tedd -- --- http://sperling.com/ IIRC, the VARCHAR (for MySQL) has a limit of 255 chars. You may have to use one of the *TEXT variants if you need to store a lot of text. Regards, Tommy Tommy: If you are using a version of MySQL that is older than v 5.0.3, then you are right -- but after that version VARCHAR can hold up to 65,535 characters. Tedd, That tells you that I haven't been keeping track of version changes for MySQL. I remember that when 5 was still an RC. How much does the OP need? If that is not enough room, then why not use LONGTEXT (4G)? The differences are how the data is stored. In BLOBS the data is stored in binary strings with no char set and comparisons are based on numeric values of bytes. Whereas, TEXT data are treated as character strings which have a char set and can be sorted and compared based upon collation of the char set. Cheers, tedd -- --- http://sperling.com/ I totally agree on VARCHAR/TEXT over BLOBs as you can use the index (with/without FULLTEXT) more efficiently for faster query results. Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 11:02 AM, Nathan Nobbe quickshif...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? I had tried that originally too. It does set the timezone correctly, but then again so does the ini set. So the timezone does get set to America/Chicago with a date_default_timezone_set(), and then PHP shanks from there, showing UTC. It seems certain that the timezone *does* get set to America/Chicago (via multiple methods), and that America/Chicago *itself* is corrupt in PHP--and that's even with timezonedb installed. Now everybody knows Chicago is full of corruption, but at least the clocks aren't, right? Surely there are bizillions of others out there running this combination of software in the Central time zone! Yet it's as if nobody else has corrupt timezone DB records (be they internal or via timezonedb) except me. And I can't help but notice how CentOS (tzdata package) is also corrupt, every single time it gets updated, on the Central zone but no others. Obviously these should be entirely separate issues, but somebody out there has it out for the Central time zone. Probably a Yankees fan. Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 10:11 AM, Dan Yost yod...@gmail.com wrote: On Tue, Nov 2, 2010 at 11:02 AM, Nathan Nobbe quickshif...@gmail.com wrote: So now I suppose the thread becomes: how do I get a valid US/Central (America/Chicago) timezone in PHP5? give the timezonedb extension a shot http://pecl.php.net/package/timezonedb Tried it, no change. It is still impossible to get simple CENTRAL timezone output. This is maddening. That's really weird since I'm sure php has its own timezone db, and it sounds like that's where PHP is getting it if you saw the correct output after switching date.timezone to America/Denver. What about trying date_default_timezone_set() ? I had tried that originally too. It does set the timezone correctly, but then again so does the ini set. So the timezone does get set to America/Chicago with a date_default_timezone_set(), and then PHP shanks from there, showing UTC. It seems certain that the timezone *does* get set to America/Chicago (via multiple methods), and that America/Chicago *itself* is corrupt in PHP--and that's even with timezonedb installed. Now everybody knows Chicago is full of corruption, but at least the clocks aren't, right? Surely there are bizillions of others out there running this combination of software in the Central time zone! Yet it's as if nobody else has corrupt timezone DB records (be they internal or via timezonedb) except me. And I can't help but notice how CentOS (tzdata package) is also corrupt, every single time it gets updated, on the Central zone but no others. Obviously these should be entirely separate issues, but somebody out there has it out for the Central time zone. Probably a Yankees fan. dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 10:37 AM, Nathan Nobbe quickshif...@gmail.comwrote: dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. yeah, we have one centos box left on our network atm, 5.2 $ cat /etc/redhat-release CentOS release 5.2 (Final) php 5.2.6 $ php -v PHP 5.2.6 (cli) (built: May 5 2008 14:41:03) Copyright (c) 1997-2008 The PHP Group looks like if i set the timezone explicitly the date functions are working correctly (obviously though im not sure if this is a 5.1 vs 5.2 issue, just saying :D) php echo Br . strftime(%D %T %z %Z) . br; Br11/02/10 10:40:12 -0600 MDTbr php date_default_timezone_set('America/Chicago'); php echo Br . strftime(%D %T %z %Z) . br; Br11/02/10 11:40:53 -0500 CDTbr -nathan
Re: [PHP] time zone ignored (both via ini or in code)
On Tue, Nov 2, 2010 at 11:37 AM, Nathan Nobbe quickshif...@gmail.com wrote: dude at this point i dont want to sound too much like a troll, but php 5.1 is some really old software. frankly this is why i chose not to run on centos during my evaluation of it. i understand the concept behind running proven stable software, but i think centos is taking that notion to the extreme. i would probly try building a more recent version of php from source and see if that helps. That's OK, I knew this was coming. It's been a real struggle to be deploying something so old, yet CentOS insists on nothing but 5.1 in the packages unless you resort to some volatile repositories, which kind of defeats the purpose (in my case, that is). I used to always go with source directly but was really hoping to go the somewhat-brainless auto-update route, sticking to yum packages and all that. At risk of sending this thread too far down an OS-specific path, can anybody in the CentOS+PHP world comment on yum packages, 5.1, and this actual issue? (In the very beginning I scoured the Net, thinking surely 5.1.6 can't be the standard on CentOS, but kept running into the either go from source yourself or use volatile repositories claims, which aren't good in an enterprise case, though I realize using source isn't bad from that standpoint). Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Password protected directory
I need to access and read the files in a password protected directory with a PHP script using the readdir function. I'm already making users login to a secure area, so I don't want to make them enter a password again to access the files - is there a way to include the password with the readdir/opendir function with PHP? Thanks in advance. Ben
Re: [PHP] Password protected directory
On Tue, Nov 2, 2010 at 1:05 PM, Ben Miller biprel...@gmail.com wrote: I need to access and read the files in a password protected directory with a PHP script using the readdir function. I'm already making users login to a secure area, so I don't want to make them enter a password again to access the files - is there a way to include the password with the readdir/opendir function with PHP? Thanks in advance. Ben assign a session key to the user and just check if that session key is set before using the standard account to access the file. Then the password can be held in the config file and the user never sees it -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Password protected directory
On Tue, Nov 2, 2010 at 13:05, Ben Miller biprel...@gmail.com wrote: I need to access and read the files in a password protected directory with a PHP script using the readdir function. I'm already making users login to a secure area, so I don't want to make them enter a password again to access the files - is there a way to include the password with the readdir/opendir function with PHP? What operating system? How is the directory password-protected (HTTP auth, Win/SAMBA share ACLs, PHP/script control, etc.)? Is everything hosted on the same machine or virtual environment? As you can tell, it's a bit difficult to give you an answer when the question is so vague that it may as well be nonexistent. ;-P -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php