Ejemplo n.º 1
0
 /**
  * Creates an absolute url to the given app and file.
  * @param string $app app
  * @param string $file file
  * @param array $args array with param=>value, will be appended to the returned url
  * 	The value of $args will be urlencoded
  * @return string the url
  * @since 4.0.0 - parameter $args was added in 4.5.0
  */
 public static function linkToAbsolute($app, $file, $args = array())
 {
     return \OC_Helper::linkToAbsolute($app, $file, $args);
 }
Ejemplo n.º 2
0
 /**
  * @brief Creates an absolute url
  * @param $app app
  * @param $file file
  * @returns the url
  *
  * Returns a absolute url to the given app and file.
  */
 public static function linkToAbsolute($app, $file)
 {
     return \OC_Helper::linkToAbsolute($app, $file);
 }
Ejemplo n.º 3
0
 /**
  * Check if the user is a subadmin, redirects to home if not
  *
  * @return null|boolean $groups where the current user is subadmin
  */
 public static function checkSubAdminUser()
 {
     OC_Util::checkLoggedIn();
     if (!OC_SubAdmin::isSubAdmin(OC_User::getUser())) {
         header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php'));
         exit;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * Check if the user is a subadmin, redirects to home if not
  *
  * @return null|boolean $groups where the current user is subadmin
  */
 public static function checkSubAdminUser()
 {
     OC_Util::checkLoggedIn();
     $userObject = \OC::$server->getUserSession()->getUser();
     $isSubAdmin = false;
     if ($userObject !== null) {
         $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
     }
     if (!$isSubAdmin) {
         header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php'));
         exit;
     }
     return true;
 }
Ejemplo n.º 5
0
 /**
  * @brief redirect to a error page
  */
 public static function redirectToErrorPage()
 {
     $location = \OC_Helper::linkToAbsolute('apps/files_encryption/files', 'error.php');
     $post = 0;
     if (count($_POST) > 0) {
         $post = 1;
     }
     header('Location: ' . $location . '?p=' . $post);
     exit;
 }
Ejemplo n.º 6
0
 /**
  * @brief Redirect to the user default page
  * @return void
  */
 public static function redirectToDefaultPage()
 {
     if (isset($_REQUEST['redirect_url'])) {
         $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url']));
     } else {
         if (isset(OC::$REQUESTEDAPP) && !empty(OC::$REQUESTEDAPP)) {
             $location = OC_Helper::linkToAbsolute(OC::$REQUESTEDAPP, 'index.php');
         } else {
             $defaultPage = OC_Appconfig::getValue('core', 'defaultpage');
             if ($defaultPage) {
                 $location = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/' . $defaultPage);
             } else {
                 $location = OC_Helper::linkToAbsolute('files', 'index.php');
             }
         }
     }
     OC_Log::write('core', 'redirectToDefaultPage: ' . $location, OC_Log::DEBUG);
     header('Location: ' . $location);
     exit;
 }
Ejemplo n.º 7
0
 /**
  * @small
  * test linkToAbsolute URL construction in sub directory
  * @dataProvider provideSubDirAppAbsoluteUrlParts
  */
 public function testLinkToAbsoluteSubDir($app, $file, $args, $expectedResult)
 {
     \OC::$WEBROOT = '/owncloud';
     $result = \OC_Helper::linkToAbsolute($app, $file, $args);
     $this->assertEquals($expectedResult, $result);
 }
Ejemplo n.º 8
0
 /**
  * get a list of installed web apps
  * @param string $format
  * @return string xml/json
  */
 private static function systemWebApps($format)
 {
     $login = OC_OCS::checkpassword();
     $apps = OC_App::getEnabledApps();
     $values = array();
     foreach ($apps as $app) {
         $info = OC_App::getAppInfo($app);
         if (isset($info['standalone'])) {
             $newvalue = array('name' => $info['name'], 'url' => OC_Helper::linkToAbsolute($app, ''), 'icon' => '');
             $values[] = $newvalue;
         }
     }
     $txt = OC_OCS::generatexml($format, 'ok', 100, '', $values, 'cloud', '', 2, 0, 0);
     echo $txt;
 }
Ejemplo n.º 9
0
 * Copyright (c) 2010 Frank Karlitschek karlitschek@kde.org
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
*/
$RUNTIME_NOAPPS = TRUE;
//no apps
require_once '../../lib/base.php';
// Someone lost their password:
if (isset($_POST['user'])) {
    if (OC_User::userExists($_POST['user'])) {
        $token = sha1($_POST['user'] . md5(uniqid(rand(), true)));
        OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
        $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
        if (!empty($email) and isset($_POST['sectoken']) and isset($_SESSION['sectoken']) and $_POST['sectoken'] == $_SESSION['sectoken']) {
            $link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php') . '?user='******'user'] . '&token=' . $token;
            $tmpl = new OC_Template('core/lostpassword', 'email');
            $tmpl->assign('link', $link);
            $msg = $tmpl->fetchPage();
            $l = OC_L10N::get('core');
            $from = 'lostpassword-noreply@' . OC_Helper::serverHost();
            OC_MAIL::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
            echo 'sent';
        }
        $sectoken = rand(1000000, 9999999);
        $_SESSION['sectoken'] = $sectoken;
        OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true, 'sectoken' => $sectoken));
    } else {
        $sectoken = rand(1000000, 9999999);
        $_SESSION['sectoken'] = $sectoken;
        OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false, 'sectoken' => $sectoken));
