Example #1
0
 public function setUp()
 {
     $libreofficeBinary = \OC_Helper::findBinaryPath('libreoffice');
     $openofficeBinary = $libreofficeBinary ? null : \OC_Helper::findBinaryPath('openoffice');
     if ($libreofficeBinary || $openofficeBinary) {
         parent::setUp();
         $fileName = 'testimage.odt';
         $this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
         $this->width = 595;
         $this->height = 842;
         $this->provider = new \OC\Preview\OpenDocument();
     } else {
         $this->markTestSkipped('No Office provider present');
     }
 }
Example #2
0
 public function setUp()
 {
     $avconvBinary = \OC_Helper::findBinaryPath('avconv');
     $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg');
     if ($avconvBinary || $ffmpegBinary) {
         parent::setUp();
         \OC\Preview\Movie::$avconvBinary = $avconvBinary;
         \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
         $fileName = 'testimage.mp4';
         $this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
         $this->width = 560;
         $this->height = 320;
         $this->provider = new \OC\Preview\Movie();
     } else {
         $this->markTestSkipped('No Movie provider present');
     }
 }
 public function testEmailSuccessful()
 {
     /**
      * FIXME: Disable test for systems where no sendmail is available since code is static.
      * @link https://github.com/owncloud/core/pull/12085
      */
     if (is_null(\OC_Helper::findBinaryPath('sendmail'))) {
         $this->markTestSkipped('sendmail is not available');
     }
     $randomToken = $this->container['SecureRandom'];
     $this->container['SecureRandom']->expects($this->once())->method('generate')->with('21')->will($this->returnValue('ThisIsMaybeANotSoSecretToken!'));
     $this->container['UserManager']->expects($this->once())->method('userExists')->with('ExistingUser')->will($this->returnValue(true));
     $this->container['Config']->expects($this->once())->method('getUserValue')->with('ExistingUser', 'settings', 'email')->will($this->returnValue('*****@*****.**'));
     $this->container['SecureRandom']->expects($this->once())->method('getMediumStrengthGenerator')->will($this->returnValue($randomToken));
     $this->container['Config']->expects($this->once())->method('setUserValue')->with('ExistingUser', 'owncloud', 'lostpassword', 'ThisIsMaybeANotSoSecretToken!');
     $this->container['URLGenerator']->expects($this->once())->method('linkToRouteAbsolute')->with('core.lost.resetform', array('userId' => 'ExistingUser', 'token' => 'ThisIsMaybeANotSoSecretToken!'))->will($this->returnValue('https://ownCloud.com/index.php/lostpassword/'));
     $response = $this->lostController->email('ExistingUser');
     $expectedResponse = array('status' => 'success');
     $this->assertSame($expectedResponse, $response);
 }
Example #4
0
 /**
  * check the code of an app with some static code checks
  * @param string $folder the folder of the app to check
  * @return boolean true for app is o.k. and false for app is not o.k.
  */
 public static function checkCode($appname, $folder)
 {
     $blacklist = array('OC_API::', 'OC_App::', 'OC_AppConfig::', 'OC_Avatar', 'OC_BackgroundJob::', 'OC_Config::', 'OC_DB::', 'OC_Files::', 'OC_Helper::', 'OC_Hook::', 'OC_Image::', 'OC_JSON::', 'OC_L10N::', 'OC_Log::', 'OC_Mail::', 'OC_Preferences::', 'OC_Request::', 'OC_Response::', 'OC_Template::', 'OC_User::', 'OC_Util::');
     // is the code checker enabled?
     if (OC_Config::getValue('appcodechecker', true)) {
         // check if grep is installed
         $grep = \OC_Helper::findBinaryPath('grep');
         if (!$grep) {
             OC_Log::write('core', 'grep not installed. So checking the code of the app "' . $appname . '" was not possible', OC_Log::ERROR);
             return true;
         }
         // iterate the bad patterns
         foreach ($blacklist as $bl) {
             $cmd = 'grep --include \\*.php -ri ' . escapeshellarg($bl) . ' ' . $folder . '';
             $result = exec($cmd);
             // bad pattern found
             if ($result != '') {
                 OC_Log::write('core', 'App "' . $appname . '" is using a not allowed call "' . $bl . '". Installation refused.', OC_Log::ERROR);
                 return false;
             }
         }
         return true;
     } else {
         return true;
     }
 }
