php-general Digest 2 Nov 2010 10:49:34 -0000 Issue 7017
Topics (messages 309222 through 309230):
Re: include html
309222 by: Nathan Nobbe
309224 by: Karl DeSaulniers
309227 by: Nathan Nobbe
309229 by: Karl DeSaulniers
Re: search is not case insensitive
309223 by: Tommy Pham
309225 by: Tommy Pham
309228 by: Dr Michael Daly
Re: time zone ignored (both via ini or in code)
309226 by: Nathan Nobbe
Re: Implementing optional methods in a concrete class, but calling themfrom an
abstract class.
309230 by: Nathan Rixham
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
On Sunday, October 31, 2010, [email protected]
<[email protected]> wrote:
> This can only be done with javascript, as the iframe is client-side, which
> php knows nothing about.
sounds to me like OP is building the page which will have the iframe
in it which means this is totally doable server side. in fact, id
almost prefer server side as that allows masking of the origin making
overriding css values easier afaict.
> I am building a website for a tshirt company that uses another
> company to get garments and promo items to print on.
> The client wants to just have those pages load on top of their
> website, but wants the layout to go with their look and feel. their css.
> We have the go ahead from the other companies to do so as well.
Karl,
this could be done server or client side, however the trouble is
altering the css for every page inside the iframe could be a real
pain. basically what you could do is act as a proxy, each 'page' from
the original site should be 'made a page' on your site. basically
youll have to change anchor tag href attributes so each request that
would go back to the original site goes through your site first. that
way youll have the chance to change the result before handing it back
to the client. also youll obviously need to change the url to css
file(s) per your primary requirement. if you do as i suggested above
and make the remote site appear as being served from your domain, you
should be able to get away w/ using a css file served from your domain
as well.
as one of my college professors used to say however, the devil is in
the details, mwahaha. i would recommend initially experimening to see
if you can use w/e look & feel customizations the remote site offers
to determine if embedding in the iframe w/o any proxy effort is
possible.
-nathan
--- End Message ---
--- Begin Message ---
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? 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. I also thought about injecting a link tag into the
iframe at the same time I load the HTML. Browsers load the last style
sheet on top of others. 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.
Karl
Sent from losPhone
On Nov 1, 2010, at 11:50 PM, Nathan Nobbe <[email protected]>
wrote:
On Sunday, October 31, 2010, [email protected]
<[email protected]> wrote:
This can only be done with javascript, as the iframe is client-
side, which php knows nothing about.
sounds to me like OP is building the page which will have the iframe
in it which means this is totally doable server side. in fact, id
almost prefer server side as that allows masking of the origin making
overriding css values easier afaict.
I am building a website for a tshirt company that uses another
company to get garments and promo items to print on.
The client wants to just have those pages load on top of their
website, but wants the layout to go with their look and feel. their
css.
We have the go ahead from the other companies to do so as well.
Karl,
this could be done server or client side, however the trouble is
altering the css for every page inside the iframe could be a real
pain. basically what you could do is act as a proxy, each 'page' from
the original site should be 'made a page' on your site. basically
youll have to change anchor tag href attributes so each request that
would go back to the original site goes through your site first. that
way youll have the chance to change the result before handing it back
to the client. also youll obviously need to change the url to css
file(s) per your primary requirement. if you do as i suggested above
and make the remote site appear as being served from your domain, you
should be able to get away w/ using a css file served from your domain
as well.
as one of my college professors used to say however, the devil is in
the details, mwahaha. i would recommend initially experimening to see
if you can use w/e look & feel customizations the remote site offers
to determine if embedding in the iframe w/o any proxy effort is
possible.
-nathan
--- End Message ---
--- Begin Message ---
On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers <[email protected]>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.
> 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.
> 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.
> 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.
> 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. :)
-nathan
--- End Message ---
--- Begin Message ---
On Nov 2, 2010, at 12:37 AM, Nathan Nobbe wrote:
On Mon, Nov 1, 2010 at 11:22 PM, Karl DeSaulniers
<[email protected]> 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
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Sunday, October 31, 2010 2:10 AM
> To: Dr Michael Daly; [email protected]
> Subject: Re: [PHP] search is not case insensitive
>
> This isn't a php question but a mysql one. Take out the lower() part of the
> sql statement, as like is case insensitive by default.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
> ----- Reply message -----
> From: "Dr Michael Daly" <[email protected]>
> Date: Sun, Oct 31, 2010 04:47
> Subject: [PHP] search is not case insensitive
> To: <[email protected]>
>
> 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.
>
You could also remove the strtolower(). Just to be sure that field
C.description is set with case-insensitive collation, you could use phpMyAdmin
to look at the table structure or run SQL 'show create table pbcs_appointment;'
on your MySQL tool. The description column should have *_ci (for
case-insensitive whereas *_cs is case-sensitive).
Regards,
Tommy
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: tedd [mailto:[email protected]]
> Sent: Sunday, October 31, 2010 9:00 AM
> To: [email protected]; [email protected]
> 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
--- End Message ---
--- Begin Message ---
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:[email protected]]
Sent: Sunday, 31 October 2010 3:47 PM
To: [email protected]
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.
--- End Message ---
--- Begin Message ---
On Mon, Nov 1, 2010 at 12:54 PM, Dan Yost <[email protected]> wrote:
> Greetings,
>
> I've looked through a number of different archived threads (some
> rather heated) and samples as well, but clearly I'm just missing
> something.
>
> PHP 5.1.6
> CentOS release 5.5 (Final)
>
> My server is in Central Time (US). We do observe DST. I noticed
> functions like strftime() display UTC time. So I undertook fixing
> this.
>
> I read several threads about setting date.timezone in php.ini, and
> arguments for/against different timezone methods. But in my case I see
> no reason why setting the timezone in php.ini would hurt us--we can
> live with that. And yet:
>
> [...@ez2 html 13:47:20]$ date
> Mon Nov 1 13:50:05 CDT 2010
>
> Good.
>
> [...@ez2 html 13:50:05]$ grep -i timezone /etc/php.ini
> date.timezone = "America/Chicago"
>
> Good--and yes, Apache was restarted. So far, we're Central, life is good.
>
> Let's hit PHP now:
>
> ------------
> <?
> if (date_default_timezone_get()) {
> echo 'date_default_timezone_get: ' . date_default_timezone_get() . '<br
> />';
> }
>
> if (ini_get('date.timezone')) {
> echo 'date.timezone: ' . ini_get('date.timezone');
> }
>
> echo "<Br>";
>
> $localtime = localtime();
> $localtime_assoc = localtime(time(), true);
> print_r($localtime);
> print_r($localtime_assoc);
>
>
> echo "<Br>" . strftime("%D %T %z %Z") . "<br>";
>
> ?>
> ------------
>
>
> Which produces:
>
>
> date_default_timezone_get: America/Chicago
> date.timezone: America/Chicago
> Array ( [0] => 14 [1] => 51 [2] => 18 [3] => 1 [4] => 10 [5] => 110
> [6] => 1 [7] => 304 [8] => 0 ) Array ( [tm_sec] => 14 [tm_min] => 51
> [tm_hour] => 18 [tm_mday] => 1 [tm_mon] => 10 [tm_year] => 110
> [tm_wday] => 1 [tm_yday] => 304 [tm_isdst] => 0 )
> 11/01/10 18:51:14 +0000 UTC
>
>
> Timezone is America/Chicago, yet date functions completely ignore this
> and continue to display UTC.
>
> Please help me understand where I'm blind here.
>
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
2. for grins, maybe see if the TZ environment variable is set on your system
var_dump(getenv('TZ'));
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.
lastly you might see if the calling date_default_timezone_set() does the
trick.
-nathan
--- End Message ---
--- Begin Message ---
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
--- End Message ---