Example #1
0
 public function setConnectionDetails($details = NULL)
 {
     $s = $d = false;
     if ($details) {
         $v = new Amslib_Validator($details);
         $v->add("username", "text", true);
         $v->add("password", "text", true);
         $v->add("database", "text", true);
         $v->add("server", "text", true);
         $v->add("encoding", "text", true, array("default" => "utf8", "limit-input" => $this->validEncoding));
         $s = $v->execute();
         $d = $v->getValid();
         $e = $v->getErrors();
         if (!$s) {
             if (isset($e["password"])) {
                 $e["password"]["value"] = "*CENSORED*";
             }
             Amslib_Debug::log("database details were invalid", $e);
         }
     }
     $this->connectionDetails = $s ? $d : false;
     return $this->getConnectionDetails();
 }
 /**
  * 	method:	__construct
  *
  * 	todo: write documentation
  */
 public function __construct($source)
 {
     $this->route = false;
     $this->import = false;
     $this->valid = false;
     $v = new Amslib_Validator($source);
     $v->add("lang", "text", true);
     $v->add("route", "text", true);
     $v->add("route_type", "text", true);
     $v->add("options", "text", true);
     $v->add("options_input", "text", true);
     $v->add("options_output", "text", true);
     $v->add("options_record", "text", true);
     $v->add("options_failure", "text", true);
     $v->add("url", "text", true);
     $v->add("param", "text", true);
     $v->add("param_type", "text", true);
     $v->add("handler", "text", true);
     $v->add("handler_type", "text", true);
     $v->add("database", "instanceof", true, array("type" => "Amslib_Database_MySQL"));
     $s = $v->execute();
     $d = $v->getValid();
     $e = $v->getErrors();
     if ($s) {
         try {
             $this->database = $d["database"];
             $this->table = $d;
             unset($this->table["database"]);
             $this->processPath();
             $this->processService();
             $this->processConfig();
             $this->valid = true;
         } catch (Exception $e) {
             Amslib_Debug::log("Exception: ", $e->getMessage());
             Amslib_Debug::log("stack_trace");
         }
     }
 }