Ejemplo n.º 10
0
 * Copyright (c) 2012 Frank Karlitschek frank@owncloud.org
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
*/
$RUNTIME_NOAPPS = TRUE;
//no apps
require_once '../../lib/base.php';
// Someone lost their password:
if (isset($_POST['user'])) {
    if (OC_User::userExists($_POST['user'])) {
        $token = hash("sha256", $_POST['user'] . OC_Util::generate_random_bytes(10));
        OC_Preferences::setValue($_POST['user'], 'owncloud', 'lostpassword', $token);
        $email = OC_Preferences::getValue($_POST['user'], 'settings', 'email', '');
        if (!empty($email)) {
            $link = OC_Helper::linkToAbsolute('core/lostpassword', 'resetpassword.php', array('user' => $_POST['user'], 'token' => $token));
            $tmpl = new OC_Template('core/lostpassword', 'email');
            $tmpl->assign('link', $link, false);
            $msg = $tmpl->fetchPage();
            $l = OC_L10N::get('core');
            $from = 'lostpassword-noreply@' . OCP\Util::getServerHost();
            OC_MAIL::send($email, $_POST['user'], $l->t('ownCloud password reset'), $msg, $from, 'ownCloud');
            echo 'sent';
        }
        OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => true));
    } else {
        OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => true, 'requested' => false));
    }
} else {
    OC_Template::printGuestPage('core/lostpassword', 'lostpassword', array('error' => false, 'requested' => false));
}
Ejemplo n.º 11
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */
OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle("settings", "settings");
OC_App::setActiveNavigationEntry("help");
if (isset($_GET['mode']) and $_GET['mode'] === 'admin') {
    $url = OC_Helper::linkToAbsolute('core', 'doc/admin/index.html');
    $style1 = '';
    $style2 = ' active';
} else {
    $url = OC_Helper::linkToAbsolute('core', 'doc/user/index.html');
    $style1 = ' active';
    $style2 = '';
}
$url1 = OC_Helper::linkToRoute("settings_help") . '?mode=user';
$url2 = OC_Helper::linkToRoute("settings_help") . '?mode=admin';
$tmpl = new OC_Template("settings", "help", "user");
$tmpl->assign("admin", OC_User::isAdminUser(OC_User::getUser()));
$tmpl->assign("url", $url);
$tmpl->assign("url1", $url1);
$tmpl->assign("url2", $url2);
$tmpl->assign("style1", $style1);
$tmpl->assign("style2", $style2);
$tmpl->printPage();
Ejemplo n.º 12
0
 /**
  * redirect to a error page
  * @param Session $session
  * @param int|null $errorCode
  * @throws \Exception
  */
 public static function redirectToErrorPage(Session $session, $errorCode = null)
 {
     if ($errorCode === null) {
         $init = $session->getInitialized();
         switch ($init) {
             case \OCA\Encryption\Session::INIT_EXECUTED:
                 $errorCode = \OCA\Encryption\Crypt::ENCRYPTION_PRIVATE_KEY_NOT_VALID_ERROR;
                 break;
             case \OCA\Encryption\Session::NOT_INITIALIZED:
                 $errorCode = \OCA\Encryption\Crypt::ENCRYPTION_NOT_INITIALIZED_ERROR;
                 break;
             default:
                 $errorCode = \OCA\Encryption\Crypt::ENCRYPTION_UNKNOWN_ERROR;
         }
     }
     $location = \OC_Helper::linkToAbsolute('apps/files_encryption/files', 'error.php');
     $post = 0;
     if (count($_POST) > 0) {
         $post = 1;
     }
     if (defined('PHPUNIT_RUN') and PHPUNIT_RUN) {
         throw new \Exception("Encryption error: {$errorCode}");
     }
     header('Location: ' . $location . '?p=' . $post . '&errorCode=' . $errorCode);
     exit;
 }
