Exemple #1
0
 function __construct($to, $subject, $body, $from, $html = false)
 {
     $this->headers['To'] = $this->encode_header_fld($to);
     $this->headers['Subject'] = $this->encode_header_fld($subject);
     $this->headers['Date'] = date('r');
     $this->headers['Message-ID'] = '<' . md5(uniqid(rand(), 1)) . '@' . php_uname('n') . '>';
     $this->boundary = Hm_Crypt::unique_id(32);
     $this->html = $html;
     $this->body = $this->prep_message_body($body);
 }
Exemple #2
0
/**
 * Copies the site.js and site.css files to the site/ directory, and creates
 * a production version of the index.php file.
 *
 * @return void
 */
function create_production_site($assets, $settings)
{
    if (!is_readable('site/')) {
        mkdir('site', 0755);
    }
    printf("creating production site\n");
    copy('site.css', 'site/site.css');
    copy('site.js', 'site/site.js');
    $index_file = file_get_contents('index.php');
    $index_file = preg_replace("/APP_PATH', ''/", "APP_PATH', '" . APP_PATH . "'", $index_file);
    $index_file = preg_replace("/CACHE_ID', ''/", "CACHE_ID', '" . urlencode(Hm_Crypt::unique_id(32)) . "'", $index_file);
    $index_file = preg_replace("/SITE_ID', ''/", "SITE_ID', '" . urlencode(Hm_Crypt::unique_id(64)) . "'", $index_file);
    $index_file = preg_replace("/DEBUG_MODE', true/", "DEBUG_MODE', false", $index_file);
    file_put_contents('site/index.php', $index_file);
    foreach ($assets as $path) {
        copy_recursive($path);
    }
}
Exemple #3
0
 function prep_message_body()
 {
     $body = $this->body;
     if (!$this->html) {
         $body = mb_convert_encoding(trim($body), "HTML-ENTITIES", "UTF-8");
         $body = mb_convert_encoding($body, "UTF-8", "HTML-ENTITIES");
         if (!empty($this->attachments)) {
             $this->headers['Content-Type'] = 'multipart/mixed; boundary=' . $this->boundary;
             $body = sprintf("--%s\r\nContent-Type: text/plain; charset=UTF-8; format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($body));
         } else {
             $this->headers['Content-Type'] = 'text/plain; charset=UTF-8; format=flowed';
             $this->headers['Content-Transfer-Encoding'] = 'quoted-printable';
             $body = $this->format_message_text($body);
         }
     } else {
         $txt = convert_html_to_text($body);
         if (!empty($this->attachments)) {
             $alt_boundary = Hm_Crypt::unique_id(32);
             $this->headers['Content-Type'] = 'multipart/mixed; boundary=' . $this->boundary;
             $this->text_body = sprintf("--%s\r\nContent-Type: multipart/alternative; boundary=" . "\"%s\"\r\n\r\n--%s\r\nContent-Type: text/plain; charset=UTF-8; " . "format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $alt_boundary, $alt_boundary, $this->format_message_text($txt));
             $body = sprintf("--%s\r\nContent-Type: text/html; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n\r\n%s\r\n\r\n--%s--", $alt_boundary, $this->format_message_text($body), $alt_boundary);
         } else {
             $this->headers['Content-Type'] = 'multipart/alternative; boundary=' . $this->boundary;
             $this->text_body = sprintf("--%s\r\nContent-Type: text/plain; charset=UTF-8; " . "format=flowed\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($txt));
             $body = sprintf("--%s\r\nContent-Type: text/html; charset=UTF-8; format=flowed\r\n" . "Content-Transfer-Encoding: quoted-printable\r\n\r\n%s", $this->boundary, $this->format_message_text($body));
         }
     }
     $this->body = $body;
 }
Exemple #4
0
 /**
  * @preserveGlobalState disabled
  * @runInSeparateProcess
  */
 public function test_unique_id()
 {
     $this->assertEquals(24, strlen(base64_decode(Hm_Crypt::unique_id(24))));
     $this->assertEquals(48, strlen(base64_decode(Hm_Crypt::unique_id(48))));
     $this->assertEquals(128, strlen(base64_decode(Hm_Crypt::unique_id())));
 }
Exemple #5
0
 /**
  * Set the session level encryption key
  * @param object $request request details
  * @return void
  */
 protected function set_key($request)
 {
     $this->enc_key = Hm_Crypt::unique_id();
     $this->secure_cookie($request, 'hm_id', $this->enc_key);
 }
Exemple #6
0
 /**
  * Start a new session
  * @param object $request request details
  * @return void
  */
 public function start_new_session($request)
 {
     $this->session_key = Hm_Crypt::unique_id();
     $this->secure_cookie($request, $this->cname, $this->session_key, 0);
     if ($this->insert_session_row()) {
         $this->active = true;
     }
 }