| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | 
							- <?php
 
- require_once('include/config.php');
 
- require_once('include/db.php');
 
- $isnew = @$_POST['isnew'];
 
- $dirpath = @$_POST['path'];
 
- if (empty($dirpath))
 
- 	die('Invalid request');
 
- if ($isnew == 'true') {
 
- 	create_db_dir($dirpath, $_POST['name'], $_POST['comment'], $_POST['tags'], $_POST['date']);
 
- } else {
 
- 	update_db_dir($dirpath, $_POST['name'], $_POST['comment'], $_POST['tags'], $_POST['date']);
 
- }
 
- $dirid = get_dir_info($dirpath)['id'];
 
- $images = get_dir_images($dirpath);
 
- $path = $config['basedir'].$dirpath.'/';
 
- $dir_handle = @opendir($path) or die('Directory open error');
 
- $i=0;
 
- $files = [];
 
- while ($file = readdir($dir_handle)) {
 
- 	if(is_dir($file))
 
- 		continue;
 
- 	$files[] = array('name' => $file, 'date' => filemtime($path.$file));
 
- }
 
- closedir($dir_handle);
 
- foreach($files as $file) {
 
- 	if (image_in_dir($file['name'], $images))
 
- 		continue;
 
- 	add_db_image($dirid, '', '', '', $file['name'], $file['date']);
 
- }
 
- $count = get_dir_count($dirpath);
 
- update_dir_count($dirpath, $count);
 
- function image_in_dir($path, $images) {
 
- 	foreach($images as $image) {
 
- 		if ($image['path'] == $path)
 
- 			return true;
 
- 	}
 
- 	return false;
 
- }
 
- ?>DONE
 
 
  |