php-general Digest 28 Aug 2012 06:03:41 -0000 Issue 7940

Topics (messages 318879 through 318897):

Re: syntax error breaking in and out of php into html code
        318879 by: Tedd Sperling

get question
        318880 by: Jack S
        318881 by: Jim Giner
        318882 by: Ashley Sheridan
        318885 by: Jim Lucas
        318892 by: Ashley Sheridan
        318895 by: Jim Giner

Error connecting with DB
        318883 by: Rod Lindgren
        318888 by: Rod Lindgren

include selectively or globally?
        318884 by: Haluk Karamete
        318889 by: Matijn Woudt
        318896 by: Adam Richardson
        318897 by: tamouse mailing lists

Re: What's the best way to make a dynamic plugin architecture?
        318886 by: Mark
        318890 by: Larry Garfield
        318891 by: Matijn Woudt
        318893 by: Larry Garfield

Cannot retrieve KRB5CCNAME if logged in with kerberos ticket
        318887 by: Mauricio Tavares

Re: [modauthkerb] Cannot retrieve KRB5CCNAME if logged in with kerberos ticket
        318894 by: Benjamin Kahn

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 Aug 26, 2012, at 1:36 PM, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> Well, it turns out that I'm just an idiot...
> -- 
> Thanks,
> Ash

That was easy -- anyone of us could have told you that. :-)

Cheers,

tedd

PS: We all have our time in the barrel.

_____________________
t...@sperling.com
http://sperling.com


--- End Message ---
--- Begin Message ---
Hello All,

Trying to figure out why when I include the page that contains this
code, I'm not able to get the $calling_page populated with any values.
Any help appreciated...


<?
# Dynamic Content based in page
$calling_page = $_GET['page'];

# Home Page 
------------------------------------------------------------------------------------------------------------------------------
if(!($calling_page)) {
        $title = "Title 1 - $calling_page";
                $body = "<body />";

} elseif ($calling_page == "index") {
        $title = "Title 2 - $calling_page";
                $body = "<body />";

# Non Specified Page
--------------------------------------------------------------------------------------------------------------
} else {
        $title = "Title 3 - $calling_page";
                $body = "<body />";

}

echo "<title>".$title."</title>";
?>


-- 
Thanks!
Joey

--- End Message ---
--- Begin Message ---
On 8/27/2012 3:17 PM, Jack S wrote:
Hello All,

Trying to figure out why when I include the page that contains this
code, I'm not able to get the $calling_page populated with any values.
Any help appreciated...


<?
# Dynamic Content based in page
$calling_page = $_GET['page'];

# Home Page 
------------------------------------------------------------------------------------------------------------------------------
if(!($calling_page)) {
         $title = "Title 1 - $calling_page";
                $body = "<body />";

} elseif ($calling_page == "index") {
         $title = "Title 2 - $calling_page";
                $body = "<body />";

# Non Specified Page
--------------------------------------------------------------------------------------------------------------
} else {
         $title = "Title 3 - $calling_page";
                $body = "<body />";

}

echo "<title>".$title."</title>";
?>


Since this code does nothing other than assign a value to $calling_page based upon the content of a GET variable, what do you mean by "not able to get the $calling_page populated with any values.".

Are you simply saying that "$calling_page does not have a value assigned to it"? And if that is what you meant to say, then the answer is that your GET array does not contain an index of 'page'. Of course, even if that were true, you would in fact have a value in $calling_page and it would be simply: "Title 1 - ".


--- End Message ---
--- Begin Message ---
On Mon, 2012-08-27 at 15:56 -0400, Jim Giner wrote:

