static function getEnvironmentRoot($url, $https = false)
 {
     if (!isset($https)) {
         $https = isset($_SERVER['HTTPS']);
     }
     $root = ($https ? 'https' : 'http') . "://{$url}";
     $parts = explode(".", URL::getCurrentArr('host'));
     if (Config::isMyDevBox()) {
         $root .= '.' . implode(".", array_slice($parts, -4));
     } elseif (Config::isStaging()) {
         $root .= '.' . implode(".", array_slice($parts, -3));
     }
     return $root;
 }
 function write($keyspace, $key, $column_family, $data, $consistency)
 {
     try {
         Loader::load("vendor", "phpcassa/columnfamily.php");
         $columnFamily = new columnFamily($this->connection($keyspace), $column_family);
         //echo "use phpcassa!\n";
         //exit;
         if (Config::isLive() || Config::isStaging()) {
             return $columnFamily->insert($key, $data, null, null, $consistency);
         }
         $time = $this->microsecond_timestamp();
         $cassandra_mutations = array();
         foreach ($data as $key => $value) {
             $cassandra_mutations[$key][$column_family][] = new cassandra_Mutation(array("column_or_supercolumn" => new cassandra_ColumnOrSuperColumn(array("column" => new cassandra_Column(array("name" => $key, "value" => $value, "timestamp" => $time))))));
         }
         //Debugger::log("set keyspace $keyspace");
         $this->set_keyspace($keyspace);
         $start = microtime(true);
         $this->get_client()->batch_mutate($cassandra_mutations, $this->consistency());
         $end = microtime(true);
         if (json_encode($cassandra_mutations) == null) {
             print_r($cassandra_mutations);
             exit;
         }
         //error_log("Thrift::batch_mutate(".json_encode($cassandra_mutations).") " . "(".$this->host .":".$this->settings["port"].")");
         Debugger::query("Thrift::batch_mutate(" . json_encode($cassandra_mutations) . ")", $end - $start, $keyspace . "(" . $this->settings["ip"] . ":" . $this->settings["port"] . ")");
         return true;
     } catch (Exception $e) {
         $info = isset($e->why) ? $e->why : get_class($e);
         throw new Exception("Database connection is not available: {$info} {$this->host}");
         return false;
     }
 }
 function send($html_mode = false)
 {
     if (Config::isLive() || Config::isStaging()) {
         $mail = $this->getEmailer();
         if ($this->send_as_html) {
             //many mail servers break 8bit encoding by adding newlines, QP prevents that for ASCII-only emails (like this)
             $mail->Encoding = "quoted-printable";
             $mail->isHTML(true);
         }
         $mail->Subject = $this->getSubjectWithReplacements();
         $mail->Body = $this->getBodyWithReplacements();
         if (!$mail->Send()) {
             error_log("ERROR: mail not sent: {$mail->ErrorInfo}");
             return false;
         } else {
             if ($this->recordMember) {
                 Loader::load('model', 'com/htmlgraphic/history/Transaction');
                 DBObject::mutator('Transaction', 'RecordContactEmailSentAction', array($this, $this->recordMember))->activate();
             }
         }
         return true;
     } else {
         //this is so you can see if you would have sent an email on a dev box
         if ($this->recordMember) {
             Loader::load('model', 'com/htmlgraphic/history/Transaction');
             DBObject::mutator('Transaction', 'RecordContactEmailSentAction', array($this, $this->recordMember))->activate();
         }
         //error_log(print_r($this->recordMember,true));
         Debugger::log("<span style='color: #fff;'>Subject:</span> " . $this->getSubjectWithReplacements() . "<br><br><span style='color: #fff;'>-----Body-----</span><br>" . $this->getBodyWithReplacements() . "<br><span style='color: #fff;'>-----Body-----</span>");
         return true;
     }
 }