<?php
function form_validation($year,$campos){
foreach($campos as $valor){
if($valor == '')
return 'Remember to fill all the bold fields.';
}
$file = '../docs/'.$_FILES['archivo']['name'];
if(!eregi("^[0-9][0-9][0-9][0-9]$", $year)){
return 'The field \'year\' must contain four digits';
} else if($_FILES['archivo']['name'] != "" && !eregi(".*\.(pdf|ps)", $_FILES['archivo']['name'])){
return 'The file must be PDF or PostScript.';
} else if($update_file != 'true' && file_exists($file) && $_FILES['archivo']['name'] != '') {
return 'There\'s already a file with that name. Retry with renaming your file.';
} else {
return 'valid';
}
}
function get_section_title($pub_type){
switch($pub_type){
case 'InProceedings':
return 'An article in a conference proceedings';
case 'Article':
return 'An article from a journal or magazine';
case 'TechReport':
return 'A report published by a school or other institution';
case 'PhDThesis':
return 'A PhD thesis';
case 'Book':
return 'A book with an explicit publisher';
case 'InBook':
return 'A chapter of a book';
}
}
function copy_file($file,$uploaddir){
$uploadfile = $uploaddir.$_FILES[$file]['name'];
move_uploaded_file($_FILES[$file]['tmp_name'], $uploadfile);
}
function remove_file($archivo, $uploaddir){
$uploadfile = $uploaddir.$archivo;
unlink($uploadfile);
}
?>
|