Esempio n. 1
0
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @return integer
  */
 public static function installShippedApp($app)
 {
     //install the database
     if (is_file(OC_App::getAppPath($app) . "/appinfo/database.xml")) {
         OC_DB::createDbFromStructure(OC_App::getAppPath($app) . "/appinfo/database.xml");
     }
     //run appinfo/install.php
     if (is_file(OC_App::getAppPath($app) . "/appinfo/install.php")) {
         include OC_App::getAppPath($app) . "/appinfo/install.php";
     }
     $info = OC_App::getAppInfo($app);
     if (is_null($info)) {
         return false;
     }
     OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
     if (array_key_exists('ocsid', $info)) {
         OC_Appconfig::setValue($app, 'ocsid', $info['ocsid']);
     }
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }
Esempio n. 2
0
 /**
  * update the database for the app and call the update script
  *
  * @param string $appId
  * @return bool
  */
 public static function updateApp($appId)
 {
     if (file_exists(self::getAppPath($appId) . '/appinfo/database.xml')) {
         OC_DB::updateDbFromStructure(self::getAppPath($appId) . '/appinfo/database.xml');
     }
     if (!self::isEnabled($appId)) {
         return false;
     }
     if (file_exists(self::getAppPath($appId) . '/appinfo/update.php')) {
         self::loadApp($appId, false);
         include self::getAppPath($appId) . '/appinfo/update.php';
     }
     //set remote/public handlers
     $appData = self::getAppInfo($appId);
     if (array_key_exists('ocsid', $appData)) {
         OC_Appconfig::setValue($appId, 'ocsid', $appData['ocsid']);
     }
     foreach ($appData['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, $appId . '/' . $path);
     }
     foreach ($appData['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, $appId . '/' . $path);
     }
     self::setAppTypes($appId);
     $version = \OC_App::getAppVersion($appId);
     \OC_Appconfig::setValue($appId, 'installed_version', $version);
     return true;
 }
Esempio n. 3
0
     exit;
 }
 OC::checkMaintenanceMode();
 OC::checkSingleUserMode(true);
 $request = \OC::$server->getRequest();
 $pathInfo = $request->getPathInfo();
 if (!$pathInfo && $request->getParam('service', '') === '') {
     header('HTTP/1.0 404 Not Found');
     exit;
 } elseif ($request->getParam('service', '')) {
     $service = $request->getParam('service', '');
 } else {
     $pathInfo = trim($pathInfo, '/');
     list($service) = explode('/', $pathInfo);
 }
 $file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($service));
 if (is_null($file)) {
     header('HTTP/1.0 404 Not Found');
     exit;
 }
 $parts = explode('/', $file, 2);
 $app = $parts[0];
 // Load all required applications
 \OC::$REQUESTEDAPP = $app;
 OC_App::loadApps(array('authentication'));
 OC_App::loadApps(array('filesystem', 'logging'));
 if (!\OC::$server->getAppManager()->isInstalled($app)) {
     throw new Exception('App not installed: ' . $app);
 }
 OC_App::loadApp($app);
 OC_User::setIncognitoMode(true);
Esempio n. 4
0
 /**
  *
  * This function installs an app. All information needed are passed in the
  * associative array $data.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noinstall: boolean, if true appinfo/install.php won't be loaded
  *   - inactive: boolean, if set true the appconfig/app.sample.php won't be
  *     renamed
  *
  * This function works as follows
  *   -# fetching the file
  *   -# unzipping it
  *   -# check the code
  *   -# installing the database at appinfo/database.xml
  *   -# including appinfo/install.php
  *   -# setting the installed version
  *
  * It is the task of oc_app_install to create the tables and do whatever is
  * needed to get the app working.
  *
  * Installs an app
  * @param array $data with all information
  * @throws \Exception
  * @return integer
  */
 public static function installApp($data = array())
 {
     $l = \OC::$server->getL10N('lib');
     list($extractDir, $path) = self::downloadApp($data);
     $info = self::checkAppsIntegrity($data, $extractDir, $path);
     $basedir = OC_App::getInstallPath() . '/' . $info['id'];
     //check if the destination directory already exists
     if (is_dir($basedir)) {
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         throw new \Exception($l->t("App directory already exists"));
     }
     if (!empty($data['pretent'])) {
         return false;
     }
     //copy the app to the correct place
     if (@(!mkdir($basedir))) {
         OC_Helper::rmdirr($extractDir);
         if ($data['source'] == 'http') {
             unlink($path);
         }
         throw new \Exception($l->t("Can't create app folder. Please fix permissions. %s", array($basedir)));
     }
     $extractDir .= '/' . $info['id'];
     if (!file_exists($extractDir)) {
         OC_Helper::rmdirr($basedir);
         throw new \Exception($l->t("Archive does not contain a directory named %s", $info['id']));
     }
     OC_Helper::copyr($extractDir, $basedir);
     //remove temporary files
     OC_Helper::rmdirr($extractDir);
     //install the database
     if (is_file($basedir . '/appinfo/database.xml')) {
         if (\OC::$server->getAppConfig()->getValue($info['id'], 'installed_version') === null) {
             OC_DB::createDbFromStructure($basedir . '/appinfo/database.xml');
         } else {
             OC_DB::updateDbFromStructure($basedir . '/appinfo/database.xml');
         }
     }
     //run appinfo/install.php
     if ((!isset($data['noinstall']) or $data['noinstall'] == false) and file_exists($basedir . '/appinfo/install.php')) {
         include $basedir . '/appinfo/install.php';
     }
     //set the installed version
     \OC::$server->getAppConfig()->setValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id']));
     \OC::$server->getAppConfig()->setValue($info['id'], 'enabled', 'no');
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, $info['id'] . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, $info['id'] . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info['id'];
 }
