error("Mail sending disabled in demo mode."); if($filepath != '') { if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath); $content = file_get_contents($filepath); $content = chunk_split(base64_encode($content)); $uid = strtoupper(md5(uniqid(time()))); $subject = "=?utf-8?B?".base64_encode($subject)."?="; if($filename == '') { $path_parts = pathinfo($filepath); $filename = $path_parts["basename"]; unset($path_parts); } $header = "Return-Path: $form\nFrom: $from\nReply-To: $from\n"; $header .= "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=$uid\n"; $header .= "--$uid\n"; $header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n"; $header .= "$text\n"; $header .= "--$uid\n"; $header .= "Content-Type: $filetype; name=\"$filename\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: attachment; filename=\"$filename\"\n\n"; $header .= "$content\n"; $header .= "--$uid--"; mail($to, $subject, "", $header); } else { $header = "From: $from\nReply-To: $from\n"; $header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n"; $header .= "Content-Transfer-Encoding: 8bit\n\n"; $subject = "=?utf-8?B?".base64_encode($subject)."?="; mail($to, $subject, $text, $header); } return true; } public function array_merge($array1,$array2) { $out = $array1; foreach($array2 as $key => $val) { $out[$key] = $val; } return $out; } public function currency_format($number) { global $app; $number_format_decimals = (int)$app->lng('number_format_decimals'); $number_format_dec_point = $app->lng('number_format_dec_point'); $number_format_thousands_sep = $app->lng('number_format_thousands_sep'); if($number_format_thousands_sep == 'number_format_thousands_sep') $number_format_thousands_sep = ''; return number_format((double)$number, $number_format_decimals, $number_format_dec_point, $number_format_thousands_sep); } public function get_ispconfig_url() { $url = (stristr($_SERVER['SERVER_PROTOCOL'],'HTTPS'))?'https':'http'; $url .= '://'.$_SERVER['SERVER_NAME']; if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { $url .= ':'.$_SERVER['SERVER_PORT']; } return $url; } function json_encode($data) { if(!function_exists('json_encode')){ switch ($type = gettype($data)){ case 'NULL': return 'null'; case 'boolean': return ($data ? 'true' : 'false'); case 'integer': case 'double': case 'float': return $data; case 'string': return '"' . addslashes($data) . '"'; case 'object': $data = get_object_vars($data); case 'array': $output_index_count = 0; $output_indexed = array(); $output_associative = array(); foreach($data as $key => $value){ $output_indexed[] = $this->json_encode($value); $output_associative[] = $this->json_encode($key) . ':' . $this->json_encode($value); if($output_index_count !== NULL && $output_index_count++ !== $key){ $output_index_count = NULL; } } if($output_index_count !== NULL){ return '[' . implode(',', $output_indexed) . ']'; } else { return '{' . implode(',', $output_associative) . '}'; } default: return ''; // Not supported } } else { return json_encode($data); } } } ?>