distancefinder/functions.php

39 lines
894 B
PHP
Raw Normal View History

<?php
function formatAddress($address){
return ucwords(strtolower($address));
}
function getDbDistance($id1, $id2){
return (string) dbGetVal("select distance from df_distances where (id1='$id1' and id2='$id2') or (id1='$id2' and id2='$id1') limit 1");
}
function uploadFile($newname) {
$uploadErrorCodes = array(
1 => 'File exceeds upload_max_filesize',
2 => 'File exceeds MAX_FILE_SIZE',
3 => 'File only partially uploaded',
4 => 'No file uploaded',
6 => 'Missing temporary folder',
7 => 'Disk write failed',
);
if ($_FILES['upload']['name']=='') {
return;
}
if ($_FILES['upload']['error']) {
return $uploadErrorCodes[$_FILES['upload']['error']];
}
if(!move_uploaded_file($_FILES['upload']['tmp_name'], $newname)) {
return 'Server error. Could not move uploaded file.<br>';
}
}