An Implementation Of The Model-View-Controller Pattern In PHP
For those who you thought my method of implementing OO principles in PHP was
totally wrong - see http://www.tonymarston.co.uk/php-my...od-bad-oop.html
for details, you can now read
http://www.tonymarston.co.uk/php-my...controller.html and tell
me why my implementation of the MVC design pattern is totally wrong.
Go on, I dare you. Make my day.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Modify A Php File(model) With Php
I have an invoice model on my server! and i want to replace some field(like adresse, phone, price, VAT, ....) do you know a tools or class that allows those kind of manipulations
Using AJAX With A PHP Front Controller
I have a framework that uses the front controller design pattern for a single point of entry to the application and the autoload function for includes. I am trying to incorporate AJAX into the framework, but the javascript calls to php ignore my front controller code when instantiating classes.
RSA Implementation For PHP
Is there a RSA library for php available? Has somebody any samples to decrypt a encrypted message with the public key given in a certificate?
A PageRank Implementation
I am very proud to tell to folk that I have end a PHP implementation of PageRank. The source is free and could be use as you want.
Best Xmlrpc Implementation
Can anybody recommend the best xmlrpc library for php? My observations so far are that: * the PEAR XML_RPC package is undocumented * the php xmlrpc extensions are undocumented and require downloading extra code for the client functions * the usefulinc (http://xmlrpc.usefulinc.com/) is not supported by the php team
LRU Cache Implementation
Most of my application's operations (including SQL queries and numerical computation) can be cached. An LRU (least recently used) cache would fit the bill perfectly. This LRU cache should be preserved over multiple requests from the same session. If possible, it should be seen across multiple sessions so that all users can benefit from it. I can't implement either solution. In principle I could preserve the cache across multiple requests by using $_SESSION, but I don't think this would be wise. The whole structure would weigh on the order of a MB, so access would probably be really, really slow. Also consider that access to the cache must be serialized. I could in principle write the C code to do the caching. But this would be extremely ugly since I want to cache PHP objects, not C structures. There would also be the overhead of converting to and from PHP's representation.
Has Anyone Done An SMPP 3.4 Implementation Or 3.3 ?
I need some guidance please on SMPP. I am completly new on that. I wonder if PHP is going to be the right root to take. At the moment I am having a look on Net_SMPP from PEAR but it doesn't make a lot of sense Yet. I succeed int sending a message but I want to have a constant bind and get replies and reports if the messages sent have been delivered. Is it much different to develop PHP for comand line execution rather than the web ?
Correct Implementation Of Smbclient
I've got a real N00b question. I've been messing around with smbclient all day and I can get it to work from the commandline but not from my php script...i'm sure it's probably just an un-escaped character. PHP Code:
CMS - Category Page Implementation
I'm programming a basic CMS. Lets say there are three categories: Headline News Business News Local News I'd like there to be a category page which would display all of the content in that category. For example, on the "local news" page, I'd like it to display all the local news stories. I know how to implement it so far but the one twist is that I'd like it to display only say 10 stories a page. One could click on the next or previous page to see the next or previous ten stories.
Ldap And OpenLdap System Implementation
Did any one in here knows how to setup ldap server, I need to setup that kind of system in our network the idea is to collect all microsoft outlook address book and send to the ldap server. Also is there other alternative way to implement such system i have search some alternative to this and i search OpenLdap but it confuse me how can i send address book data directly and sycronized in OpenLdap system.
Plain PHP Implementation Of Hash Function
I have a problem compiling the hash function from PECL into my PHP. I get the error configure: error: C preprocessor "/lib/cpp" fails sanity check I would like to use a plain PHP implementation of these functions. Is there a library of them around?
-> PHP4 Singleton Implementation Question <-
I'm trying to implement a singleton in PHP4 but it doesn't seem to work. The object is recreated each time I call it. The goal of the class is to keep a variable up to date. It's used to display a database content, 25 rows at a time. The singleton keeps track of the current starting row and increases it or decreases it by 25 depending on the user action (pressing a Next or Prev button). Those buttons are submit buttons calling the current form itself. But each time I re-enter that form, the singleton variable is created again and therefore the currentRow variable reinitilized. Here is the code for the class called Welcome: --------------------------------------------- class Welcome { var $offsetRows = 25; var $currentRow ; // ************************************************** ******** // INSTANCE function to instanciate this class only once // ************************************************** ******** function &getInstance() { static $instance ; if( !$instance ) { $instance = new Welcome() ; } return $instance ; } // ************************************************** // CONSTRUCT function called when object is created // ************************************************** function Welcome() { $this->currentRow = 0 ; $this->offsetRows = 25 ; } // ************************************************** // SHOWRECORDS // Displays the actual table with info in rows. // ************************************************** function showRecords() { // my table display code here using $this->currentRow } // ************************************************** // NEXTRECORDS // Displays the next nn offset records // ************************************************** function nextRecords() { $this->currentRow += $this->offsetRows ; $this->showRecords() ; } // ************************************************** // PREVRECORDS // Displays the previous nn offset records if not at first // ************************************************** function prevRecords() { $this->currentRow -= $this->offsetRows ; if( $this->currentRows < 0 ) $this->currentRows = 0 ; $this->showRecords() ; } } Then my form works as follows: ------------------------------ <FORM action="<?=$_SERVER['PHP_SELF']?>" method="post"> <?php require_once( "class_welcome.php" ) ; if( !$welcome ) { $welcome =& Welcome::getInstance() ; } if(isset($_POST['next'])) { $welcome->nextRecords() ; } else { if(isset($_POST['previous'])) { $welcome->prevRecords() ; } else { $welcome->showRecords() ; } } ?> <P> <INPUT name="previous" type="submit" value="<<" /> <INPUT name="next" type="submit" value=">>" /> </FORM>
(Zend Engine) Array Implementation.
Does someone know how the array-type is implemented in Zend Engine? I would say it is a hashmap or a kind of vector, but since numeric AND string keys are possible I can't figure out how they made it. Does someone know about it or know a place where to get that information?
Php Configure File Not Present In Current LAMP Configuration - CURL Implementation
I run a few websites, and feel fairly confident about my PHP skills, but not so much with my Linux skills. We are running PHP 4.3.6, and I need to configure it to utilize cURL. I got cURL installed and configured on the server, but now I need to reconfigure PHP with the command: ./configure --with-mysql --with-apache=../apache_1.3.31 --with-curl=/usr/local/lib The only problem is that my confgure file is not present in the PHP directory. I'm not sure where to go with this. I'm trying to get the site set up to be able to connect to Authorize.net, and I can't get past this cURL problem. Does anyone have any idea what I need to do to get PHP configured to recognize the cURL functionality?
Url View
Is there a way using php to check what php script the user is viewing? If so how is it done?
Getting Name Of New Of View From MySQL 5.0+
We are using MySQL 5.0+ because it now supports views. However it appears that the PHP's(4.3) mysql_field_table() is returning a temporary name table name rather than the actual table (view) name. For instance we have a view defined as "open_meeetings_view", yet when we do a mysql_field_table() the name retrieved is "#sql_7a3a_1". The same call correctly retrieves all static tables and even aliases correctly. It does not appear that PHP has the ability to dig any deeper (maybe in PHP 5.0?), but does anyone know how to query MySQL for this information directly? A "show tables" does show the view names correctly. So we just need a way to correlate the temporary table "#sql_7a3a_1" back to the real view name "open_meeetings_view".
View Source
I was at amazon.com and clicked on View/Source, and I got a blank page. How did they do that?
Directory-View With PHP
I've programmed an access-control via header()-function. It checks an username and password in database ... nothing special. Currently, the control gives access to a download, but I would like to allow special users to view the complete directory. AFAIK this is only possibly through ".htaccess" (Apache webserver). But then, I need to create an entry for each user in the database in the file :-( Would it be possible to allow this direclty through PHP? Of course, I could write dynamically into htaccess, but if several users would access the file at the same time ... URGHS :-)
SQL VIEW Table
When I make a view table in mysql for as pre request from a client, does this table belongs to the this client only or all the clients who uses the server. My intension, i want to create exclusive "temp" tables for clients, where no other clients will be able to go into it.
View All Plus Pagination?
i have a online store that has about 2800+ products - on my productList.php pages I have a few variables to display the number of products per page: <?php $productsPerRow = 3; $productsPerPage = 27;my boss would like a view all button that sets $productsPerPage to the total number of products - and is active for as long as the SESSION (Perhaps unless the button is clicked again?) Any Ideas on the best approach to accomplish this??
PHP View Counter
How do I make a php counter, to count: a) Total Views of one page b) Unique views of one page c) Use mysql with it
Pattern Syntax
is there a not operator in the pattern syntax thingy? e.g. (*+) all characters but i want to exclude [ and ]
PHP Pattern Match
I need to convert the following pattern which I found in a php program into a perl regex... but I have NO CLUE WHAT IT DOES! &[^;]; <[^>]*> Actually, for the second one, I have an idea as to what it does, but I'm not sure... they are both used in this context:
ActiveRecord Pattern
there is a good implementation of ActiveRecord pattern in PHP? (ADOdb implementation is not good for me...)
A Good OOP Pattern?
I am not new to OOP but would like to make the whole site 100% object oriented. Can anybody suggest/provide a small application or framework (not a big one) so that one can understand the concept of making a whole application in OOP way.
Pattern Matching ?
can someone please explain how to search $blah for a certain string of characters. lets say $blah = "i cant work out how to pattern match"; if ( $blah ~= /cant/ ) { echo "i cant!" }; that would work with perl whats the php equivilant ?
The Flyweight Pattern In PHP 5
Yesterday I continued my series of design patterns examples using PHP 5 with the Bridge Pattern. Here now is my 18th design pattern example, the Flyweight Pattern. In the flyweight pattern we conserve resources by sharing instances of a class which are identical. The creating of these instances is controlled by a factory which will only create one if it does not already exist, and will return the shared instance to the requestor.
Strategy Pattern Php 5
I am reading about the "Strategy" pattern. The concepts they intruduce is : 1. Favor composition over inheritance. Does this mean? - as opposed to creating big classes that I will inherit from in the future, I should include only the most important things in the super class and use "composites" or classes that inherit to put details into? 2. Program to interfaces and not implementations. One thing is: when you add a new method to an interface, you break all your clients, whereas with an abstract class you can add a new method and provide full implementation and new clients will inherit it.
Searching For A Pattern
Has somebody a pattern which contains: - URL Checking (This Syntax: http://www(with and without www). - Only *.html, *.htm, *.php formats - also: http://www.lol.com/index.html or index.htm or index.php.
Pattern Matching
i have an array with ip-numbers, some using wildcards, that i need to match against a given ip-number. PHP Code:
Remove Pattern
I would like to remove all this pattern, even any text or number into <span>...</span> Pattern and String into <span>...</span>: PHP Code:
The Mediator Pattern In PHP 5
I finally pieced together what I think is a good example of the Mediator Pattern in PHP 5. See what you think. I have, per request, tried to simplify my test program structure a bit. testMediator.php has only one html tag in it - a <BR>. This is in my new writeln() function, which adds '<'.'BR'.'>' to each line and echos. If you just add a '<BR>' after each line the program would run fine, but the source code would not display properly. So, see if you like the new test structure better. Most of the other PHP design patterns on www.FluffyCat.com/PHP-Design-Patterns still have the old test formatting system, but if this proves more readable I'll redo the others as well.
RE Matching What's Not The Pattern
say i have 4 tables: forum_prefix_forum1 forum_prefix_forum2 other_prefix_table even_other_prefix_table this will select the forum_prefix tables PHP Code:
Pattern Matching
I have a web search form. If I put 'fred' in one field and in the database it has 'fred, bob, dave' in that field, I can bring up the record by using: SELECT * from details where keywords LIKE '%$keywords%' This works fine. HOWEVER If I put 'fred, bob, dave' in the search box, and it only has 'fred' in the database field THEN it won't bring up the record. Obviously I can't use: SELECT * from details where keywords LIKE '%$keywords%' any more, so what do I do?
The Strategy Pattern In PHP 5
I'm almost done my series of design patterns using PHP 5. Today's pattern is the Strategy Pattern. In the Stratedy Pattern a "family of algorythms" is used interchangably by calling clients. This is the second pattern in as many days as I've used my older work with patterns in Java, and again I liked the old example when I first looked at it, but now I wonder about it. In this example the context is passed a parameter at instantiation, and the context then chooses a concrete strategy which it hold on to for every time it needs a strategy. This means that the calling client would need to call the appropriate context. Not sure if this is the real intent here, might have to revisit this one...
The Singleton Pattern In PHP 5
To add to my growing library of Design Patterns in PHP 5 I have written what I think is a good example of the Singleton Pattern. In the classic singleton pattern an object will distribute one and only one instance of itself. This can be useful for the sharing of resources such as a single db or network connection. A variation, sometimes called a multiton, would distribute a limited number of instances of itself. Useful, say if you had a limited number of db connections to share.
MVC/OO Pattern Clarification
I had a question about OO implementation in the MVC pattern that is directed at anyone who feels experienced with it. My fuzziness comes from trying to learn OOP and MVC at the same time, coming from a procedural background where I used neither. I promise I'm not a dummy, and my logic skills are very strong, but this really is a whole new world for me. Quote:
The Interpreter Pattern In PHP 5
Last week I continued my series of design patterns examples using PHP 5 with the Bridge Pattern, Flyweight Pattern, and Proxy Pattern. Here now is my 20th PHP 5 design pattern example, the Interpreter Pattern. In the Interpreter Design Pattern you define a language syntax, and parse requests that use that syntax, and call the correct classes and methods to handle the request. An interesting pattern, although I don't think I've used it much in systems I've worked on. It is probably indespensible if you are writing a compiler.
Factory Pattern In Php
I want to use a factory pattern to create a variety of objects. Which object gets created depends on a string that is passed to the factory create method. I would like to avoid using an if or switch construct to accomplish this but not sure how. For example, .... if($nextObject == "login") { return new Login(); } else if($nextObject == "validatedata") { return new Validate(aString); } .... Is there any way to avoid this?
The Proxy Pattern In PHP 5
This week I've I continued my series of design patterns examples using PHP 5 with the Bridge Pattern and the Flyweight Pattern. Here now is my 19th design pattern example using PHP 5, the Proxy Pattern. http://www.fluffycat.com/PHP-Design-Patterns/Proxy/ In the proxy pattern one class stands in for and controll all calls to another class. This could be because the real subject class is on another platform, the real subject is "expensive" to create so we only create it if necessary, or to controll access to the real subject class. A proxy can also add access functionality, such as keeping track of how many times a real subject is called. Proxy is a nice little pattern, being both fairly simple and widely used.
Create Pattern
I doubt on how to create the following pattern: ************ *********** ********** ********* ******** ******* ****** ***** **** *** ** *
Pattern Matching
I have HTML stored in a variable $html Buried in there is a link with the anchor text as New York therefore in the $html variable somewhere is <a href="somelink">New York[/url] Is there any way using pattern matching that would let me get the link used to link to the text New York? There is a few links with the text New York but I only want to get the link from the first one. Been agonising over this for ages so if anyone could help it would really save my life.
Way To View PHP Files On Your Computer?
Is there a way to view what certain PHP files will look like, without having to upload them to your server? I'm testing out page layouts, and its kind of a pain to upload it every time to see what it looks like.
PHP Download/view Statistics
if anyone had any ideas for a simple way that I could use to get statistics on the amount of times a webpage has been viewed? I don't really want to install a whole web statistics package.. I just want to keep track of the statistics on a few pages.
View The Picture Before Save
when i upload the picture.. is there a way we can let the user to view the picture which they just browsed before they upload>?? e.g. user need to upload 3 pictures... so when user browsed the picture... usually what we get is just the path name...instead.. i wan to view the picture and the path... but these picture are not yet upload to the folder.
See On-line View Code
Hi! Is there any possible way to view an "on-line" php file? That is of course how you can view the code in a php file?
|