> On 8/27/2012 3:17 PM, Jack S wrote:
> > Hello All,
> >
> > Trying to figure out why when I include the page that contains this
> > code, I'm not able to get the $calling_page populated with any values.
> > Any help appreciated...
> >
> >
> > <?
> > # Dynamic Content based in page
> > $calling_page = $_GET['page'];
> >
> > # Home Page 
> > ------------------------------------------------------------------------------------------------------------------------------
> > if(!($calling_page)) {
> >          $title = "Title 1 - $calling_page";
> >             $body = "<body />";
> >
> > } elseif ($calling_page == "index") {
> >          $title = "Title 2 - $calling_page";
> >             $body = "<body />";
> >
> > # Non Specified Page
> > --------------------------------------------------------------------------------------------------------------
> > } else {
> >          $title = "Title 3 - $calling_page";
> >             $body = "<body />";
> >
> > }
> >
> > echo "<title>".$title."</title>";
> > ?>
> >
> >
> Since this code does nothing other than assign a value to $calling_page 
> based upon the content of a GET variable, what do you mean by "not able 
> to get the $calling_page populated with any values.".
> 
> Are you simply saying that "$calling_page does not have a value assigned 
> to it"?  And if that is what you meant to say, then the answer is that 
> your GET array does not contain an index of 'page'.  Of course, even if 
> that were true, you would in fact have a value in $calling_page and it 
> would be simply: "Title 1 - ".
> 
> 


How are you including this in your code? GET data won't be passed in a
call like require("some_file.php?page=page");
-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 08/27/2012 01:26 PM, Ashley Sheridan wrote:
On Mon, 2012-08-27 at 15:56 -0400, Jim Giner wrote:

Also, as Ashley can attest, make sure that your able to run with short-tags enabled. Seeings how your code block starts with a short-tag. eg. '<?' Change this to <?php and see if you get the same results.

Sorry Ashley, had to point it out.

--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

--- End Message ---
--- Begin Message ---
On Mon, 2012-08-27 at 18:54 -0400, Jack S wrote:

> OK yes, <? works fine.
> In respect to errors I get:
> PHP Notice:  Undefined index: page
> in /home/WebSite.com/www/includes/header.php on line 8
> 
> Line 8 has the below line of code
> $calling_page = $_GET['page'];
> 
> 
> 
> 
> On Mon, Aug 27, 2012 at 4:47 PM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
> 
>         On Mon, 2012-08-27 at 16:37 -0400, Jack S wrote: 
>         
>         > > How are you including this in your code? GET data won't be passed 
> in a
>         > > call like require("some_file.php?page=page");
>         > > --
>         > > Thanks,
>         > > Ash
>         > > http://www.ashleysheridan.co.uk
>         > >
>         > >
>         > 
>         > Hi Ash,
>         > 
>         > The index.php file has an include statement like so:
>         > <?php include_once 
> $_SERVER['DOCUMENT_ROOT'].'/includes/header.php'; ?>
>         > 
>         > The code snipet is at the top of the header file.
>         > I have done this before and it worked, just can't seem to figure out
>         > what is wrong here.
>         > 
>         > Thanks!
>         > 
>         > 
>         > 
>         > 
>         > 
>         
>         
>         
>         
>         Do you have errors and notices set to display, or have you
>         checked the error logs for anything? It could be that some
>         change in configuration is causing a problem with the include
>         itself.
>         
>         
>         -- 
>         Thanks,
>         Ash
>         http://www.ashleysheridan.co.uk
>         
>         
>         
> 
> 
> 
> 
> -- 
> Thanks!
> Jack


Are you passing a page parameter through the URL? The error is basically
complaining that you're not.


-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk



--- End Message ---
--- Begin Message ---
On 8/27/2012 7:21 PM, Ashley Sheridan wrote:
On Mon, 2012-08-27 at 18:54 -0400, Jack S wrote:

OK yes, <? works fine.
In respect to errors I get:
PHP Notice:  Undefined index: page
in /home/WebSite.com/www/includes/header.php on line 8

Line 8 has the below line of code
$calling_page = $_GET['page'];




On Mon, Aug 27, 2012 at 4:47 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:

         On Mon, 2012-08-27 at 16:37 -0400, Jack S wrote:

         > > How are you including this in your code? GET data won't be passed 
in a
         > > call like require("some_file.php?page=page");
         > > --
         > > Thanks,
         > > Ash
         > > http://www.ashleysheridan.co.uk
         > >
         > >
         >
         > Hi Ash,
         >
         > The index.php file has an include statement like so:
         > <?php include_once $_SERVER['DOCUMENT_ROOT'].'/includes/header.php'; 
?>
         >
         > The code snipet is at the top of the header file.
         > I have done this before and it worked, just can't seem to figure out
         > what is wrong here.
         >
         > Thanks!
         >
         >
         >
         >
         >




         Do you have errors and notices set to display, or have you
         checked the error logs for anything? It could be that some
         change in configuration is causing a problem with the include
         itself.


         --
         Thanks,
         Ash
         http://www.ashleysheridan.co.uk







