Example #1
0
                                }
                            }
                        }
                        $tags = GetTagsFromExif($upload);
                    } else {
                        $w = 0;
                        $h = 0;
                    }
                    $message_date = date("Y-m-d H:i:s");
                    $maxorder = GetMaxMessageOrder($c, $dbh);
                    $query = "INSERT INTO message (channel_id, message_date, message_sender, message_subject, message_order) VALUES ({$c},'" . $message_date . "','" . $alias . "','',{$maxorder})";
                    $result = mysql_query($query, $dbh);
                    $current_message = mysql_insert_id();
                    $query = "INSERT INTO attachment (message_id, filename, content_type, original_filename,image_width,image_height,latitude,longitude,date_time) VALUES ({$current_message},'{$filename}','{$att_type}','{$filename}',{$w},{$h},'{$lat}','{$long}','{$datetime}')";
                    $result = mysql_query($query, $dbh);
                    IncreaseFileIndex($c, $dbh);
                    ProcessMessageTags($tags, $current_message, $dbh);
                    $tags = "";
                    $msg = "File uploader ... file upload OK.";
                }
            }
        }
    }
} else {
    $c = -1;
    $alias = "";
    $msg = "File uploader";
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Example #2
0
function ParseMultipart($type, $m, $a, $c, $folder, $tags, $dbh, $convert_to_mp3, $servpath, $sample_rate, $channel_folder, $static_map_width, $static_map_height, $api_key, $get_reverse_geocoding)
{
    if (strpos($type, "mixed") > 0) {
        $multipart = GetMultipart($a);
    } elseif (strpos($type, "alternative") > 0) {
        $multipart = GetMultipartAlt($a);
    }
    if (sizeof($multipart) > 0) {
        $date_done = false;
        for ($mi = 0; $mi < sizeof($multipart); $mi++) {
            $mtype = $multipart[$mi]["type"];
            $mattach = $multipart[$mi]["attachment"];
            $original_filename = $multipart[$mi]["name"];
            if ($mtype == "jpg" || $mtype == "jpe") {
                $subfolder = "/image/image";
                $extension = ".jpg";
                $att_type = 1;
            } elseif ($mtype == "wav") {
                $subfolder = "/sound/sound";
                $extension = ".wav";
                $att_type = 2;
            } elseif ($mtype == "amr") {
                $subfolder = "/sound/sound";
                $extension = ".amr";
                $att_type = 2;
            } elseif ($mtype == "mp3") {
                $subfolder = "/sound/sound";
                $extension = ".mp3";
                $att_type = 2;
            } elseif ($mtype == "3gp") {
                $subfolder = "/video/video";
                $extension = ".3gp";
                $att_type = 3;
            } elseif ($mtype == "mp4") {
                $subfolder = "/video/video";
                $extension = ".mp4";
                $att_type = 3;
            } elseif ($mtype == "avi") {
                $subfolder = "/video/video";
                $extension = ".avi";
                $att_type = 3;
            } elseif ($mtype == "txt" || $mtype == "text/plain") {
                $att_type = 0;
                $text = trim(utf8_decode(decode_ISO88591($mattach)));
                //tagging from mobile
                if ($tags == "") {
                    $parts = ExtractTagsFromText($text);
                    $text = $parts[0];
                    $tags = $parts[1];
                }
                //
                $text = urlencode($text);
                $query = "UPDATE message SET message_text = '{$text}' WHERE message_id = {$m}";
                $result = mysql_query($query, $dbh);
            } else {
                $att_type = 0;
            }
            if ($att_type > 0) {
                $index = GetMaxFileIndex($c, $dbh);
                $file = $folder . $subfolder . $index . $extension;
                $handle = fopen("channels/" . $file, "wb");
                $ok = fwrite($handle, imap_base64($mattach));
                fclose($handle);
                if ($extension == ".jpg") {
                    $sz = getimagesize("channels/" . $file);
                    $w = $sz[0];
                    $h = $sz[1];
                    if ($get_date_from_exif && !$date_done) {
                        GetMessageDateFromExif("channels/" . $file, $m, $dbh);
                        $date_done = true;
                    }
                } else {
                    if ($extension == ".amr" && $convert_to_mp3 == true) {
                        $file1 = $subfolder . $index . $extension;
                        $file2 = $subfolder . $index . ".mp3";
                        ConvertAMRToMP3($file1, $file2, $servpath, $channel_folder, $folder, $sample_rate);
                        $w = 0;
                        $h = 0;
                        $file = $folder . $file2;
                    } else {
                        $w = 0;
                        $h = 0;
                    }
                }
                //GeoZexe: from filename or exif
                $lat = "";
                $long = "";
                $datetime = "";
                /*
                $coord=GetCoordinatesFromFilename($original_filename);
                */
                //if (sizeof($coord)==0) {
                if ($att_type == 1) {
                    $coord = GetCoordinatesFromExif("channels/" . $file);
                    //}
                    if (sizeof($coord) == 1) {
                        $datetime = $coord[0];
                    } else {
                        if (sizeof($coord) == 2 && $coord[0] != 0 && $coord[1] != 0) {
                            $lat = $coord[0];
                            $long = $coord[1];
                        } else {
                            if (sizeof($coord) == 3 && $coord[0] != 0 && $coord[1] != 0) {
                                $lat = $coord[0];
                                $long = $coord[1];
                                $datetime = $coord[2];
                            }
                        }
                    }
                    if ($lat != "" && $long != "" && $get_reverse_geocoding == true) {
                        $address = GetReverseGeocoding($lat, $long);
                    }
                    $tags_exif = GetTagsFromExif("channels/" . $file);
                    if ($tags == "") {
                        $tags = $tags_exif;
                    } else {
                        $tags .= "," . $tags_exif;
                    }
                }
                $is_published = GetPublishedDefault($c, $dbh);
                $query = "INSERT INTO attachment (message_id, filename, content_type, original_filename,image_width,image_height,latitude,longitude,date_time,map_address,is_published) VALUES ({$m},'{$file}','{$att_type}','{$original_filename}',{$w},{$h},'{$lat}','{$long}','{$datetime}','{$address}',{$is_published})";
                $result = mysql_query($query, $dbh);
                /*
                				if ($lat!="" && $long!="") {
                					$attachment_id=mysql_insert_id();
                					$map_filename=GrabMapImage($lat,$long,$attachment_id,$static_map_width,$api_key);
                					if ($map_filename!="") {
                						$query="UPDATE attachment SET map_filename = '$map_filename' WHERE attachment_id=$attachment_id";
                						$result = mysql_query($query, $dbh);
                					}
                				}*/
                IncreaseFileIndex($c, $dbh);
            }
        }
    }
    return $tags;
}