OC_App::setActiveNavigationEntry("admin");
$template = new OC_Template('settings', 'admin', 'user');
$l = OC_L10N::get('settings');
$showLog = \OC::$server->getConfig()->getSystemValue('log_type', 'owncloud') === 'owncloud';
$numEntriesToLoad = 3;
$entries = OC_Log_Owncloud::getEntries($numEntriesToLoad + 1);
$entriesRemaining = count($entries) > $numEntriesToLoad;
$entries = array_slice($entries, 0, $numEntriesToLoad);
$logFilePath = OC_Log_Owncloud::getLogFilePath();
$doesLogFileExist = file_exists($logFilePath);
$logFileSize = filesize($logFilePath);
$config = \OC::$server->getConfig();
$appConfig = \OC::$server->getAppConfig();
$request = \OC::$server->getRequest();
// Should we display sendmail as an option?
$template->assign('sendmail_is_available', (bool) \OC_Helper::findBinaryPath('sendmail'));
$template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
$template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
$template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
$template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
$template->assign('entries', $entries);
$template->assign('entriesremain', $entriesRemaining);
$template->assign('logFileSize', $logFileSize);
$template->assign('doesLogFileExist', $doesLogFileExist);
Example #6
0
File: smb.php Project: evanjt/core
 /**
  * check if smbclient is installed
  */
 public static function checkDependencies()
 {
     $smbClientExists = (bool) \OC_Helper::findBinaryPath('smbclient');
     return $smbClientExists ? true : array('smbclient');
 }
 /**
  * Register the default providers (if enabled)
  */
 protected function registerCoreProviders()
 {
     if ($this->registeredCoreProviders) {
         return;
     }
     $this->registeredCoreProviders = true;
     $this->registerCoreProvider('OC\\Preview\\TXT', '/text\\/plain/');
     $this->registerCoreProvider('OC\\Preview\\MarkDown', '/text\\/(x-)?markdown/');
     $this->registerCoreProvider('OC\\Preview\\PNG', '/image\\/png/');
     $this->registerCoreProvider('OC\\Preview\\JPEG', '/image\\/jpeg/');
     $this->registerCoreProvider('OC\\Preview\\GIF', '/image\\/gif/');
     $this->registerCoreProvider('OC\\Preview\\BMP', '/image\\/bmp/');
     $this->registerCoreProvider('OC\\Preview\\XBitmap', '/image\\/x-xbitmap/');
     $this->registerCoreProvider('OC\\Preview\\MP3', '/audio\\/mpeg/');
     // SVG, Office and Bitmap require imagick
     if (extension_loaded('imagick')) {
         $checkImagick = new \Imagick();
         $imagickProviders = ['SVG' => ['mimetype' => '/image\\/svg\\+xml/', 'class' => '\\OC\\Preview\\SVG'], 'TIFF' => ['mimetype' => '/image\\/tiff/', 'class' => '\\OC\\Preview\\TIFF'], 'PDF' => ['mimetype' => '/application\\/pdf/', 'class' => '\\OC\\Preview\\PDF'], 'AI' => ['mimetype' => '/application\\/illustrator/', 'class' => '\\OC\\Preview\\Illustrator'], 'PSD' => ['mimetype' => '/application\\/x-photoshop/', 'class' => '\\OC\\Preview\\Photoshop'], 'EPS' => ['mimetype' => '/application\\/postscript/', 'class' => '\\OC\\Preview\\Postscript'], 'TTF' => ['mimetype' => '/application\\/(?:font-sfnt|x-font$)/', 'class' => '\\OC\\Preview\\Font']];
         foreach ($imagickProviders as $queryFormat => $provider) {
             $class = $provider['class'];
             if (!in_array(trim($class, '\\'), $this->getEnabledDefaultProvider())) {
                 continue;
             }
             if (count($checkImagick->queryFormats($queryFormat)) === 1) {
                 $this->registerCoreProvider($class, $provider['mimetype']);
             }
         }
         if (count($checkImagick->queryFormats('PDF')) === 1) {
             // Office previews are currently not supported on Windows
             if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) {
                 $officeFound = is_string($this->config->getSystemValue('preview_libreoffice_path', null));
                 if (!$officeFound) {
                     //let's see if there is libreoffice or openoffice on this machine
                     $whichLibreOffice = shell_exec('command -v libreoffice');
                     $officeFound = !empty($whichLibreOffice);
                     if (!$officeFound) {
                         $whichOpenOffice = shell_exec('command -v openoffice');
                         $officeFound = !empty($whichOpenOffice);
                     }
                 }
                 if ($officeFound) {
                     $this->registerCoreProvider('\\OC\\Preview\\MSOfficeDoc', '/application\\/msword/');
                     $this->registerCoreProvider('\\OC\\Preview\\MSOffice2003', '/application\\/vnd.ms-.*/');
                     $this->registerCoreProvider('\\OC\\Preview\\MSOffice2007', '/application\\/vnd.openxmlformats-officedocument.*/');
                     $this->registerCoreProvider('\\OC\\Preview\\OpenDocument', '/application\\/vnd.oasis.opendocument.*/');
                     $this->registerCoreProvider('\\OC\\Preview\\StarOffice', '/application\\/vnd.sun.xml.*/');
                 }
             }
         }
     }
     // Video requires avconv or ffmpeg and is therefor
     // currently not supported on Windows.
     if (in_array('OC\\Preview\\Movie', $this->getEnabledDefaultProvider()) && !\OC_Util::runningOnWindows()) {
         $avconvBinary = \OC_Helper::findBinaryPath('avconv');
         $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg');
         if ($avconvBinary || $ffmpegBinary) {
             // FIXME // a bit hacky but didn't want to use subclasses
             \OC\Preview\Movie::$avconvBinary = $avconvBinary;
             \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
             $this->registerCoreProvider('\\OC\\Preview\\Movie', '/video\\/.*/');
         }
     }
 }
