Пример #1
0
     // file specified by roomurl column doesnt exist so clear it
     $query = 'UPDATE property SET roomurl = "" WHERE id = "' . $property['id'] . '"';
     $result = mysql_query($query, $db_connection);
     if (!$result) {
         die('Invalid query 1: ' . mysql_error());
     }
     array_push($missing_files, $roomurl_path);
 } else {
     // file exists, so rename it then create thumbnails for it
     $file_name = PhotoManager::generate_file_name($roomurl);
     $file_path = $UPLOAD_DIRECTORY . '/' . $file_name;
     $result = rename($roomurl_path, $UPLOAD_DIRECTORY . '/' . $file_name);
     if (!$result) {
         die('Could not move file');
     }
     $file_name_medium = $pm->_file_name_append($file_name, '-medium');
     $file_medium_contents = $pm->_resize_image($file_path, $pm->THUMBNAIL_MEDIUM_WIDTH, $pm->THUMBNAIL_MEDIUM_HEIGHT);
     $pm->_write_file($file_name_medium, $file_medium_contents);
     $file_name_small = $pm->_file_name_append($file_name, '-small');
     $file_small_contents = $pm->_resize_image($file_path, $pm->THUMBNAIL_SMALL_WIDTH, $pm->THUMBNAIL_SMALL_HEIGHT);
     $pm->_write_file($file_name_small, $file_small_contents);
     // create photo rows
     $property_id = $property['id'];
     $query = "INSERT INTO `photos` (`propertyid`, `filename`, `filename_medium`, `filename_small`, `default`) VALUES \n\t\t\t\t\t\t('{$property_id}', '{$file_name}', '{$file_name_medium}', '{$file_name_small}', 1);";
     $result = mysql_query($query, $db_connection);
     if (!$result) {
         die('Invalid query 2: ' . mysql_error());
     }
     // clear roomurl values
     $query = 'UPDATE property SET roomurl = "" WHERE id = "' . $property_id . '"';
     $result = mysql_query($query, $db_connection);