Jump to content

WhIteSidE

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

WhIteSidE's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Like Daniel0 said, the best encryption solutions are based on an open standard and are still uncrackable. Why open? Security through obscurity only works as long as no one figures out your method. As soon as someone figures it out, you're boned. And someone always figures it out. The other alternative is to use a simple solution in clear php code to authenticate a license key. True, php experts may be able to hack around it, although I never have. Most organizations will pay for a license. ~ Christopher
  2. Again, this really depends. There are people who really like CakePHP and indeed, there are some very nice things about it. First and foremost, the ability to "bake" scaffolding. In addition, there are good, solid User and Access Control libraries already written for Cake. On the other hand, Cake, like Rails, is all about convention over code. As such it can be intensely frustrating at times to have to follow their stupid conventions and Cake in particular has massive code bloat. Zend is the Polar opposite of Cake. While Cake has lots of mandatory things, Zend is simply a bunch of libraries which can be included as needed. On the other hand, Zend is a lot less cohesive and (IMO) tends to lead to applications with too much coupling if you are not careful in your design*. Finally, CodeIgniter, my personal favorite for most projects. CI implements a strong MVC engine, although it is still very flexible. In addition, it implements a light weight version of smarty and is not too intrusive. My biggest complaint is that there is not a really good ACL/Authorization class for CI, although ReduxAuth and ZendACL are often used. Finally, many Zend libraries can easily be used with CI if needed. ~ Christopher * Obviously, this isn't the point of Zend, but I frequently see code where like 30 zend classes are included in every file, which kind of defeats the purpose.
  3. You might consider the "Model-View-Controller" architecture. In php most MVC frameworks load a template type file which contains purely procedural code (or tags). See http://www.smarty.net/crashcourse.php and take a look at how cakePHP and CodeIgniter handle views. ~ Christopher
  4. This is probably a good idea, however, if you want you index script to be more powerful (i.e. load pages out of a directory without knowing every possible page in advance), then you should at the very least include some sanitation to make sure that somebody doesn't include a path, that is to say '../../secretfilenotinthewebroot' ~ Christopher
  5. While working on a project the other day, something came up that got me to thinking about the use of closures to simplify various debugging and other "academic" questions about how function calls are made. Consider a function which has a big, nasty, ugly logic tree, with many return statements. As the function executes a different branch will be executed. Thus, if I am worried about what the function is returning (if I want to log it for instance), I need to either (a) Write some logging code in the calling function, (b) Write and invoker function or © Use some method to "catch" the return inside the function. For an example class MyClass: class MyClass { function MyClass() { } function Method($input) { if($input===false) { return 'FALSE'; } if($input=='Hello') { return 'GREETING'; } } } To execute logging method a, then, in my code I would write: $myclass = new MyClass(); $returnValue = $myclass->Method('Hello'); Logger::log($returnValue); doSomething($returnValue); This has the unfortunate side effect, however, that I need to log wherever I use the code, and cannot simply call the function. Another way to do this would be to use a helper, or 'invoker' method: class MyClass { $_logReturn; function MyClass($logReturn=TRUE) { $_logReturn=$logReturn; } public function Method($input) { $returnValue = $this->_Method($input); if ($_logReturn) Logger::log($returnValue); return $returnValue; } private function _Method($input) { if($input===false) { return 'FALSE'; } if($input=='Hello') { return 'GREETING'; } } } Now from my calling function, I simply write: $myclass = new MyClass(); doSomething($myclass->Method('Hello')); Now, method b isn't entirely terrible, although it would be really tedious for a huge class to write a real and helper function for each method. Closure to the rescue. Modify MyClass to look something like this: class MyClass { $return function MyClass($logReturn=TRUE) { $ret = function ($returnValue) use ($logReturn) { if ($logReturn) Logger::log($returnValue); return $returnValue; } } function Method($input) { if($input===false) { $ret('FALSE'); } if($input=='Hello') { $ret('GREETING'); } } } Now my simple calling code works, and I don't need to write each function twice. However, there is a messy aspect to this, in that I need to use the $ret() call instead of the return keyword. To that end, does anyone know of a way to trap the return value directly? ~ Christopher
×
×
  • 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.