Jump to content

SparK_BR

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

About SparK_BR

  • Birthday 06/11/1991

Contact Methods

  • MSN
    roger@valemais.net

Profile Information

  • Gender
    Male
  • Location
    Curitiba, PR - Brasil

SparK_BR's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. if you use cygwin or something and do a "ls -lia" you will see that things that can be run are marked with x, things that are readonly aren't marked with w and so on I think ntfs uses the chmod policy but windows explorer hides it from the user except if you try to share the folder, then you will see the permition settings oh btw, to set a folder and/or file permition use chmod
  2. version control is language independent here we use SVN but we want to use GIT in the future (stay away from CVS)
  3. He means you must create a page like "hobbies.php" but in the main page you simply don't link to it so the bot will get to your index but if the index has no link to the other page, the bot won't see it
  4. if you exclude all session_start() calls and leave only the ones that get called directly, like the main screen, the things that get called through ajax or something. then you wouldn't need session_start() for the rest I mean, included/required files don't need session_start() other than that just check if session_id() returns an empty string
  5. you can give a name to the submit button and then check isset($_POST['name']); to see what action to take, your target script would be a delegator, just delivering the message to the right script so you can either redraw the screen with more itens or add the itens to the database (phpMyAdmin does that)
  6. SparK_BR

    An Odity

    Good, at least PHP tells you something is wrong
  7. on mine I have a small script that instantiates the controller, sets the parameters from POST then run the intended action and returns the results already digested by the view. but of course, in the controller I can call another one and make it run something for me, only thing is that I can discard the result or play with the result object. as in like, if you call 'erase' in a group controller, it calls the item controller and erases the itens of that group before commiting suicide.
  8. shouldn't your substr be using 10 as third parameter instead of -10? actually, you should use substr($page_content,$strPos-10,strlen($q)+10); or something if you want to cut 10 before and 10 after the keyword and not counting with it
  9. something like that is either with the php team (or someone with time) with a list of commands and versions to check the script or somebody with all versions installed and capturing warnings and errors with every execution (and of course a vm or sandbox like thing to prevent a script to change stuff on the server)
  10. if by "defying" you mean "defining" ok =D a nice concept you should take a look at is dependency injection. either by constructors, by setters, or by configuration objects/injection containers. it's simple and will keep your code decoupled
  11. there's no such competitions where I live... and usually people who are smarter than the teachers score 50%
  12. SparK_BR

    An Odity

    is that because you used $this and called foo as static context and it found the closest instance context to get "$this" value? really interesting
  13. then you need something more hardcore like Aspects and proxies so you can attach pseudo-events to any method without changing the class, from an external source problem is, it's difficult and uses undocumented workarounds to be implemented (I'm working on something so I can handle transversal interests in my system like logging, but nothing ready yet)
  14. chrome's anonymus window firefox's private navigation and similars may help you with that (cookies get eaten after you close the browser)
  15. can I post code? last time I posted code it got removed... Event abstract abstract class Event{ private $target; private $lockTarget = false; public function setTargetOnce($obj){ if($lockTarget) return; $this->target = $obj; $this->lockTarget = true; } abstract public function getName(); public function getTarget(){ return $this->target; } } Handler abstract (your dispatcher inherit from this) abstract class EventHandler{ private $listeners = array(); public function addEventListener($eventName,$listener,$method=""){ if(!isset($this->listeners[$eventName])) $this->listeners[$eventName] = array(); $this->listeners[$eventName][] = array($listener,$method); } public function removeEventListener($eventName,$listener){ for($i = 0; $i < count($this->listeners[$eventName]); $i++){ $subject = $this->listeners[$eventName][$i]; if($subject[0] !== $listener) continue; array_splice($this->listeners[$eventName],$i,1); } } protected function dispatchEvent($event){ $event->setTargetOnce($this); foreach($this->listeners[$event->getName()] as $listener){ $called = $listener[0]; if($listener[1] != "") $called = array($listener[0],$listener[1]); call_user_func($called,$event); } } } now to test it you will need these: BasicEvent class BasicEvent extends Event{ private $name = "basic"; private $type; public function BasicEvent($type){ $this->type = $type; } public function getName(){ return $this->name; } public function getType(){ return $this->type; } } and this is something that will use that event: The dispatcher class BasicDispatcher extends EventHandler{ private $holder = false; public function __set($key,$value){ $this->dispatchEvent(new BasicEvent("set")); $this->holder->{$key} = $value; } public function __get($key){ $this->dispatchEvent(new BasicEvent("get")); return $this->holder->{$key}; } } now for the main code: PS the Dynamic class and others are part of my project, you can use any class here $ouvinte = new Dynamic(); $ouvinte->onBasic = function($self,$evento){ JavaScript::alert($evento->getName()." ".$evento->getType()." sendo tratado pelo ouvinte."); }; $disparador = new BasicDispatcher(); $disparador->addEventListener("basic", $ouvinte, "onBasic"); $disparador->addEventListener("basic", "tratarLocal"); $disparador->basicIo = "verificando integridade da mensagem pós-evento."; $mensagem = $disparador->basicIo; JavaScript::alert($mensagem); //local function function tratarLocal($evento){ JavaScript::alert($evento->getName()." ".$evento->getType()." sendo tratado localmente."); } once you set or get the basicIo property the event is dispatched and both listening methods are called
×
×
  • 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.