--
Thanks!
Jack


Are you passing a page parameter through the URL? The error is basically
complaining that you're not.



So - is this INDEX.PHP script being called by a form on the client screen that has a field with the name of 'page'? And is the script (INDEX.PHP) being called via a GET method (and not a POST) in the <form> tag of the currently displayed page?
--- End Message ---
--- Begin Message ---
I need some help. I was cleaning up files on my server yesterday and deleted
some files I should not have. One of my websites,
www.ancientempires-tours.com has a problem with one section. The subdomain
www.egypt.ancientempires-tours.com, is having a problem connecting with the
database. I need some help to fix this. 

Thank you,

Rod Lindgren 



--- End Message ---
--- Begin Message ---
I agree, but how do I fix it. Everywhere I look, it is pointing to
/home/rodtsd/public_html/Egypt

I decided to uninstall and do a fresh reinstall. This works, but now I have
to find a way to get the old webpage data back on the screen. I can
currently only display the default page and its links. 

Sensei Rod Lindgren 

@KarateClub_us

 

 Rod Lindgren


-----Original Message-----
From: Volmar Machado [mailto:qi.vol...@gmail.com] 
Sent: Monday, August 27, 2012 3:12 PM
To: r...@okinawa-te.info
Subject: Re: [PHP] Error connecting with DB

In the first image you have softaculous pointing to
[/home/rodtsd/public_html/Egypt/egypt]
So that could be the cause.