Esempio n. 5
0
 /**
  * update the database for the app and call the update script
  * @param string $appid
  */
 public static function updateApp($appid)
 {
     if (file_exists(self::getAppPath($appid) . '/appinfo/preupdate.php')) {
         self::loadApp($appid);
         include self::getAppPath($appid) . '/appinfo/preupdate.php';
     }
     if (file_exists(self::getAppPath($appid) . '/appinfo/database.xml')) {
         OC_DB::updateDbFromStructure(self::getAppPath($appid) . '/appinfo/database.xml');
     }
     if (!self::isEnabled($appid)) {
         return;
     }
     if (file_exists(self::getAppPath($appid) . '/appinfo/update.php')) {
         self::loadApp($appid);
         include self::getAppPath($appid) . '/appinfo/update.php';
     }
     //set remote/public handlers
     $appData = self::getAppInfo($appid);
     foreach ($appData['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, $appid . '/' . $path);
     }
     foreach ($appData['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, $appid . '/' . $path);
     }
     self::setAppTypes($appid);
 }
Esempio n. 6
0
<?php

OCP\App::register(array('order' => 11, 'id' => 'user_webfinger', 'name' => 'Webfinger'));
OCP\CONFIG::setAppValue('core', 'public_host-meta', '/apps/user_webfinger/host-meta.php');
OCP\CONFIG::setAppValue('core', 'public_webfinger', '/apps/user_webfinger/webfinger.php');
 /**
  * install an app already placed in the app folder
  * @param string $app id of the app to install
  * @returns array see OC_App::getAppInfo
  */
 public static function installShippedApp($app)
 {
     //install the database
     if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml")) {
         OC_DB::createDbFromStructure(OC::$APPSROOT . "/apps/{$app}/appinfo/database.xml");
     }
     //run appinfo/install.php
     if (is_file(OC::$APPSROOT . "/apps/{$app}/appinfo/install.php")) {
         include OC::$APPSROOT . "/apps/{$app}/appinfo/install.php";
     }
     $info = OC_App::getAppInfo($app);
     OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
     //set remote/public handelers
     foreach ($info['remote'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'remote_' . $name, '/apps/' . $app . '/' . $path);
     }
     foreach ($info['public'] as $name => $path) {
         OCP\CONFIG::setAppValue('core', 'public_' . $name, '/apps/' . $app . '/' . $path);
     }
     OC_App::setAppTypes($info['id']);
     return $info;
 }
Esempio n. 8
0
<?php

$RUNTIME_NOSETUPFS = true;
$RUNTIME_NOAPPS = TRUE;
require_once 'lib/base.php';
$file = OCP\CONFIG::getAppValue('core', 'public_' . strip_tags($_GET['service']));
if (is_null($file)) {
    header('HTTP/1.0 404 Not Found');
    exit;
}
$parts = explode('/', $file);
$app = $parts[2];
OC_App::loadApp($app);
require_once OC::$APPSROOT . $file;
Esempio n. 9
0
<?php

$RUNTIME_NOSETUPFS = true;
$RUNTIME_NOAPPS = TRUE;
require_once 'lib/base.php';
if (array_key_exists('PATH_INFO', $_SERVER)) {
    $path_info = $_SERVER['PATH_INFO'];
} else {
    $path_info = substr($_SERVER['PHP_SELF'], strpos($_SERVER['PHP_SELF'], basename(__FILE__)) + strlen(basename(__FILE__)));
}
if (!($pos = strpos($path_info, '/', 1))) {
    $pos = strlen($path_info);
}
$service = substr($path_info, 1, $pos - 1);
$file = OCP\CONFIG::getAppValue('core', 'remote_' . $service);
if (is_null($file)) {
    header('HTTP/1.0 404 Not Found');
    exit;
}
$parts = explode('/', $file);
$app = $parts[2];
OC_App::loadApp($app);
$baseuri = OC::$WEBROOT . '/remote.php/' . $service . '/';
require_once OC::$APPSROOT . $file;