Jump to content

dpacmittal

Members
  • Posts

    220
  • Joined

  • Last visited

    Never

Everything posted by dpacmittal

  1. How about the second part of the question about the MX entries?
  2. I'm wanting to change hosting provide but I dont know how to change it without any downtime. Any help is appreciated. Also, since I'll change hosts, I need to point my domain names to the new nameservers. So, do I have to edit the MX entries to point to Google Apps again or would it be retained? Just FYI, I'm switching from Linode to Web Faction.
  3. I've modifying lots of wordpress plugins for a client. But since I've modified them he can no longer update them. Is there anyway to modify a plugin and still make them update. I know some updates might break the changes, but thats okay. I just want the plugins to be updatable and changes I've made applied to them dynamically or something.
  4. I made a CNAME static.mysite.com and pointed it to www.mysite.com. This is basically to create a cookieless domain. Now I don't want anything other than javascript, css and pictures to be served from static.mysite.com. I almost wasted one hour figuring out what htaccess would suffice this. I've got the logic but I am not able to implement it. Basically, if the HOST header has static in it, then allow only above-specified filetypes and give a 403 on the other pages. If the HOST header doesn't contain 'static' in it, then its normal domain and should allow access to everything. I hope I am clear. Can you guys help me with this?
  5. Gave a quick look and I have just one suggestion: Consider making a db class just for CRUD operations and another class which would handle the queries related to login. This way db class becomes reusable.
  6. I guess this would be quite enough.
  7. Yeah, I hope so. I'd rather sacrifice performance. Thanks for all the replies. I'll mark this solved.
  8. Thanks for the code. I too had thought of doing this way but I wanted to have better performance. In this way, you notify all the attached observers which then process through a series of conditions. This creates unnecessary overhead. Is there any way we can notify only the objects which are related to a particular state?
  9. Add set_time_limit(0); ini_set('memory_limit', '64M'); at the top of the file. Also initialize $message as pointed by bulrush.
  10. I think he means a web-app which can update on a single click or maybe auto-update using cron. @OP: You can create a php file on central server which simply echoes (or displays xml) latest version of software available. You can then use curl to download the archive on to client server, use zip libraries to extract the files and redirect the client-browser to upgrade.php or something.
  11. I don't know whether I'll get better answer posting this in 'Php coding' or 'Application design', so I'll just post it in 'PHP coding' since it has more traffic. Okay, so I've read about observer pattern, seen examples. Seen how to use SPL for the purpose. However, all the examples were basic and only dealt with a single hook. However, I'd like to have multiple hooks within a class and I am confused about whats the best way to achieve that. I've written a code last night which does this but I'm afraid its very noobish. I'd be grateful to anyone who could point me in the right direction. Code I wrote last night: <?php class Login implements SplSubject { private $storage; var $currhook; function __construct() { $this->storage = array(); } function attach( SplObserver $observer ) { if(!isset($this->storage[$observer->hookName])) $this->storage[$observer->hookName] = new SplObjectStorage(); $this->storage[$observer->hookName]->attach($observer); } function detach( SplObserver $observer) { $this->storage[$observer->hookName]->detach($observer); } function notify() { foreach ( $this->storage[$this->currhook] as $obs ) { $obs->update( $this ); } } function log_in(){ $this->currhook = 'beforelogin'; $this->notify(); echo "LOGGED IN"; $this->currhook = 'afterlogin'; $this->notify(); } } class LoginObserver implements SplObserver { var $hookName; function update(SplSubject $login){ $this->doupdate($login); } } class afterLogin extends LoginObserver { function __construct(Login $login){ $this->hookName = 'beforelogin'; $login->attach($this); } function doupdate($login){ echo "beforelogin<br/>"; } } class beforeLogin extends LoginObserver { function __construct(Login $login){ $this->hookName = 'afterlogin'; $login->attach($this); } function doupdate($login){ echo "<br/>After login"; } } $login = new Login(); new beforeLogin($login); new afterLogin($login); $login->log_in(); ?> Pardon the naming inconsistencies.
  12. This is what you need: http://php.net/manual/en/function.eval.php Store the equation in database as: $ORIGINAL_PRICE - ($ORIGINAL_PRICE * 0.50) After that, you can do: $value = eval($row['equation']);
  13. Thanks a lot. I was just over-complicating stuff. It was straighforward. Thanks, again.
  14. UPDATE: I tried this new regex. It seems to be working fine except that it is accepting phone numbers with lesser digits. Here is it: if(preg_match('!^\d(\d|(?<=\d)(\s|\-)?){5,10}\d$!',$number))
  15. First of all, sorry for not being able to provide a more appropriate title. This is a question from elance coding test. I completed it last time by using all sorts of functions and a very basic regex. This time I tried to become brave and thought of solving it completely using Regexes. However I got stuck at multiple points (hence, the inappropriate title). I tried these which are obviously wrong: if(preg_match('!^\d([\d]+(\s|\-)?){5,10}\d$!',$number)) I know it would accept any length of string. if(preg_match('!^\d(\d|\s|\-){5,10}\d$!',$number)) This would allow multiple spaces and hyphens next to each other. Normally, my knowledge on regex usually gets me through my work and I don't usually need help in this regard. However, this one completely got me. Any help would be appreciated. Thanks!
  16. Okay so I removed the '%' from the query as well as the album field. It still doesn't return the required lyrics when searching for some songs.. Whats wrong? I've manually checked and they are there in the database.
  17. Wildcard? Doesn't it work on fulltext? Actually I took help from a comment in mysql documentation. I saw it there, so I put it.
  18. My client has a video site and he wishes to display lyrics when someone watches a music video. He bought a database for that. Now, most videos' titles contain artist name and song title. I take it as argument and search it in database and present the lyrics. It works for 60% of the songs and doesn't works for the others. For eg; I searched 'Beatles let it be' and it returned wrong lyrics. My query is: SELECT *, MATCH(title,artist,album) AGAINST ('%$query%') as Relevance FROM lyrics WHERE MATCH(title,artist,album) AGAINST ('%$query%' IN BOOLEAN MODE) HAVING Relevance > 6 ORDER BY Relevance DESC limit 1 $query is the video title. PS: This is the first time I am working with Fulltext so my query might be noobish. EDIT: I just noticed that I am using album in the query too, is it possible thats what causing the inaccuracy?
  19. Thanks, it gave me the idea. Thanks, it helped quite a lot.
  20. Thanks. I'll check out the link. In the meanwhile, could you tell my if the idea which I had thought initially in the original post is a good one?
  21. Bump. If I don't find help on phpfreaks, I won't find it anywhere.
  22. Nope it does not. Even if it did, what does it have to do with plugin system?
  23. I want to create a plugin system similar to one implemented in wordpress. Google hasn't been of any help. I tried reading wordpress source but it would take much time to understand the underlying concept. I've checked its database and it doesn't store any plugin information in the database which means that it parses all the plugins everytime the page is loaded which, in my opinion, is not (?) a good way to do it. The system they've used is the hook system. There are hooks in most of the places. You add some action to the hook and when the hook is called, the action to attached is also executed. For eg; if you attach an action of cleaning a certain folder on the hook of add-post (say), everytime you add a post, the folder will be cleared. Okay, so I've not been able to understand how wordpress does it. However, I myself have a basic idea for this. I just want opinions if it is a good way to do it. I've thought of something like this: Plugins would have to call a function to attach an action to hook eg; attach_action ($hookname, $callback) When the plugin is installed, attach_action would add this information to the database. When the hook is called, it fetches all the actions attached to it from the database and executes them. When the plugin is uninstalled, the record from database is removed. So this is it. I want to know if this is better/worse way than how wordpress does? Thanks
  24. I want to create a plugin system similar to one implemented in wordpress. Google hasn't been of any help. I tried reading wordpress source but it would take much time to understand the underlying concept. I've checked its database and it doesn't store any plugin information in the database which means that it parses all the plugins everytime the page is loaded which, in my opinion, is not (?) a good way to do it. The system they've used is the hook system. There are hooks in most of the places. You add some action to the hook and when the hook is called, the action to attached is also executed. For eg; if you attach an action of cleaning a certain folder on the hook of add-post (say), everytime you add a post, the folder will be cleared. Okay, so I've not been able to understand how wordpress does it. However, I myself have a basic idea for this. I just want opinions if it is a good way to do it. I've thought of something like this: Plugins would have to call a function to attach an action to hook eg; attach_action ($hookname, $callback) When the plugin is installed, attach_action would add this information to the database. When the hook is called, it fetches all the actions attached to it from the database and executes them. When the plugin is uninstalled, the record from database is removed. So this is it. I want to know if this is better/worse way than how wordpress does? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.