diff options
| author | Savetheinternet <savetheinternet@tinyboard.org> | 2011-06-03 17:43:01 +1000 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@tinyboard.org> | 2011-06-03 17:43:01 +1000 |
| commit | 5c942f8c9e2305c529b83ef7a544b56febc7e3ae (patch) | |
| tree | 279e781b815b57c07b8390448912178945cb89d1 | |
| parent | 6ce881284330487fe3dff3cf740f6befc49914de (diff) | |
check if destination and source files exist before attempting to copy
| -rwxr-xr-x | kusabax.php | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/kusabax.php b/kusabax.php index 6b17499a..ebe76773 100755 --- a/kusabax.php +++ b/kusabax.php @@ -4,9 +4,9 @@ $kusabaxc = Array('db' => Array('timeout' => 5, 'persistent' => false)); $kusabaxc['db']['type'] = 'mysql'; $kusabaxc['db']['server'] = 'localhost'; - $kusabaxc['db']['user'] = 'kusaba'; - $kusabaxc['db']['password'] = 'kusaba'; - $kusabaxc['db']['database'] = 'kusaba'; + $kusabaxc['db']['user'] = ''; + $kusabaxc['db']['password'] = ''; + $kusabaxc['db']['database'] = ''; // KusabaX table prefix $kusabaxc['db']['prefix'] = ''; // Anything more to add to the DSN string (eg. port=xxx;foo=bar) @@ -222,10 +222,24 @@ $file_path = $kusabaxc['root'] . '/' . $board . '/src/' . $post['file'] . '.' . $post['file_type']; $thumb_path = $kusabaxc['root'] . '/' . $board . '/thumb/' . $post['file'] . 's.' . $post['file_type']; - $log[] = 'Copying file: <strong>' . $file_path . '</strong>'; + $to_file_path = sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']; + $to_thumb_path = sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']; - copy($file_path, sprintf($config['board_path'], $board) . $config['dir']['img'] . $post['file'] . '.' . $post['file_type']); - copy($thumb_path, sprintf($config['board_path'], $board) . $config['dir']['thumb'] . $post['file'] . '.' . $post['file_type']); + if(!file_exists($to_file_path)) { + $log[] = 'Copying file: <strong>' . $file_path . '</strong>'; + if(!@copy($file_path, $to_file_path)) { + $err = error_get_last(); + $log[] = 'Could not copy <strong>' . $file_path . '</strong>: ' . $err['message']; + } + } + + if(!file_exists($to_thumb_path)) { + $log[] = 'Copying file: <strong>' . $thumb_path . '</strong>'; + if(!@copy($thumb_path, $to_thumb_path)) { + $err = error_get_last(); + $log[] = 'Could not copy <strong>' . $thumb_path. '</strong>: ' . $err['message']; + } + } } // Insert post |
