Re: [PHP] What's the best way to make a dynamic plugin architecture?
On 26 Aug 2012, at 19:42, Mark mark...@gmail.com wrote: Envision the following plugin architecture: class PluginLoader { } interface PluginInterface { .. some function definitions .. } class PluginOne implements PluginInterface { } class PluginTwo implements PluginInterface { } The PluginLoader is loading the plugins. The PluginInterface defines an interface which each plugin has to implement. PluginOne and PluginTwo are plugins that implement the interface. Each plugin (PluginOne and PluginTwo) are stored in their own folders. So the folder structure would be somewhat like this: |- Plugins |- - PluginOne |- - - PluginOne.php |- - - other possible files |- - PluginTwo |- - - PluginTwo.php |- - - other possible files |- PluginLoader.php |- PluginInterface.php Now making this structure isn't an issue. I can do all of that just fine. The place where i'm actually going to make a plugin instance is where things get a little more complicated. The PluginLoader simply reads all the dirs in the Plugins folder and tries to find a filename with the same dir. So if it reads the dir Plugins/PluginOne it will try to include the PHP file: Plugins/PluginOne/PluginOne.php. That's fine and working. To actually make a plugin instance i can do two things that i know of: 1. use eval like so: eval('$obj = new '.$pluginName.'();'); and register it to the PluginLoader. No need to use eval, you can simply do this: $obj = new $pluginName(); See here: http://php.net/language.variables.variable 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? Now my question is: what is the right way of loading plugins like this? Is there some other option then the two i described above? My PHP limitations are the newest version so no limitation there :) I'm kinda leaning towards the second option now since that seems to be quite stable and not very error prone. The eval one is much easier to break :p If you're happy for each plugin to be in a separate directory then what you have in option 1, minus the eval, will work perfectly well. I don't know what your use case is but if there's a chance a single plugin might want to provide several classes then I'd require an init.php in each plugin folder and have that register the class names with the class loader. It could also then pass along some meta information such as a description of what each class does. If this is for use in web requests you might want to stick to what you currently have as there's a lot less overhead. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Movable Type (MT) *client*
I all, I'm looking for a Class or a PHP bundle in order to programatically fetch blog entries from a Dotclear Movable Type (MT) blog, with their tags, categories, all available attributes. I found http://goo.gl/JUbCN in order to almost do the job. I could deal with it, but I'm looking for a more out-of-the-box thing. Say for example, $the_blog = new MTBlog($usr, $pwd, $url); $tags=$the_blog-getTags(); $the_blog-getCategories(); $the_blog-getEntriesHavingTag($tags[3]); Thank you, if you ever have that in your bookmarks. -- RMA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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: Envision the following plugin architecture: class PluginLoader { } interface PluginInterface { .. some function definitions .. } class PluginOne implements PluginInterface { } class PluginTwo implements PluginInterface { } The PluginLoader is loading the plugins. The PluginInterface defines an interface which each plugin has to implement. PluginOne and PluginTwo are plugins that implement the interface. Each plugin (PluginOne and PluginTwo) are stored in their own folders. So the folder structure would be somewhat like this: |- Plugins |- - PluginOne |- - - PluginOne.php |- - - other possible files |- - PluginTwo |- - - PluginTwo.php |- - - other possible files |- PluginLoader.php |- PluginInterface.php Now making this structure isn't an issue. I can do all of that just fine. The place where i'm actually going to make a plugin instance is where things get a little more complicated. The PluginLoader simply reads all the dirs in the Plugins folder and tries to find a filename with the same dir. So if it reads the dir Plugins/PluginOne it will try to include the PHP file: Plugins/PluginOne/PluginOne.php. That's fine and working. To actually make a plugin instance i can do two things that i know of: 1. use eval like so: eval('$obj = new '.$pluginName.'();'); and register it to the PluginLoader. No need to use eval, you can simply do this: $obj = new $pluginName(); See here: http://php.net/language.variables.variable Ahh right, i completely forgot about that option. That might just work the way i want it :) 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. Now my question is: what is the right way of loading plugins like this? Is there some other option then the two i described above? My PHP limitations are the newest version so no limitation there :) I'm kinda leaning towards the second option now since that seems to be quite stable and not very error prone. The eval one is much easier to break :p If you're happy for each plugin to be in a separate directory then what you have in option 1, minus the eval, will work perfectly well. I don't know what your use case is but if there's a chance a single plugin might want to provide several classes then I'd require an init.php in each plugin folder and have that register the class names with the class loader. It could also then pass along some meta information such as a description of what each class does. If this is for use in web requests you might want to stick to what you currently have as there's a lot less overhead. Yeah, if i extend it more that will certainly be an requirement. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Thank you for your advice, really appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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. Thank you for your advice, really appreciated. No probs. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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. Thank you for your advice, really appreciated. No probs. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] multiple forms one page
On Aug 27, 2012, at 12:08 AM, Rosie Williams rosiemariewilli...@hotmail.com wrote: Hi all, I am a newbie to PHP. I have several php forms which were originally on separate pages now included in the one page. Each form had the following code in it: function mysql_fix_string($string){ if (get_magic_quotes_gpc()) $string = stripslashes($string);return mysql_real_escape_string($string);} function mysql_entities_fix_string($string){ return htmlentities(mysql_fix_string($string));} However I am only able to include it in one of the forms on the new page with multiple scripts due to the fatal error that I can only declare the function once. So for testing I have commented these lines out of the other scripts. I need to know what the security implications of this are? Do the scripts that do not contain these lines run without it or is it included automatically every time the database is accessed regardless of which script is accessing it? If not how do I deal with it? thanks in advanceRosie My advice -- place your common functions into one file (i.e., functions.php) and: include_once(includes/functions.php); At the start of every script that needs any of the functions contained therein. As for rolling several forms into one, here are some of the ways I do it: http://sperling.com/php/step/ http://sperling.com/php/submit/ Cheers, tedd PS: If anyone see's anything in error, please feel free to correct me. As a very talented harmonica player once said Sometimes I suck and sometime I blow. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] syntax error breaking in and out of php into html code
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get question
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: get question
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 - . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: get question
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
[PHP] Error connecting with DB
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
[PHP] include selectively or globally?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: get question
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Cannot retrieve KRB5CCNAME if logged in with kerberos ticket
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 titlePHP Test/title /head body h1PHP 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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Error connecting with DB
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include selectively or globally?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: get question
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
Re: [PHP] What's the best way to make a dynamic plugin architecture?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: [modauthkerb] Cannot retrieve KRB5CCNAME if logged in with kerberos ticket
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 titlePHP Test/title /head body h1PHP 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: get question
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? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] include selectively or globally?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php