This blob has been accessed 423 times via Git panel.
- <?php
- if (isset($_POST['mbox_min']) and !empty($_POST['mbox_min']) and is_numeric($_POST['mbox_min'])) {
- $mbox_min = $_POST['mbox_min'];
- }
- else {
- $mbox_min = "0";
- }
- if (isset($_POST['mbox_ppg']) and !empty($_POST['mbox_ppg']) and is_numeric($_POST['mbox_ppg'])) {
- $mbox_ppg = $_POST['mbox_ppg'];
- }
- else {
- $mbox_ppg = "14";
- }
- $mbox_max = $mbox_min + $mbox_ppg;
- function time_elapsed_string($ptime) {
- if ($etime < 1) {
- return '0 seconds';
- }
- $a = array( 12 * 30 * 24 * 60 * 60 => 'year',
- 30 * 24 * 60 * 60 => 'month',
- 7 * 24 * 60 * 60 => 'week',
- 24 * 60 * 60 => 'day',
- 60 * 60 => 'hour',
- 60 => 'minute',
- 1 => 'second'
- );
- foreach ($a as $secs => $str) {
- $d = $etime / $secs;
- if ($d >= 1) {
- $r = round($d);
- return $r . ' ' . $str . ($r > 1 ? 's' : '');
- }
- }
- }
- function HumanReadableFilesize($size) {
- // Adapted from: http://www.php.net/manual/en/function.filesize.php
- $mod = 1024;
- $units = explode(' ','B KB MB GB TB PB');
- for ($i = 0; $size > $mod; $i++) {
- $size /= $mod;
- }
- return round($size, 2) . ' ' . $units[$i];
- }
- function get_mime_type(&$struct) {
- $primary_mime_type = array("TEXT", "MULTIPART","MESSAGE", "APPLICATION", "AUDIO", "IMAGE", "VIDEO", "OTHER");
- if($struct->subtype) {
- return $primary_mime_type[(int) $struct->type] . '/' .$struct->subtype;
- }
- return "TEXT/PLAIN";
- }
- function get_part($stream, $msg_number, $mime_type, $structure = false, $part_number = false) {
- if (!$structure) {
- $structure = imap_fetchstructure($stream, $msg_number);
- }
- if ($structure) {
- if ($mime_type == get_mime_type($structure)) {
- if (!$part_number) {
- $part_number = "1";
- }
- $text = imap_fetchbody($stream, $msg_number, $part_number);
- if ($structure->encoding == 3) {
- return imap_base64($text);
- }
- else if ($structure->encoding == 4) {
- return imap_qprint($text);
- }
- else {
- return $text;
- }
- }
- if ($structure->type == 1) /* multipart */ {
- while (list($index, $sub_structure) = each($structure->parts)) {
- if ($part_number) {
- $prefix = $part_number . '.';
- }
- $data = get_part($stream, $msg_number, $mime_type, $sub_structure,$prefix . ($index + 1));
- if ($data) {
- return $data;
- }
- } // END OF WHILE
- } // END OF MULTIPART
- } // END OF STRUTURE
- return false;
- } // END OF FUNCTION
- function extract_emails_from($string){
- preg_match_all("/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i", $string, $matches);
- return $matches[0];
- }
- ?>