"; if(is_null($index)) { if( '' == $_FILES[$field]['tmp_name'] ) return false; # echo "Passed single test 2
"; if( UPLOAD_ERR_NO_FILE == $_FILES[$field]['error'] ) return false; # echo "Passed single test 3
"; if( 0 == $_FILES[$field]['size'] ) return false; # echo "Passed single test 4
"; } else { if( !is_array($_FILES[$field]['tmp_name']) ) return false; # echo "Passed array text 2
"; if( '' == $_FILES[$field]['tmp_name'][$index] ) return false; # echo "Passed array test 3
"; if( UPLOAD_ERR_NO_FILE == $_FILES[$field]['error'][$index] ) return false; # echo "Passed array test 4
"; if( 0 == $_FILES[$field]['size'][$index] ) return false; # echo "Passed array test 5
"; } return true; } function pre_upload_rant_image( $pathtofile ) { if( !is_valid_upload() ) return array(); $image_data = getimagesize( $pathtofile ); $doing_upload = false; $upload_imagetype = null; $upload_error = false; if( false === $image_data ) { $upload_error='

Something wronky happened with that upload, getimagesize() returned false!

'; } elseif( 300 > $image_data[0] ) { $upload_error='

Image too narrow, only '.$image_data[0].'px tall. Rant saved as draft. Try uploading image again.

'; } elseif ( 245 > $image_data[1] ) { $upload_error='

Image too short, only '.$image_data[1].'px tall. Rant saved as draft. Try uploading image again.

'; } elseif( false === $image_data[2] ) { $upload_error='

Unknown image type or extension. Upload refused. Rant saved as draft. Try uploading image again.

'; } elseif( !is_uploaded_file( $pathtofile ) ) { $upload_error="

Something bad happened, that's not a valid file upload! Rant saved as draft. Try uploading image again.

"; } else { // Valid upload. It will be moved into place later. $upload_imagetype = $image_data[2]; $doing_upload = true; } return compact( "upload_error", "doing_upload", "upload_imagetype" ); } function save_stock_rant_image( $source, $rant ) { if( copy( sprintf( '%s/%s/%s', SITE_PATH_ABS,SITE_RANT,$source), SITE_PATH_ABS .'/'.get_rantimage_filename($rant) ) ) { $upload_info='

Default rant image copied.

'; } else { $upload_error='

There was an error copying the default rant image into place.

'; } return compact("upload_info","upload_error"); } function save_upload_rant_image( $source, $rant ) { $destination = SITE_PATH_ABS.'/'.get_rantimage_filename($rant); $size = getimagesize($source); if(300 == $size[0] && 245 == $size[1]) { if( move_uploaded_file($source, $destination) ) { $upload_info='

New rant image uploaded for rant '. $rant->id .'.

'; } else { $upload_error='

Something went wrong while moving the uploaded image.

'; } } else { if( crop_resize($source, $destination) ) { $upload_info='

New rant image uploaded and resized for rant '. $rant->id .'.

'; } else { $upload_error='

Something went wrong while transforming the uploaded image.

'; } } return compact("upload_info","upload_error"); } function save_upload_rant_attachment( $source, $rant ) { global $mtdb; $image_data = getimagesize( $source ); $mtdb->query( "INSERT INTO rant_attachment (rant, media) VALUES ($rant, $image_data[2])" ); $rant_attachment_id = mysql_insert_id( $mtdb->link ); if( move_uploaded_file($source, SITE_PATH_ABS.'/'.get_rantattachment_filename($rant_attachment_id) ) ) { $upload_info='

New rant attachment uploaded for rant '. $rant .'.

'; adminlog('Rant attachment uploaded', MTS_RANT, MTA_ADD); } else { $upload_error='

Something went wrong while storing the attachment.

'; } return compact("rant_attachment_id","upload_info","upload_error"); } ?>