if (!createDir($_CONFIG['log_dir'])) { if ($_INI['debug_ajax']) { showDebugMessage('Failed to create log_dir ' . $_CONFIG['log_dir']); } showAlertMessage("<span class='ubrError'>ERROR</span>: Failed to create log_dir", 1); } } // Purge old .link files if ($_INI['purge_link_files']) { purgeFiles($TEMP_DIR, $_INI['purge_link_limit'], 'link', $_INI['debug_ajax']); } // Purge old .redirect files if ($_INI['purge_redirect_files']) { purgeFiles($TEMP_DIR, $_INI['purge_redirect_limit'], 'redirect', $_INI['debug_ajax']); } // Show debug message if ($_INI['debug_ajax']) { showDebugMessage("Upload ID = {$UPLOAD_ID}"); } // Write link file if (writeLinkFile($_CONFIG, $DATA_DELIMITER)) { if ($_INI['debug_ajax']) { showDebugMessage('Created link file ' . $PATH_TO_LINK_FILE); } startUpload($UPLOAD_ID, $_INI['debug_upload'], $_INI['debug_ajax']); } else { if ($_INI['debug_ajax']) { showDebugMessage('Failed to create link file ' . $PATH_TO_LINK_FILE); } showAlertMessage("<span class='ubrError'>ERROR</span>: Failed to create link file: {$UPLOAD_ID}.link", 1); }
// Purge old redirect files if($PURGE_REDIRECT_FILES){ purge_ubr_files($TEMP_DIR, $PURGE_REDIRECT_LIMIT, '.redirect'); } // Generate upload id $UPLOAD_ID = generateUploadID(); // Show debug message if($DEBUG_AJAX){ showDebugMessage("Upload ID = $UPLOAD_ID"); } // Write link file if(write_link_file($TEMP_DIR, $UPLOAD_ID, $DEBUG_UPLOAD, $DELETE_LINK_FILE, $PURGE_TEMP_DIRS, $PURGE_TEMP_DIRS_LIMIT, $_CONFIG)){ if($DEBUG_AJAX){ $path_to_link_file = $TEMP_DIR . $UPLOAD_ID . ".link"; showDebugMessage("Created link file $path_to_link_file"); } startUpload($UPLOAD_ID, $DEBUG_UPLOAD); } else{ showAlertMessage("<font color='red'>ERROR</font>: Failed to open link file: $UPLOAD_ID.link", 1); } //////////////////////////////////////////////////////////FUNCTIONS ////////////////////////////////////////////////////////////////// // Create a directory function create_dir($dir){ if(is_dir($dir)){ return true; } else{ umask(0); if(@mkdir($dir, 0777)){ return true; } else{ return false; } } }