本文整理汇总了PHP中OC_Util类的典型用法代码示例。如果您正苦于以下问题:PHP OC_Util类的具体用法?PHP OC_Util怎么用?PHP OC_Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OC_Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSecret
/**
* Adds a secret to config.php
*/
private function addSecret()
{
if (\OC::$server->getConfig()->getSystemValue('secret', null) === null) {
$secret = \OC_Util::generateRandomBytes(96);
\OC::$server->getConfig()->setSystemValue('secret', $secret);
}
}
示例2: getThumbnail
/**
* {@inheritDoc}
*/
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview)
{
$this->initCmd();
if (is_null($this->cmd)) {
return false;
}
$absPath = $fileview->toTmpFile($path);
$tmpDir = \OC::$server->getTempManager()->getTempBaseDir();
$defaultParameters = ' -env:UserInstallation=file://' . escapeshellarg($tmpDir . '/owncloud-' . \OC_Util::getInstanceId() . '/') . ' --headless --nologo --nofirststartwizard --invisible --norestore --convert-to pdf --outdir ';
$clParameters = \OCP\Config::getSystemValue('preview_office_cl_parameters', $defaultParameters);
$exec = $this->cmd . $clParameters . escapeshellarg($tmpDir) . ' ' . escapeshellarg($absPath);
shell_exec($exec);
//create imagick object from pdf
$pdfPreview = null;
try {
list($dirname, , , $filename) = array_values(pathinfo($absPath));
$pdfPreview = $dirname . '/' . $filename . '.pdf';
$pdf = new \imagick($pdfPreview . '[0]');
$pdf->setImageFormat('jpg');
} catch (\Exception $e) {
unlink($absPath);
unlink($pdfPreview);
\OCP\Util::writeLog('core', $e->getmessage(), \OCP\Util::ERROR);
return false;
}
$image = new \OC_Image();
$image->loadFromData($pdf);
unlink($absPath);
unlink($pdfPreview);
if ($image->valid()) {
$image->scaleDownToFit($maxX, $maxY);
return $image;
}
return false;
}
示例3: setUp
protected function setUp()
{
parent::setUp();
if (!getenv('RUN_OBJECTSTORE_TESTS')) {
$this->markTestSkipped('objectstore tests are unreliable in some environments');
}
// reset backend
\OC_User::clearBackends();
\OC_User::useBackend('database');
// create users
$users = array('test');
foreach ($users as $userName) {
\OC_User::deleteUser($userName);
\OC_User::createUser($userName, $userName);
}
// main test user
\OC_Util::tearDownFS();
\OC_User::setUserId('');
\OC\Files\Filesystem::tearDown();
\OC_User::setUserId('test');
$config = \OC::$server->getConfig()->getSystemValue('objectstore');
$this->objectStorage = new ObjectStoreToTest($config['arguments']);
$config['objectstore'] = $this->objectStorage;
$this->instance = new ObjectStoreStorage($config);
}
示例4: init
protected function init()
{
if ($this->started) {
return;
}
$this->started = true;
// prevent php output buffering, caching and nginx buffering
OC_Util::obEnd();
header('Cache-Control: no-cache');
header('X-Accel-Buffering: no');
$this->fallback = isset($_GET['fallback']) and $_GET['fallback'] == 'true';
if ($this->fallback) {
$this->fallBackId = (int) $_GET['fallback_id'];
header("Content-Type: text/html");
echo str_repeat('<span></span>' . PHP_EOL, 10);
//dummy data to keep IE happy
} else {
header("Content-Type: text/event-stream");
}
if (!OC_Util::isCallRegistered()) {
$this->send('error', 'Possible CSRF attack. Connection will be closed.');
$this->close();
exit;
}
flush();
}
示例5: themeExist
private function themeExist($method)
{
if (OC_Util::getTheme() !== '' && method_exists('OC_Theme', $method)) {
return true;
}
return false;
}
示例6: finishSetup
public function finishSetup()
{
if (file_exists($this->autoConfigFile)) {
unlink($this->autoConfigFile);
}
\OC_Util::redirectToDefaultPage();
}
示例7: sendEmail
public static function sendEmail($args)
{
$isEncrypted = OC_App::isEnabled('files_encryption');
if (!$isEncrypted || isset($_POST['continue'])) {
$continue = true;
} else {
$continue = false;
}
if (OC_User::userExists($_POST['user']) && $continue) {
$token = hash('sha256', OC_Util::generate_random_bytes(30) . OC_Config::getValue('passwordsalt', ''));
OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', hash('sha256', $token));
// Hash the token again to prevent timing attacks
$email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
if (!empty($email)) {
$link = OC_Helper::linkToRoute('core_lostpassword_reset', array('user' => $_POST['user'], 'token' => $token));
$link = OC_Helper::makeURLAbsolute($link);
$tmpl = new OC_Template('core/lostpassword', 'email');
$tmpl->assign('link', $link, false);
$msg = $tmpl->fetchPage();
$l = OC_L10N::get('core');
$from = OCP\Util::getDefaultEmailAddress('lostpassword-noreply');
try {
OC_Mail::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
} catch (Exception $e) {
OC_Template::printErrorPage('A problem occurs during sending the e-mail please contact your administrator.');
}
self::displayLostPasswordPage(false, true);
} else {
self::displayLostPasswordPage(true, false);
}
} else {
self::displayLostPasswordPage(true, false);
}
}
示例8: __construct
function __construct()
{
$this->l = OC_L10N::get('lib');
$version = OC_Util::getVersion();
$this->defaultEntity = 'ownCloud';
/* e.g. company name, used for footers and copyright notices */
$this->defaultName = 'ownCloud';
/* short name, used when referring to the software */
$this->defaultTitle = 'ownCloud';
/* can be a longer name, for titles */
$this->defaultBaseUrl = 'https://owncloud.org';
$this->defaultSyncClientUrl = 'https://owncloud.org/sync-clients/';
$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
$this->defaultDocBaseUrl = 'http://doc.owncloud.org';
$this->defaultDocVersion = $version[0] . '.0';
// used to generate doc links
$this->defaultSlogan = $this->l->t('web services under your control');
$this->defaultLogoClaim = '';
$this->defaultMailHeaderColor = '#1d2d44';
/* header color of mail notifications */
if (class_exists('OC_Theme')) {
$this->theme = new OC_Theme();
}
}
示例9: sendResponse
/**
* Send the requested parts of the file
*/
public function sendResponse()
{
if (!preg_match('/^bytes=\\d*-\\d*(,\\d*-\\d*)*$/', $_SERVER['HTTP_RANGE'])) {
$this->sendNotSatisfiable();
}
$ranges = explode(',', substr($_SERVER['HTTP_RANGE'], 6));
foreach ($ranges as $range) {
$parts = explode('-', $range);
$start = isset($parts[0]) ? $parts[0] : 0;
$end = isset($parts[1]) ? $parts[1] : $this->getFilesize() - 1;
if ($start > $end) {
$this->sendNotSatisfiable();
}
$handle = $this->view->fopen($this->filepath, 'rb');
\fseek($handle, $start);
$buffer = \fread($handle, $end - $start);
$md5Sum = md5($buffer);
\fclose($handle);
// send the headers and data
header("Content-Length: " . $end - $start);
header("Content-md5: " . $md5Sum);
header("Accept-Ranges: bytes");
header('Content-Range: bytes ' . $start . '-' . $end . '/' . $this->getFilesize());
header("Connection: close");
header("Content-type: " . $this->getMimeType());
header('Content-Disposition: attachment; filename=' . $this->getFilename());
\OC_Util::obEnd();
echo $buffer;
flush();
}
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!$input->getOption('debug')) {
$this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
$output->writeln("Scanning <info>{$path}</info>");
});
}
$inputPath = $input->getOption('path');
$path = false;
if ($inputPath) {
$path = '/' . trim($inputPath, '/');
list(, $user, ) = explode('/', $path, 3);
$users = array($user);
} else {
if ($input->getOption('all')) {
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}
}
foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
\OC_Util::tearDownFS();
\OC_Util::setupFS($user);
$output->writeln("Start scan for <info>{$user}</info>");
$this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
}
}
示例11: getContentHtml
/**
* @param array $data
* @return string
*/
function getContentHtml($data = array())
{
$this->maxStringLen = $data['maxStringLen'];
$this->startStringLen = $data['startStringLen'];
// if problem exists
if (isset($data['msg'])) {
return '<div class="msg">' . $this->p($data['msg']) . '</div>';
}
$html = '';
$html .= '<table>';
foreach ($data['activities'] as $activity) {
$prioritystyle = 'class="activity-section group"';
if (isset($activity['priority'])) {
$prioritystyle = 'class="activity-section group priority-' . $this->p($activity['priority']);
}
$priority = $this->p($activity['priority']);
$link = $this->p($activity['link']);
$subject = $this->p($activity['subject']);
$sSub = $this->getNiceSmallText($this->p($activity['subject']));
$smallSubject = \OC_Util::sanitizeHTML($sSub);
$time = $this->getRelativeTime($this->p($activity['date']));
$html .= '<tr><td><div ' . $prioritystyle . ' subject"><a class="preview preview-dir-icon" href="' . $link . '" title="' . $subject . '">' . $smallSubject . '</a><br /><span class="hoverInfo" data-opacitynormal="0.5">' . $time . '</span></div></td></tr>';
}
$html .= '</table>';
return $html;
}
示例12: imagePath
/**
* @brief Creates path to an image
* @param string $app app
* @param string $image image name
* @return string the url
*
* Returns the path to the image.
*/
public function imagePath($app, $image)
{
// Read the selected theme from the config file
$theme = \OC_Util::getTheme();
//if a theme has a png but not an svg always use the png
$basename = substr(basename($image), 0, -4);
// Check if the app is in the app folder
if (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$image}")) {
return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$image}";
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png")) {
return \OC::$WEBROOT . "/themes/{$theme}/apps/{$app}/img/{$basename}.png";
} elseif (file_exists(\OC_App::getAppPath($app) . "/img/{$image}")) {
return \OC_App::getAppWebPath($app) . "/img/{$image}";
} elseif (!file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.svg") && file_exists(\OC_App::getAppPath($app) . "/img/{$basename}.png")) {
return \OC_App::getAppPath($app) . "/img/{$basename}.png";
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$image}")) {
return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$image}";
} elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/{$app}/img/{$basename}.png")) {
return \OC::$WEBROOT . "/themes/{$theme}/{$app}/img/{$basename}.png";
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/{$app}/img/{$image}")) {
return \OC::$WEBROOT . "/{$app}/img/{$image}";
} elseif (!empty($app) and !file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/{$app}/img/{$basename}.png")) {
return \OC::$WEBROOT . "/{$app}/img/{$basename}.png";
} elseif (file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$image}")) {
return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$image}";
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.svg") && file_exists(\OC::$SERVERROOT . "/themes/{$theme}/core/img/{$basename}.png")) {
return \OC::$WEBROOT . "/themes/{$theme}/core/img/{$basename}.png";
} elseif (file_exists(\OC::$SERVERROOT . "/core/img/{$image}")) {
return \OC::$WEBROOT . "/core/img/{$image}";
} else {
throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT);
}
}
示例13: beforeController
/**
* This runs all the security checks before a method call. The
* security checks are determined by inspecting the controller method
* annotations
* @param string/Controller $controller the controllername or string
* @param string $methodName the name of the method
* @throws AmpacheException when a security check fails
*/
public function beforeController($controller, $methodName)
{
// get annotations from comments
$annotationReader = new MethodAnnotationReader($controller, $methodName);
$this->isAmpacheCall = $annotationReader->hasAnnotation('AmpacheAPI');
// don't try to authenticate for the handshake request
if ($this->isAmpacheCall && $this->request['action'] !== 'handshake') {
$token = $this->request['auth'];
if ($token !== null && $token !== '') {
$user = $this->mapper->find($token);
if ($user !== false && array_key_exists('user_id', $user)) {
// setup the filesystem for the user - actual login isn't really needed
\OC_Util::setupFS($user['user_id']);
$this->ampacheUser->setUserId($user['user_id']);
return;
}
} else {
// for ping action without token the version information is provided
if ($this->request['action'] === 'ping') {
return;
}
}
throw new AmpacheException('Invalid Login', 401);
}
}
示例14: __construct
function __construct()
{
$this->l = \OC::$server->getL10N('lib');
$version = OC_Util::getVersion();
$this->defaultEntity = '';
/* e.g. company name, used for footers and copyright notices */
$this->defaultName = '';
/* short name, used when referring to the software */
$this->defaultTitle = '';
/* can be a longer name, for titles */
$this->defaultBaseUrl = '';
$this->defaultSyncClientUrl = '';
$this->defaultiOSClientUrl = '';
$this->defaultiTunesAppId = '';
$this->defaultAndroidClientUrl = '';
$this->defaultDocBaseUrl = 'https://doc.owncloud.org';
$this->defaultDocVersion = $version[0] . '.' . $version[1];
// used to generate doc links
$this->defaultSlogan = $this->l->t('Web Master - Mayank Agarwal <br>UI - Sambhav Kothari');
$this->defaultLogoClaim = '';
$this->defaultMailHeaderColor = '#1d2d44';
/* header color of mail notifications */
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
// prevent defaults.php from printing output
ob_start();
require_once $themePath;
ob_end_clean();
if (class_exists('OC_Theme')) {
$this->theme = new OC_Theme();
}
}
}
示例15: setUp
protected function setUp()
{
parent::setUp();
if (\OC_Util::runningOnWindows()) {
$this->markTestSkipped('[Windows] tar archives are not supported on Windows');
}
}