2012/8/27 Rod Lindgren <r...@okinawa-te.info>:ir
> Found logs:
>
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> [Mon Aug 27 16:22:08 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/jordan/404.shtml
> [Mon Aug 27 16:22:08 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/jordan/favicon.ico
> [Mon Aug 27 16:22:08 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/jordan/404.shtml
> [Mon Aug 27 16:22:08 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/jordan/favicon.ico
> [Mon Aug 27 16:21:39 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/ancientempires-tours.com/404.shtml
> [Mon Aug 27 16:21:39 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/ancientempires-tours.com/favicon.ico
> [Mon Aug 27 16:21:38 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/ancientempires-tours.com/404.shtml
> [Mon Aug 27 16:21:38 2012] [error] [client 109.222.227.210] File does not
> exist: /home/rodtsd/public_html/ancientempires-tours.com/favicon.ico
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
> [Mon Aug 27 16:14:04 2012] [error] [client 65.52.110.151] File does not
> exist: /home/rodtsd/public_html/Okinawa-te.info/404.shtml
> [Mon Aug 27 16:14:04 2012] [error] [client 65.52.110.151] File does not
> exist: /home/rodtsd/public_html/Okinawa-te.info/Video.html
> Warning: DocumentRoot [/home/rodtsd/public_html/Egypt/egypt] does not
exist
>
> Not sure why it is trying to go to /home/rodtsd/public_html/Egypt/egypt.
The
> subdomain is set to /home/rodtsd/public_html/Egypt.
>
>  Rod Lindgren
>
>
> -----Original Message-----
> From: Volmar Machado [mailto:qi.vol...@gmail.com]
> Sent: Monday, August 27, 2012 2:10 PM
> To: r...@okinawa-te.info
> Subject: Re: [PHP] Error connecting with DB
>
> server logs
>
> 2012/8/27 Rod Lindgren <r...@okinawa-te.info>:
>> I need some help. I was cleaning up files on my server yesterday and
> deleted
>> some files I should not have. One of my websites,
>> www.ancientempires-tours.com has a problem with one section. The
subdomain
>> www.egypt.ancientempires-tours.com, is having a problem connecting with
> the
>> database. I need some help to fix this.
>>
>> Thank you,
>>
>> Rod Lindgren
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12
> -----
> No virus found in this message.
> Checked by AVG - www.avg.com
> Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12
-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1424 / Virus Database: 2437/5227 - Release Date: 08/27/12


--- End Message ---
--- Begin Message ---
With this question, I aim to understand the inner workings of PHP a
little better.

Assume that you got a 50K library. The library is loaded with a bunch
of handy functions that you use here and there. Also assume that these
functions are needed/used by say 10% of the pages of your site. But
your home page definitely needs it.

Now, the question is... should you use a global include that points to
this library - across the board - so that ALL the pages ( including
the 90% that do not need the library ) will get it, or should you
selectively add that include reference only on the pages you need?

Before answering this question, let me point "why" I ask this question...

When you include that reference, PHP may be caching it. So the
performance hit I worry may be one time deal, as opposed to every
time. Once that one time out of the way, subsequent loads may not be
as bad as one might think. That's all because of the smart caching
mechanisms that PHP deploys - which I do not have a deep knowledge of,
hence the question...

Since the front page needs that library anyway, the argument could be
why not keep that library warm and fresh in the memory and get it
served across the board?

When answering this question, please approach the matter strictly from
a caching/performance point of view, not from a convenience point of
view just to avoid that the discussion shifts to a programming style
and the do's and don'ts.

Thank you

http://stackoverflow.com/questions/12148966/include-selectively-or-globally

--- End Message ---
--- Begin Message ---
On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
<halukkaram...@gmail.com> wrote:
> With this question, I aim to understand the inner workings of PHP a
> little better.
>
> Assume that you got a 50K library. The library is loaded with a bunch
> of handy functions that you use here and there. Also assume that these
> functions are needed/used by say 10% of the pages of your site. But
> your home page definitely needs it.
>
> Now, the question is... should you use a global include that points to
> this library - across the board - so that ALL the pages ( including
> the 90% that do not need the library ) will get it, or should you
> selectively add that include reference only on the pages you need?
>
> Before answering this question, let me point "why" I ask this question...
>
> When you include that reference, PHP may be caching it. So the
> performance hit I worry may be one time deal, as opposed to every
> time. Once that one time out of the way, subsequent loads may not be
> as bad as one might think. That's all because of the smart caching
> mechanisms that PHP deploys - which I do not have a deep knowledge of,
> hence the question...
>
> Since the front page needs that library anyway, the argument could be
> why not keep that library warm and fresh in the memory and get it
> served across the board?
>
> When answering this question, please approach the matter strictly from
> a caching/performance point of view, not from a convenience point of
> view just to avoid that the discussion shifts to a programming style
> and the do's and don'ts.
>
> Thank you
>
> http://stackoverflow.com/questions/12148966/include-selectively-or-globally

Since searching for files is one of the most expensive (in time)
operations, you're probably best off with only a single PHP file. PHP
parses a file initially pretty quickly (it's only checking syntax half
on load), so unless you're having a 100MHz CPU with SSD drive, I'd say
go with a single PHP file. If you make sure the file isn't fragmented
over your disk, it should load pretty quick to memory. I'm not sure if
PHP caches that much, but if you really care, take a look at memcached
or APC.

- Matijn

--- End Message ---
--- Begin Message ---
On Mon, Aug 27, 2012 at 6:54 PM, Matijn Woudt <tijn...@gmail.com> wrote:
> On Mon, Aug 27, 2012 at 10:56 PM, Haluk Karamete
> <halukkaram...@gmail.com> wrote:
>>
>> Now, the question is... should you use a global include that points to
>> this library - across the board - so that ALL the pages ( including
>> the 90% that do not need the library ) will get it, or should you
>> selectively add that include reference only on the pages you need?
>>
>
> Since searching for files is one of the most expensive (in time)
> operations, you're probably best off with only a single PHP file.

Maybe I misinterpreted the question, but I don't think I agree.

If you have a 50K PHP file that's only needed in only 10% of the
pages, then, when solely considering performance, that file should
only be included on the 10% of the pages that actually use the file.
Now, there are reasons where you might want to include the file
globally (maintenance purposes, etc.) Loading the 50K of PHP code
requires building up all of the associated infrastructure (zvals,
etc.) for the user code (even if APC is used, the cached opcode/PHP
bytecode still has to be parsed and built up for the user-defined
classes and functions per request, even if they're unused), is
certainly going to perform more slowly than selectively including the
library on only the pages that need the library.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com

--- End Message ---
--- Begin Message ---
What do your performance measurements show so you have actual data
comparisons to make a valid decsion?

--- End Message ---
--- Begin Message ---
On Mon, Aug 27, 2012 at 4:26 PM, Stuart Dallas <stu...@3ft9.com> wrote:
> On 27 Aug 2012, at 14:52, Mark <mark...@gmail.com> wrote:
>
>> On Mon, Aug 27, 2012 at 3:46 PM, Stuart Dallas <stu...@3ft9.com> wrote:
>>> On 27 Aug 2012, at 14:29, Mark <mark...@gmail.com> wrote:
>>>
>>>> On Mon, Aug 27, 2012 at 12:41 PM, Stuart Dallas <stu...@3ft9.com> wrote:
>>>>> On 26 Aug 2012, at 19:42, Mark <mark...@gmail.com> wrote:
>>>>>
>>>>>> 2. Let the plugin itself (so in this case PluginOne.php) open itself
>>>>>> and register it to the PluginLoader.
>>>>>>
>>>>>> With the first option i have to do eval which i try to avoid if possible.
>>>>>> With the second solution the PluginLoader probably has to be a 
>>>>>> singlethon.
>>>>>
>>>>> Why does it need to be a singleton?
>>>>
>>>> Well, i would then do something like this from within the included
>>>> plugin file after the class:
>>>> PluginLoader::getInstance()->registerPlugin(new PluginOne());
>>>>
>>>> Or something alike.
>>>
>>> I'm not sure I see what PluginLoader is doing? It makes more sense to me if 
>>> you register like so:
>>>
>>> PluginLoader::getInstance()->registerPlugin('PluginOne');
>>>
>>> Then you get an instance of the plugin:
>>>
>>> $plugin = PluginLoader::getInstance()->factory('PluginOne');
>>>
>>> Tho, even then I don't see what the PluginLoader is adding to the party.
>>
>> Well, i'm making the classes up as i type. I don't actually have a
>> PluginLoader yet. Or rather, i'm just beginning to make it right now.
>> What it's doing is very simple. Read through the directory of the
>> plugins and load every single plugin it finds in memory. Then every
>> plugin registers the mime types it can handle. That information is
>> stored in the PluginLoader upon which some other place can call:
>> PluginLoader::pluginForMime("text/html"). Though i still have to take
>> a good look at that.
>>
>> But you're right, i can use the factory pattern here.
>
>
> Ahh, I see. Personally I'd go with the following (pseudocode)...
>
> Inside the PluginLoader constructor (or other method)
>   foreach (plugindir)
>     require plugindir/plugindir.php
>     $plugindir::init($this)
>
> The static init() method calls PluginLoader::registerPlugin('mime/type', 
> 'PluginClassName'). Then pluginForMime does a lookup for the mime type and 
> returns an object of the corresponding type. That way a single plugin can 
> support multiple mime types.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/

That sounds sane and i probably go for that :)
Thanks for clarifying it a little.

--- End Message ---
--- Begin Message ---
On 8/27/12 4:09 PM, Mark wrote:
On Mon, Aug 27, 2012 at 4:26 PM, Stuart Dallas <stu...@3ft9.com> wrote:

2. Let the plugin itself (so in this case PluginOne.php) open itself
and register it to the PluginLoader.

With the first option i have to do eval which i try to avoid if possible.
With the second solution the PluginLoader probably has to be a singlethon.

Why does it need to be a singleton?

Well, i would then do something like this from within the included
plugin file after the class:
PluginLoader::getInstance()->registerPlugin(new PluginOne());

Or something alike.

I'm not sure I see what PluginLoader is doing? It makes more sense to me if you 
register like so:

PluginLoader::getInstance()->registerPlugin('PluginOne');

Then you get an instance of the plugin:

$plugin = PluginLoader::getInstance()->factory('PluginOne');

Tho, even then I don't see what the PluginLoader is adding to the party.

Well, i'm making the classes up as i type. I don't actually have a
PluginLoader yet. Or rather, i'm just beginning to make it right now.
What it's doing is very simple. Read through the directory of the
plugins and load every single plugin it finds in memory. Then every
plugin registers the mime types it can handle. That information is
stored in the PluginLoader upon which some other place can call:
PluginLoader::pluginForMime("text/html"). Though i still have to take
a good look at that.

But you're right, i can use the factory pattern here.


Ahh, I see. Personally I'd go with the following (pseudocode)...

Inside the PluginLoader constructor (or other method)
   foreach (plugindir)
     require plugindir/plugindir.php
     $plugindir::init($this)

The static init() method calls PluginLoader::registerPlugin('mime/type', 
'PluginClassName'). Then pluginForMime does a lookup for the mime type and 
returns an object of the corresponding type. That way a single plugin can 
support multiple mime types.

-Stuart

--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

That sounds sane and i probably go for that :)
Thanks for clarifying it a little.

You should never be calling require() yourself. Just follow the PSR-0 naming standard and use an autoloader, then you don't have to even think about it. There are many existing autoloaders you can use, including Composer's, Symfony2's, and probably Zend has one as well.

Also, the key question is how you'll be mapping your situation to the plugin you need. If it's fairly hard-coded (i.e., "mime type of foo => class Bar"), then just use a simple dependency injection container like Pimple. If it's more complex and situational, then yes a factory is the easiest approach.

--Larry Garfield

--- End Message ---
--- Begin Message ---
On Tue, Aug 28, 2012 at 12:58 AM, Larry Garfield <la...@garfieldtech.com> wrote:
> On 8/27/12 4:09 PM, Mark wrote:
>>
>> On Mon, Aug 27, 2012 at 4:26 PM, Stuart Dallas <stu...@3ft9.com> wrote:
>
>
>>>>>>>> 2. Let the plugin itself (so in this case PluginOne.php) open itself
>>>>>>>> and register it to the PluginLoader.
>>>>>>>>
>>>>>>>> With the first option i have to do eval which i try to avoid if
>>>>>>>> possible.
>>>>>>>> With the second solution the PluginLoader probably has to be a
>>>>>>>> singlethon.
>>>>>>>
>>>>>>>
>>>>>>> Why does it need to be a singleton?
>>>>>>
>>>>>>
>>>>>> Well, i would then do something like this from within the included
>>>>>> plugin file after the class:
>>>>>> PluginLoader::getInstance()->registerPlugin(new PluginOne());
>>>>>>
>>>>>> Or something alike.
>>>>>
>>>>>
>>>>> I'm not sure I see what PluginLoader is doing? It makes more sense to
>>>>> me if you register like so:
>>>>>
>>>>> PluginLoader::getInstance()->registerPlugin('PluginOne');
>>>>>
>>>>> Then you get an instance of the plugin:
>>>>>
>>>>> $plugin = PluginLoader::getInstance()->factory('PluginOne');
>>>>>
>>>>> Tho, even then I don't see what the PluginLoader is adding to the
>>>>> party.
>>>>
>>>>
>>>> Well, i'm making the classes up as i type. I don't actually have a
>>>> PluginLoader yet. Or rather, i'm just beginning to make it right now.
>>>> What it's doing is very simple. Read through the directory of the
>>>> plugins and load every single plugin it finds in memory. Then every
>>>> plugin registers the mime types it can handle. That information is
>>>> stored in the PluginLoader upon which some other place can call:
>>>> PluginLoader::pluginForMime("text/html"). Though i still have to take
>>>> a good look at that.
>>>>
>>>> But you're right, i can use the factory pattern here.
>>>
>>>
>>>
>>> Ahh, I see. Personally I'd go with the following (pseudocode)...
>>>
>>> Inside the PluginLoader constructor (or other method)
>>>    foreach (plugindir)
>>>      require plugindir/plugindir.php
>>>      $plugindir::init($this)
>>>
>>> The static init() method calls PluginLoader::registerPlugin('mime/type',
>>> 'PluginClassName'). Then pluginForMime does a lookup for the mime type and
>>> returns an object of the corresponding type. That way a single plugin can
>>> support multiple mime types.
>>>
>>> -Stuart
>>>
>>> --
>>> Stuart Dallas
>>> 3ft9 Ltd
>>> http://3ft9.com/
>>
>>
>> That sounds sane and i probably go for that :)
>> Thanks for clarifying it a little.
>
>
> You should never be calling require() yourself.  Just follow the PSR-0
> naming standard and use an autoloader, then you don't have to even think
> about it.  There are many existing autoloaders you can use, including
> Composer's, Symfony2's, and probably Zend has one as well.
>

I believe there's one in PHP by default now called SPLClassLoader or
something like that..

- Matijn

--- End Message ---
--- Begin Message ---
On 8/27/12 6:11 PM, Matijn Woudt wrote:

You should never be calling require() yourself.  Just follow the PSR-0
naming standard and use an autoloader, then you don't have to even think
about it.  There are many existing autoloaders you can use, including
Composer's, Symfony2's, and probably Zend has one as well.


I believe there's one in PHP by default now called SPLClassLoader or
something like that..

- Matijn

There was a proposal for one, but it was never added. You still need a user-space class loader for PSR-0, but they're readily available.

--Larry Garfield

--- End Message ---
--- Begin Message ---
Quick-n-easy question: I have my apache virtual host configured to use
kerberos authentication:

        <Location />
                AuthType KerberosV5
                KrbAuthRealms DOMAIN.COM
                KrbServiceName HTTP
                Krb5Keytab /etc/apache2/krb5.keytab
                KrbMethodNegotiate on
                KrbMethodK5Passwd on
                KrbAuthoritative off
                KrbSaveCredentials on
                Require valid-user
        </Location>

And then I created the following test page:

<html>
<head>
        <title>PHP Test</title>
</head>
<body>
        <h1>PHP Kerberos Test</h1>
<?php
        echo "user = {$_SERVER['PHP_AUTH_USER']}<br/>";
        echo "REMOTE_USER={$_SERVER['REMOTE_USER']}<br/>";
        putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");
        echo "KRB5CCNAME={$_SERVER['KRB5CCNAME']}<br/>";

        exit();
?>
  </body>
</html>

And I have mod_auth_kerb php5 modules enabled in apache. When I try to
connect to the above test page using a kerberos ticket, I do see the
PHP_AUTH_USER and REMOTE_USER (which are the same). But I get nothing
in KRB5CCNAME. Now, if I destory my kerberos ticket and login using
kerberos user/pw, At first I do get the filename associated with
KRB5CCNAME. But, if I wait less than 15s to refresh the page, I get
nothing for KRB5CCNAME; if I wait more than 15s, I will get the
filename for KRB5CCNAME.

Does anyone know what I may be doing wrong?

--- End Message ---
--- Begin Message ---
Maybe you are hitting this bug?

https://bugzilla.redhat.com/show_bug.cgi?id=687975 
mod_auth_kerb using krb5passwd and keepalive and credential delegation
loses delegation after first request on connection

On Mon, 2012-08-27 at 17:29 -0400, Mauricio Tavares wrote:
> Quick-n-easy question: I have my apache virtual host configured to use
> kerberos authentication:
> 
>         <Location />
>                 AuthType KerberosV5
>                 KrbAuthRealms DOMAIN.COM
>                 KrbServiceName HTTP
>                 Krb5Keytab /etc/apache2/krb5.keytab
>                 KrbMethodNegotiate on
>                 KrbMethodK5Passwd on
>                 KrbAuthoritative off
>                 KrbSaveCredentials on
>                 Require valid-user
>         </Location>
> 
> And then I created the following test page:
> 
> <html>
> <head>
>         <title>PHP Test</title>
> </head>
> <body>
>         <h1>PHP Kerberos Test</h1>
> <?php
>         echo "user = {$_SERVER['PHP_AUTH_USER']}<br/>";
>         echo "REMOTE_USER={$_SERVER['REMOTE_USER']}<br/>";
>         putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");
>         echo "KRB5CCNAME={$_SERVER['KRB5CCNAME']}<br/>";
> 
>         exit();
> ?>
>   </body>
> </html>
> 
> And I have mod_auth_kerb php5 modules enabled in apache. When I try to
> connect to the above test page using a kerberos ticket, I do see the
> PHP_AUTH_USER and REMOTE_USER (which are the same). But I get nothing
> in KRB5CCNAME. Now, if I destory my kerberos ticket and login using
> kerberos user/pw, At first I do get the filename associated with
> KRB5CCNAME. But, if I wait less than 15s to refresh the page, I get
> nothing for KRB5CCNAME; if I wait more than 15s, I will get the
> filename for KRB5CCNAME.
> 
> Does anyone know what I may be doing wrong?
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> modauthkerb-help mailing list
> modauthkerb-h...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/modauthkerb-help



--- End Message ---

Reply via email to