update.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // fix webdav properties, remove namespace information between curly bracket (update from OC4 to OC5)
  3. $installedVersion=OCP\Config::getAppValue('files', 'installed_version');
  4. if (version_compare($installedVersion, '1.1.4', '<')) {
  5. $query = OC_DB::prepare( "SELECT propertyname, propertypath, userid FROM `*PREFIX*properties`" );
  6. $result = $query->execute();
  7. while( $row = $result->fetchRow()){
  8. $query = OC_DB::prepare( 'UPDATE *PREFIX*properties SET propertyname = ? WHERE userid = ? AND propertypath = ?' );
  9. $query->execute( array( preg_replace("/^{.*}/", "", $row["propertyname"]),$row["userid"], $row["propertypath"] ));
  10. }
  11. }
  12. //update from OC 3
  13. //try to remove remaining files.
  14. //Give a warning if not possible
  15. $filesToRemove = array(
  16. 'ajax',
  17. 'appinfo',
  18. 'css',
  19. 'js',
  20. 'l10n',
  21. 'templates',
  22. 'admin.php',
  23. 'download.php',
  24. 'index.php',
  25. 'settings.php'
  26. );
  27. foreach($filesToRemove as $file) {
  28. $filepath = OC::$SERVERROOT . '/files/' . $file;
  29. if(!file_exists($filepath)) {
  30. continue;
  31. }
  32. $success = OCP\Files::rmdirr($filepath);
  33. if($success === false) {
  34. //probably not sufficient privileges, give up and give a message.
  35. OCP\Util::writeLog('files','Could not clean /files/ directory. Please remove everything except webdav.php from ' . OC::$SERVERROOT . '/files/', OCP\Util::ERROR);
  36. break;
  37. }
  38. }