Ejemplo n.º 13
0
 /**
  * Check if the user is a admin, redirects to home if not
  */
 public static function checkAdminUser()
 {
     // Check if we are a user
     self::checkLoggedIn();
     if (!OC_Group::inGroup(OC_User::getUser(), 'admin')) {
         header('Location: ' . OC_Helper::linkToAbsolute('', 'index.php'));
         exit;
     }
 }
Ejemplo n.º 14
0
<?php

/**
 * ownCloud - Files_Opds app
 *
 * Copyright (c) 2014 Frank de Lange
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
namespace OCA\Files_Opds;

$l = new \OC_L10N('files_opds');
\OCP\Util::addScript('files_opds', 'personal');
$tmpl = new \OCP\Template('files_opds', 'personal');
$opdsEnable = Config::get('enable', false);
$tmpl->assign('opdsEnable-checked', $opdsEnable === 'true' ? 'checked="checked"' : '');
$tmpl->assign('opdsEnable-value', $opdsEnable === 'true' ? '1' : '0');
$tmpl->assign('rootPath', Config::get('root_path', '/Library'));
$tmpl->assign('fileTypes', Config::get('file_types', ''));
$tmpl->assign('skipList', Config::get('skip_list', 'metadata.opf,cover.jpg'));
$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OCP\User::getDisplayName())));
$tmpl->assign('bookshelf-count', Bookshelf::count());
$tmpl->assign('feedUrl', \OC_Helper::linkToAbsolute('', 'index.php') . '/apps/files_opds/');
return $tmpl->fetchPage();
Ejemplo n.º 15
0
$RUNTIME_NOAPPS = TRUE;
//no apps, yet
require_once 'lib/base.php';
//valid user account
if (isset($_SERVER['PHP_AUTH_USER'])) {
    $authuser = $_SERVER['PHP_AUTH_USER'];
} else {
    $authuser = '';
}
if (isset($_SERVER['PHP_AUTH_PW'])) {
    $authpw = $_SERVER['PHP_AUTH_PW'];
} else {
    $authpw = '';
}
if (!OC_User::login($authuser, $authpw)) {
    header('WWW-Authenticate: Basic realm="your valid user account"');
    header('HTTP/1.0 401 Unauthorized');
    exit;
} else {
    $apps = OC_App::getEnabledApps();
    $values = array();
    foreach ($apps as $app) {
        $info = OC_App::getAppInfo($app);
        if (isset($info['standalone'])) {
            $newvalue = array('name' => $info['name'], 'url' => OC_Helper::linkToAbsolute($app, ''), 'icon' => '');
            $values[] = $newvalue;
        }
    }
    echo json_encode($values);
    exit;
}
Ejemplo n.º 16
0
<?php

/**
 * 2012 Frank Karlitschek frank@owncloud.org
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */
OC_Util::checkLoggedIn();
OC_App::loadApps();
// Load the files we need
OC_Util::addStyle("settings", "settings");
OC_App::setActiveNavigationEntry("help");
if (isset($_GET['mode']) and $_GET['mode'] == 'admin') {
    $url = OC_Helper::linkToAbsolute('core', 'doc/admin');
    $style1 = '';
    $style2 = ' pressed';
} else {
    $url = OC_Helper::linkToAbsolute('core', 'doc/user');
    $style1 = ' pressed';
    $style2 = '';
}
$url1 = OC_Helper::linkToRoute("settings_help") . '?mode=user';
$url2 = OC_Helper::linkToRoute("settings_help") . '?mode=admin';
$tmpl = new OC_Template("settings", "help", "user");
$tmpl->assign("admin", OC_User::isAdminUser(OC_User::getUser()));
$tmpl->assign("url", $url);
$tmpl->assign("url1", $url1);
$tmpl->assign("url2", $url2);
$tmpl->assign("style1", $style1);
$tmpl->assign("style2", $style2);
$tmpl->printPage();