php-general Digest 14 Feb 2012 12:28:33 -0000 Issue 7688
Topics (messages 316587 through 316600):
Re: questions about $_SERVER
316587 by: Tedd Sperling
is it possible to change the html title from the WYSIWYG editor?
316588 by: Haluk Karamete
316590 by: Marc Guay
316594 by: Daniel Brown
316595 by: Daniel Brown
316596 by: Haluk Karamete
316598 by: Bastien
316599 by: Haluk Karamete
Re: What is the mnemonic for date()'s Day format?
316589 by: Matijn Woudt
316591 by: Marc Guay
316592 by: Dotan Cohen
316593 by: Dotan Cohen
Re: Swiftlet is quite possibly the smallest MVC framework you'll ever use.
316597 by: Elbert F
handle file_get_contents timeout including dns lookup time
316600 by: nik600
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Feb 13, 2012, at 4:10 AM, Stuart Dallas wrote:
> On 13 Feb 2012, at 06:28, Rui Hu wrote:
>
>> How PHP sets variables in $_SERVER, say, $DOCUMENT_ROOT? What should I know
>> if I want to modify $_SERVER myself?
>
> Once your script starts the superglobals are no different to any other
> variables, except that they're in scope at all times.
That's probably the reason why they are named "SuperGlobals". :-)
But to be more descriptive, these are simply globals that are predefined by php
-- see:
http://php.net/manual/en/language.variables.superglobals.php
I believe, (please show me otherwise) there are no "globals" in PHP other than
SuperGlobals.
Cheers,
tedd
_____________________
t...@sperling.com
http://sperling.com
--- End Message ---
--- Begin Message ---
you may find it weird, actually very weird, but is the following possible>
load up a post or page into the admin panel and place something like
this in to the editor;
<?php
//assume exec-PHP already active
$current_page_url_here = get_current_url();
echo "<a href='{$current_page_url_here}?var1=val1'>click me</a>";
if ( $_GET['var1']=='val1' )
{
//change the current post's html title to <title>val1</title>
without using javascript/jquery
}
?>
so when the visitor, clicks on the "click me", same page reloads but
this time, the title reads val1, and that's what search engines see
too.
and if it is also possible to change, the_title() to be equal to val1,
that's even better.
But, is such a thing technically possible? Or is it too late at that
time to make those changes?
Could ob_start in any shape or form be deployed here to achieve this goal?
--- End Message ---
--- Begin Message ---
Based on the terms you're using it sounds like this is a Wordpress
question. You'd have a lot better chances of getting an answer if you
query a group of WP gurus/geeks.
Marc
--- End Message ---
--- Begin Message ---
On Mon, Feb 13, 2012 at 15:50, Haluk Karamete <halukkaram...@gmail.com> wrote:
> you may find it weird, actually very weird, but is the following possible>
>
> load up a post or page into the admin panel and place something like
> this in to the editor;
>
> <?php
>
> //assume exec-PHP already active
>
> $current_page_url_here = get_current_url();
>
> echo "<a href='{$current_page_url_here}?var1=val1'>click me</a>";
>
> if ( $_GET['var1']=='val1' )
> {
> //change the current post's html title to <title>val1</title>
> without using javascript/jquery
> }
> ?>
>
> so when the visitor, clicks on the "click me", same page reloads but
> this time, the title reads val1, and that's what search engines see
> too.
> and if it is also possible to change, the_title() to be equal to val1,
> that's even better.
>
> But, is such a thing technically possible? Or is it too late at that
> time to make those changes?
> Could ob_start in any shape or form be deployed here to achieve this goal?
This is not a WYSIWYG editor question; WYSIWYG editors are things
like KompoZer, Dreamweaver, FrontPage, and even web-based things like
TinyMCE, et al.
That aside, try this very basic example (and expounded) and see if
it's what you're trying to achieve:
<?php
echo '<title>';
if (isset($_GET['title'])) {
echo $_GET['title'];
} else {
echo 'The title has not been set!';
}
echo '</title>'.PHP_EOL;
echo '<a
href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?title=Enter+your+title+here">Change
Title</a>'.PHP_EOL;
?>
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
On Mon, Feb 13, 2012 at 17:15, Haluk Karamete <halukkaram...@gmail.com> wrote:
Please keep the replies on the list for all to benefit, including
the archives.
> Isn't it TinyMCE considered a WYSIWYG one? but, anyway, that's beside
> the main point.
Indeed. Hence:
".... even web-based things like TinyMCE, et al."
> To your suggestion...
>
> I don't think your snippet would do any good as far as search
> engines... search engines would still take the title in the <head>.
> here, we are already in the the_content().
Did you understand what I meant by "very basic example?" You'd
need to modify your <title>.*</title> tag in the head, as well,
obviously. That's all quite logical, and well beyond the scope of the
initial question.
--
</Daniel P. Brown>
Network Infrastructure Manager
http://www.php.net/
--- End Message ---
--- Begin Message ---
Yeah, but n the context of wordpress, that does not fly.
If I do a die; in the middle of wp's tinymce editor, and check back
the page, the title is already out there.
first 5 lines would be something like
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>the wordpress page title we were trying toi change is already
here...</title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
But this question is a wp question. I accidentally dropped it in the PHP group.
On Mon, Feb 13, 2012 at 2:24 PM, Daniel Brown <danbr...@php.net> wrote:
> On Mon, Feb 13, 2012 at 17:15, Haluk Karamete <halukkaram...@gmail.com> wrote:
>
> Please keep the replies on the list for all to benefit, including
> the archives.
>
>> Isn't it TinyMCE considered a WYSIWYG one? but, anyway, that's beside
>> the main point.
>
> Indeed. Hence:
>
> ".... even web-based things like TinyMCE, et al."
>
>> To your suggestion...
>>
>> I don't think your snippet would do any good as far as search
>> engines... search engines would still take the title in the <head>.
>> here, we are already in the the_content().
>
> Did you understand what I meant by "very basic example?" You'd
> need to modify your <title>.*</title> tag in the head, as well,
> obviously. That's all quite logical, and well beyond the scope of the
> initial question.
>
> --
> </Daniel P. Brown>
> Network Infrastructure Manager
> http://www.php.net/
--- End Message ---
--- Begin Message ---
Bastien Koert
On 2012-02-13, at 5:34 PM, Haluk Karamete <halukkaram...@gmail.com> wrote:
> Yeah, but n the context of wordpress, that does not fly.
> If I do a die; in the middle of wp's tinymce editor, and check back
> the page, the title is already out there.
>
> first 5 lines would be something like
>
>
> <!DOCTYPE html>
> <html dir="ltr" lang="en-US">
> <head>
> <meta charset="UTF-8" />
> <title>the wordpress page title we were trying toi change is already
> here...</title>
> <link rel="profile" href="http://gmpg.org/xfn/11" />
>
> But this question is a wp question. I accidentally dropped it in the PHP
> group.
>
> On Mon, Feb 13, 2012 at 2:24 PM, Daniel Brown <danbr...@php.net> wrote:
>> On Mon, Feb 13, 2012 at 17:15, Haluk Karamete <halukkaram...@gmail.com>
>> wrote:
>>
>> Please keep the replies on the list for all to benefit, including
>> the archives.
>>
>>> Isn't it TinyMCE considered a WYSIWYG one? but, anyway, that's beside
>>> the main point.
>>
>> Indeed. Hence:
>>
>> ".... even web-based things like TinyMCE, et al."
>>
>>> To your suggestion...
>>>
>>> I don't think your snippet would do any good as far as search
>>> engines... search engines would still take the title in the <head>.
>>> here, we are already in the the_content().
>>
>> Did you understand what I meant by "very basic example?" You'd
>> need to modify your <title>.*</title> tag in the head, as well,
>> obviously. That's all quite logical, and well beyond the scope of the
>> initial question.
>>
>> --
>> </Daniel P. Brown>
>> Network Infrastructure Manager
>> http://www.php.net/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Any reason you can't just use JS to alter the title tag on the page loading?
--- End Message ---
--- Begin Message ---
Search engines would still be indexing the original page's title. I
need each unique URL to have its own unique, robot friendly title.
Again, this question is strictly within WP context.
On Mon, Feb 13, 2012 at 6:49 PM, Bastien <phps...@gmail.com> wrote:
>
>
> Bastien Koert
>
> On 2012-02-13, at 5:34 PM, Haluk Karamete <halukkaram...@gmail.com> wrote:
>
>> Yeah, but n the context of wordpress, that does not fly.
>> If I do a die; in the middle of wp's tinymce editor, and check back
>> the page, the title is already out there.
>>
>> first 5 lines would be something like
>>
>>
>> <!DOCTYPE html>
>> <html dir="ltr" lang="en-US">
>> <head>
>> <meta charset="UTF-8" />
>> <title>the wordpress page title we were trying toi change is already
>> here...</title>
>> <link rel="profile" href="http://gmpg.org/xfn/11" />
>>
>> But this question is a wp question. I accidentally dropped it in the PHP
>> group.
>>
>> On Mon, Feb 13, 2012 at 2:24 PM, Daniel Brown <danbr...@php.net> wrote:
>>> On Mon, Feb 13, 2012 at 17:15, Haluk Karamete <halukkaram...@gmail.com>
>>> wrote:
>>>
>>> Please keep the replies on the list for all to benefit, including
>>> the archives.
>>>
>>>> Isn't it TinyMCE considered a WYSIWYG one? but, anyway, that's beside
>>>> the main point.
>>>
>>> Indeed. Hence:
>>>
>>> ".... even web-based things like TinyMCE, et al."
>>>
>>>> To your suggestion...
>>>>
>>>> I don't think your snippet would do any good as far as search
>>>> engines... search engines would still take the title in the <head>.
>>>> here, we are already in the the_content().
>>>
>>> Did you understand what I meant by "very basic example?" You'd
>>> need to modify your <title>.*</title> tag in the head, as well,
>>> obviously. That's all quite logical, and well beyond the scope of the
>>> initial question.
>>>
>>> --
>>> </Daniel P. Brown>
>>> Network Infrastructure Manager
>>> http://www.php.net/
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Any reason you can't just use JS to alter the title tag on the page loading?
--- End Message ---
--- Begin Message ---
On Mon, Feb 13, 2012 at 7:52 PM, Dotan Cohen <dotanco...@gmail.com> wrote:
> From the fine manual [1]:
> l (lowercase 'L')
> A full textual representation of the day of the week
>
> I can never remember this one, and I use it occasionally. What is the
> mnemonic for "l"? How did this letter come to be chosen? Can anyone
> more creative than me think of a way to associate the lower case
> letter "l" with the full textual representation of the day of the
> week?
>
> Thanks!
>
>
> [1] http://il2.php.net/manual/en/function.date.php
>
> --
> Dotan Cohen
Hi,
I've been wondering where the letter was chosen from too, so I took
svn and got all the way back to revision 214 where the options was
first added. Note that this commit is June 7, 1996, and we're talking
about php2 (php/fi) here. I tried to look at mailing list archives,
but it seems that rasmus was pretty much developing PHP on it's own in
those days.
It seems that it has been added when cookie support was added, and for
the cookie to set a date they wanted a nicely printed day. It seems to
be just a choice from rasmus back in those days.
My best guess would be that the 'l' is chosen because it is the last
letter of 'full' in 'full name of day', though I don't understand why
'f' or 'F' wasn't chosen.
Well, try remembering the 'l' in 'full' if you need it the next time..;)
- Matijn
--- End Message ---
--- Begin Message ---
How about "long" dayname?
I find it interesting that the character for "Day of the month without
leading zeros" is j, which makes sense to me as a half-Francophone who
sometimes calls days "jours". Not that it helps me remember it, I
have to refer to that page pretty much every time I use date().
Marc
--- End Message ---
--- Begin Message ---
On Mon, Feb 13, 2012 at 22:51, Matijn Woudt <tijn...@gmail.com> wrote:
> Hi,
>
> I've been wondering where the letter was chosen from too, so I took
> svn and got all the way back to revision 214 where the options was
> first added. Note that this commit is June 7, 1996, and we're talking
> about php2 (php/fi) here. I tried to look at mailing list archives,
> but it seems that rasmus was pretty much developing PHP on it's own in
> those days.
> It seems that it has been added when cookie support was added, and for
> the cookie to set a date they wanted a nicely printed day. It seems to
> be just a choice from rasmus back in those days.
> My best guess would be that the 'l' is chosen because it is the last
> letter of 'full' in 'full name of day', though I don't understand why
> 'f' or 'F' wasn't chosen.
>
> Well, try remembering the 'l' in 'full' if you need it the next time..;)
>
You are some sleuth! Let me know first if you ever have any dirt on me, Matijn!
Thank you for the mnemonic "full". I'll know next week if it sticks or
not. Though, I already foresee myself trying to use "f"!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--- End Message ---
--- Begin Message ---
On Mon, Feb 13, 2012 at 23:04, Marc Guay <marc.g...@gmail.com> wrote:
> How about "long" dayname?
>
That makes sense. I now have two ways to remember. Thanks!
> I find it interesting that the character for "Day of the month without
> leading zeros" is j, which makes sense to me as a half-Francophone who
> sometimes calls days "jours". Not that it helps me remember it, I
> have to refer to that page pretty much every time I use date().
>
I also refer to that page enough to have it bookmarked on my homepage!
--
Dotan Cohen
http://gibberish.co.il
http://what-is-what.com
--- End Message ---
--- Begin Message ---
Hi Simon,
Moving the set_error_handler to index.php gives the developer the ability
to remove it before pushing the site to a production environment. I agree
that in most cases you don't want the live site to fail completely when it
trips over an unset variable but I prefer to have it on by default to
encourage good habits.
Moving the autoloader as well is a good idea but I'd need a copy of the
function wherever I bootstrap Swiftlet (e.g. tests). It doesn't seem worth
the trouble to avoid two require statements.
Plugins are quite simple and can indeed extend anything, including other
plugins.
Elbert
http://swiftlet.org
> Hi, Elbert
>
> I personally would remove the set_error_handler completely. This is a
> configuration that the administrator has to handle himself. In a
> development-env they want to see all errors, warnings etc, yes - even a
> strict_notice. But in a production-env they dont want to show anything to
> the user - just show a general error if something really heavy happened.
> You can put that in the index.php but I'd wrap it in comments or remove
it.
>
> In my opinion it's a good idea to move the autoloader into the index.php.
> Then you can even call your app class using the autoloader ;)
>
> I'm just curious what exactly you want to try with the plugins ... Should
> they simply be extensions or also possibilities to extend other plugins? I
> also wrote my own framework 3 years ago and was more about making things
> way more complex than they could be just to think about maximum
flexibility
> ..
>
> I pretty much also like the no-config part.
> http://en.wikipedia.org/wiki/Convention_over_configuration
>
>
> Bye
> Simon
>
> 2012/2/12 Elbert F <i...@elbertf.com>
>
>> Hi Simon,
>>
>> I think you're right that I may be abusing the constructor a bit. I'm
>> going to follow your suggestion and split it up into smaller functions.
I'm
>> also thinking of moving the set_error_handler and spl_autoload_register
>> functions to index.php where Swiftlet is bootstrapped so they can be
>> changed.
>>
>> You make another good point about the model; it's never supposed to
access
>> the controller or view. I updated the code to reflect this. It should
work
>> like your second flowchart<
http://betterexplained.com/wp-content/uploads/rails/mvc-rails.png>(perhaps
with the added concept of plugins, which can hook into anything).
>>
>> Symfony's routing is nice, many smaller frameworks take a similar
approach
>> (e.g. Sinatra <http://www.sinatrarb.com/> and ToroPHP<http://toroweb.org/
>).
>> However, I like the fact that Swiftlet requires no configuration. Just
drop
>> in your class and it works. The file structure and classes already do a
>> good job describing themselves.
>>
>> Excellent feedback, thanks!
>>
>> Elbert
>>
>>
>>
>> On Sun, Feb 12, 2012 at 10:53 PM, Simon Schick <
>> simonsimc...@googlemail.com> wrote:
>>
>>> Hi, Elbert
>>>
>>> I've looked through the code and found it quite tiny :) I like that.
>>>
>>> Until now I found some things that I'd like to discuss with you:
>>>
>>> In the class App you're doing all the stuff (routing, calling the
>>> constructor aso) in the constructor. Would it not be better to have
>>> separate functions for that? I like the way I learned from using Java:
The
>>> constructor is only for initializing the variables you need to execute
the
>>> other functions of this class.
>>> Of course you can have a function that then calls all those small
>>> functions and maybe directly return the output.
>>>
>>> I dislike the way you treat with the model .. currently it gets the
>>> controller, the view and the app itself. If you ask me the model only
needs
>>> some configuration. I cannot come up with an idea where you'd need more
>>> than a connection-string and some additional settings. The model has
>>> several methods to gather the data that has been requested and gives it
>>> back. If you'd ask me, there's no need for interaction with the app,
>>> controller or view.
>>>
>>> I'd like to see an option for the router like the one I've seen in
>>> symfony2 ... that was quite nice .. There you can define a regexp that
>>> should match the called url, some variables that should be extracted
from
>>> that and some default-variables. It's quite hard to explain in the short
>>> term, but take a look at their documentation:
>>> http://symfony.com/doc/current/book/routing.html
>>>
>>> I'd like you to create a small workflow what your framework is doing in
>>> which order. Your framework to me looks like this image:
>>> http://imageshack.us/f/52/mvcoriginal.png/ But I'd rethink if this
>>> structure would give you more flexibility:
>>> http://betterexplained.com/wp-content/uploads/rails/mvc-rails.png
>>>
>>> I hope you got some input here you can work with. I'd like to hear your
>>> feedback.
>>>
>>> Bye
>>> Simon
>>>
>>>
>>> 2012/2/12 Elbert F <i...@elbertf.com>
>>>
>>>> I'm looking for constructive feedback on Swiftlet, a tiny MVC framework
>>>> that leverages the OO capabilities of PHP 5.3. It's intentionally
>>>> featureless and should familiar to those experienced with MVC. Any
>>>> comments
>>>> on architecture, code and documentation quality are very welcome.
>>>>
>>>> Source code and documentation: http://swiftlet.org
--- End Message ---
--- Begin Message ---
Dear all
i'm trying to handle a max timeout into a file_get_contents request,
this is my code:
******* client.php ******* placed on http://test.foo.com/client.php
<?php
ini_set('default_socket_timeout',10);
$ctx = stream_context_create(array('http' => array('timeout' => 10)));
$data = file_get_contents("http://www.foo.com/server.php",0,$ctx);
if(!data){
die("error during page request");
}else{
echo "OK";
echo $data;
}
?>
******* server.php ******* placed on www.foo.com at
http://www.foo.com/server.php
<?php
sleep(15);
echo "OK";
?>
i've noticed that in a standard scenario if i call
http://test.foo.com/client.php all works properly and the timeout is
handled correctly.
But, if i'm experiencing dns lookup problems, the timeout setting is
ignored by file_get_contents, or more probably the socket isn't yet
estabilished so the counter for timeout doesn't start.
I've been able to reproduce this problem on a linux server dropping
incoming packets of DNS with this command: (be careful, it will
disable you ability to resolve all dns address!):
* iptables -A INPUT -p udp --sport 53 -j DROP
* iptables -A INPUT -p tcp --sport 53 -j DROP
So, the question is:
is possible to have a timeout check that includes also dns resolution time?
Thanks to all in advance
--- End Message ---