Example #8
0
 /**
  * check if smbclient is installed
  */
 public static function checkDependencies()
 {
     return (bool) \OC_Helper::findBinaryPath('smbclient') || Server::NativeAvailable() ? true : ['smbclient'];
 }
Example #9
0
 protected static function registerCoreProviders()
 {
     self::registerProvider('OC\\Preview\\TXT');
     self::registerProvider('OC\\Preview\\MarkDown');
     self::registerProvider('OC\\Preview\\Image');
     self::registerProvider('OC\\Preview\\MP3');
     // SVG, Office and Bitmap require imagick
     if (extension_loaded('imagick')) {
         $checkImagick = new \Imagick();
         $imagickProviders = array('SVG' => 'OC\\Preview\\SVG', 'TIFF' => 'OC\\Preview\\TIFF', 'PDF' => 'OC\\Preview\\PDF', 'AI' => 'OC\\Preview\\Illustrator', 'PSD' => 'OC\\Preview\\Photoshop', 'EPS' => 'OC\\Preview\\Postscript');
         foreach ($imagickProviders as $queryFormat => $provider) {
             if (count($checkImagick->queryFormats($queryFormat)) === 1) {
                 self::registerProvider($provider);
             }
         }
         if (count($checkImagick->queryFormats('PDF')) === 1) {
             // Office previews are currently not supported on Windows
             if (!\OC_Util::runningOnWindows() && \OC_Helper::is_function_enabled('shell_exec')) {
                 $officeFound = is_string(\OC::$server->getConfig()->getSystemValue('preview_libreoffice_path', null));
                 if (!$officeFound) {
                     //let's see if there is libreoffice or openoffice on this machine
                     $whichLibreOffice = shell_exec('command -v libreoffice');
                     $officeFound = !empty($whichLibreOffice);
                     if (!$officeFound) {
                         $whichOpenOffice = shell_exec('command -v openoffice');
                         $officeFound = !empty($whichOpenOffice);
                     }
                 }
                 if ($officeFound) {
                     self::registerProvider('OC\\Preview\\MSOfficeDoc');
                     self::registerProvider('OC\\Preview\\MSOffice2003');
                     self::registerProvider('OC\\Preview\\MSOffice2007');
                     self::registerProvider('OC\\Preview\\OpenDocument');
                     self::registerProvider('OC\\Preview\\StarOffice');
                 }
             }
         }
     }
     // Video requires avconv or ffmpeg and is therefor
     // currently not supported on Windows.
     if (!\OC_Util::runningOnWindows()) {
         $avconvBinary = \OC_Helper::findBinaryPath('avconv');
         $ffmpegBinary = $avconvBinary ? null : \OC_Helper::findBinaryPath('ffmpeg');
         if ($avconvBinary || $ffmpegBinary) {
             // FIXME // a bit hacky but didn't want to use subclasses
             \OC\Preview\Movie::$avconvBinary = $avconvBinary;
             \OC\Preview\Movie::$ffmpegBinary = $ffmpegBinary;
             self::registerProvider('OC\\Preview\\Movie');
         }
     }
 }
Example #10
0
 /**
  * @param $command
  * @return bool
  */
 public function isCommandKnown($command)
 {
     $path = \OC_Helper::findBinaryPath($command);
     return $path !== null;
 }