Ejemplo n.º 1
0
 /**
  * Returns the rendered json
  * @return the rendered json
  */
 public function render()
 {
     parent::render();
     ob_start();
     if ($this->error) {
         \OCP\JSON::error($this->data);
     } else {
         \OCP\JSON::success($this->data);
     }
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Invite users to the editing session
  */
 public static function invite()
 {
     self::preDispatch();
     $invitees = @$_POST['users'];
     if (is_array($invitees)) {
         $invitees = array_unique($invitees);
         $esId = @$_POST['esId'];
         foreach ($invitees as $userId) {
             try {
                 Invite::add($esId, $userId);
             } catch (\Exception $e) {
             }
         }
     }
     \OCP\JSON::success();
 }
Ejemplo n.º 3
0
 /**
  * Send JSON response on successful login
  * @param String $uid
  */
 public static function postlogin_hook($uid)
 {
     if (!self::$_isPersona) {
         return;
     }
     \OCP\Util::writeLog(App::APP_ID, 'Check ambigous ', \OCP\Util::DEBUG);
     if (self::$_isAmbigous) {
         //Reply with error and logout
         \OCP\User::logout();
         \OCP\JSON::error(array('msg' => 'More than one user found'));
         exit;
     } else {
         \OCP\JSON::success(array('msg' => 'Access granted'));
         exit;
     }
 }
Ejemplo n.º 4
0
 public static function rename($args)
 {
     self::preDispatchGuest();
     $memberId = Helper::getArrayValueByKey($args, 'member_id');
     $name = Helper::getArrayValueByKey($_POST, 'name');
     $member = new Db\Member();
     $member->load($memberId);
     if ($member->getEsId() && $member->getStatus() == Db\Member::MEMBER_STATUS_ACTIVE && $member->getIsGuest()) {
         $guestMark = Db\Member::getGuestPostfix();
         if (substr($name, -strlen($guestMark)) !== $guestMark) {
             $name = $name . ' ' . $guestMark;
         }
         $op = new Db\Op();
         $op->changeNick($member->getEsId(), $memberId, $name);
     }
     \OCP\JSON::success();
 }
Ejemplo n.º 5
0
 /**
  * Check if we have a user to login
  * @param String $email 
  * @param String $uid 
  * @return String 
  */
 public static function apply($email, $uid = '')
 {
     //Get list of matching users
     $list = array();
     $query = \OCP\DB::prepare('SELECT userid FROM *PREFIX*preferences WHERE appid = ? AND configkey = ? AND configvalue  = ?');
     $result = $query->execute(array('settings', 'email', $email));
     while ($userid = $result->fetchOne()) {
         $list[] = $userid;
     }
     $qtyUser = count($list);
     //No users found
     if (!$qtyUser) {
         \OCP\Util::writeLog(App::APP_ID, 'No users found. Deny login.', \OCP\Util::DEBUG);
         return false;
     }
     //One user found
     if ($qtyUser == 1) {
         \OCP\Util::writeLog(App::APP_ID, 'Single user found. Entering the open space.', \OCP\Util::DEBUG);
         return $list[0];
     }
     //Multiple users found
     $currentPolicy = self::getSystemPolicy();
     $isValidUid = in_array($uid, $list);
     if ($currentPolicy == self::MULTIPLE_USERS_LIST) {
         //Do we have correct uid?
         if ($isValidUid) {
             \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Entering the open space.', \OCP\Util::DEBUG);
             return $uid;
         } else {
             \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. List them all.', \OCP\Util::DEBUG);
             \OCP\JSON::success(array('list' => $list));
             exit;
         }
     } elseif ($currentPolicy == self::MULTIPLE_USERS_FIRST) {
         \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Use first.', \OCP\Util::DEBUG);
         //not first but the best matching ;)
         $userid = $isValidUid ? $uid : $list[0];
         return $userid;
     }
     \OCP\Util::writeLog(App::APP_ID, 'Multiple users found. Deny login.', \OCP\Util::DEBUG);
     return Validator::setAmbigous();
 }
 /**
  * lists the documents the user has access to (including shared files, once the code in core has been fixed)
  * also adds session and member info for these files
  */
 public static function listAll()
 {
     self::preDispatch();
     $documents = Storage::getDocuments();
     $fileIds = array();
     //$previewAvailable = \OCP\Preview::show($file);
     foreach ($documents as $key => $document) {
         //\OCP\Preview::show($document['path']);
         $documents[$key]['icon'] = preg_replace('/\\.png$/', '.svg', \OC_Helper::mimetypeIcon($document['mimetype']));
         $fileIds[] = $document['fileid'];
     }
     usort($documents, function ($a, $b) {
         return @$b['mtime'] - @$a['mtime'];
     });
     $session = new Db_Session();
     $sessions = $session->getCollectionBy('file_id', $fileIds);
     $members = array();
     $member = new Db_Member();
     foreach ($sessions as $session) {
         $members[$session['es_id']] = $member->getActiveCollection($session['es_id']);
     }
     \OCP\JSON::success(array('documents' => $documents, 'sessions' => $sessions, 'members' => $members));
 }
Ejemplo n.º 7
0
            $link = (string) $_POST['link'];
            $file = (string) $_POST['file'];
            $to_address = (string) $_POST['toaddress'];
            $mailNotification = new \OC\Share\MailNotifications();
            $expiration = null;
            if (isset($_POST['expiration']) && $_POST['expiration'] !== '') {
                try {
                    $date = new DateTime((string) $_POST['expiration']);
                    $expiration = $date->getTimestamp();
                } catch (Exception $e) {
                    \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
                }
            }
            $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration);
            if (empty($result)) {
                \OCP\JSON::success();
            } else {
                $l = \OC::$server->getL10N('core');
                OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't send mail to following users: %s ", implode(', ', $result)))));
            }
            break;
    }
} else {
    if (isset($_GET['fetch'])) {
        switch ($_GET['fetch']) {
            case 'getItemsSharedStatuses':
                if (isset($_GET['itemType'])) {
                    $return = OCP\Share::getItemsShared((string) $_GET['itemType'], OCP\Share::FORMAT_STATUSES);
                    is_array($return) ? OC_JSON::success(array('data' => $return)) : OC_JSON::error();
                }
                break;
Ejemplo n.º 8
0
 */
namespace OCA_Updater;

\OCP\JSON::checkAdminUser();
// Url to download package e.g. http://download.owncloud.org/releases/owncloud-4.0.5.tar.bz2
$packageUrl = 'http://owncloud.org/releases/owncloud-latest.zip';
//Package version e.g. 4.0.4
$packageVersion = '';
$updateData = \OC_Updater::check();
if (isset($updateData['version'])) {
    $packageVersion = $updateData['version'];
}
if (isset($updateData['url']) && extension_loaded('bz2')) {
    $packageUrl = $updateData['url'];
}
if (!$packageVersion) {
    \OCP\JSON::error(array('msg' => 'Version not found'));
    exit;
}
$sourcePath = Downloader::getPackage($packageUrl, $packageVersion);
if (!$sourcePath) {
    \OCP\JSON::error(array('msg' => 'Unable to fetch package'));
    exit;
}
$backupPath = Backup::createBackup();
if ($backupPath) {
    Updater::update($sourcePath, $backupPath);
    \OCP\JSON::success(array());
} else {
    \OCP\JSON::error(array('msg' => 'Failed to create backup'));
}
    $errorMessage = $l->t('Please repeat the new recovery password');
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
    exit;
}
if ($_POST['newPassword'] !== $_POST['confirmPassword']) {
    $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password');
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
    exit;
}
$view = new \OC\Files\View('/');
$util = new \OCA\Files_Encryption\Util(new \OC\Files\View('/'), \OCP\User::getUser());
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$keyId = $util->getRecoveryKeyId();
$encryptedRecoveryKey = \OCA\Files_Encryption\Keymanager::getPrivateSystemKey($keyId);
$decryptedRecoveryKey = $encryptedRecoveryKey ? \OCA\Files_Encryption\Crypt::decryptPrivateKey($encryptedRecoveryKey, $oldPassword) : false;
if ($decryptedRecoveryKey) {
    $cipher = \OCA\Files_Encryption\Helper::getCipher();
    $encryptedKey = \OCA\Files_Encryption\Crypt::symmetricEncryptFileContent($decryptedRecoveryKey, $newPassword, $cipher);
    if ($encryptedKey) {
        \OCA\Files_Encryption\Keymanager::setPrivateSystemKey($encryptedKey, $keyId);
        $return = true;
    }
}
\OC_FileProxy::$enabled = $proxyStatus;
// success or failure
if ($return) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('Password successfully changed.'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Could not change the password. Maybe the old password was not correct.'))));
}
Ejemplo n.º 10
0
<?php

/**
 * ownCloud - Files_Opds App
 *
 * @author Frank de Lange
 * @copyright 2014 Frank de Lange
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Files_Opds;

$l = new \OC_L10N('files_opds');
\OCP\JSON::checkLoggedIn();
\OCP\JSON::callCheck();
Bookshelf::clear();
\OCP\JSON::success(array("data" => array("message" => $l->t("Bookshelf cleared"))));
Ejemplo n.º 11
0
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'deleteGroup');
});
$this->create('contacts_categories_rename', 'groups/rename')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'renameGroup');
});
$this->create('contacts_categories_addto', 'groups/addto/{categoryId}')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'addToGroup');
});
$this->create('contacts_categories_removefrom', 'groups/removefrom/{categoryId}')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('GroupController', 'removeFromGroup');
})->requirements(array('categoryId'));
$this->create('contacts_setpreference', 'preference/set')->post()->action(function ($params) {
    \OC::$session->close();
    $dispatcher = new Dispatcher($params);
    $dispatcher->dispatch('SettingsController', 'set');
});
$this->create('contacts_index_properties', 'indexproperties/{user}/')->post()->action(function ($params) {
    \OC::$session->close();
    // TODO: Add BackgroundJob for this.
    \OCP\Util::emitHook('OCA\\Contacts', 'indexProperties', array());
    \OCP\Config::setUserValue($params['user'], 'contacts', 'contacts_properties_indexed', 'yes');
    \OCP\JSON::success(array('isIndexed' => true));
})->requirements(array('user'))->defaults(array('user' => \OCP\User::getUser()));
Ejemplo n.º 12
0
<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Documents;

\OCP\JSON::callCheck();
$unstable = isset($_POST['unstable']) ? $_POST['unstable'] : null;
if (!is_null($unstable)) {
    \OCP\JSON::checkAdminUser();
    \OCP\Config::setAppValue('documents', 'unstable', $unstable);
    \OCP\JSON::success();
    exit;
}
if (isset($_GET['unstable'])) {
    \OCP\JSON::success(array('value' => \OCP\Config::getAppValue('documents', 'unstable', 'false')));
}
exit;
Ejemplo n.º 13
0
<?php

/**
 * Copyright (c) 2013, Sam Tuke <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * @brief Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
if (isset($_POST['userEnableRecovery']) && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])) {
    $userId = \OCP\USER::getUser();
    $view = new \OC_FilesystemView('/');
    $util = new \OCA\Encryption\Util($view, $userId);
    // Save recovery preference to DB
    $return = $util->setRecoveryForUser($_POST['userEnableRecovery']);
    if ($_POST['userEnableRecovery'] === '1') {
        $util->addRecoveryKeys();
    } else {
        $util->removeRecoveryKeys();
    }
} else {
    $return = false;
}
// Return success or failure
$return ? \OCP\JSON::success() : \OCP\JSON::error();
Ejemplo n.º 14
0
<?php

/**
* ownCloud
*
* @author Oliver Gasser
* @copyright 2013 Oliver Gasser
*
*/
// Check if this file is called by admin user, otherwise send JSON error
\OCP\JSON::checkAdminUser();
// Check if valid requesttoken was sent
\OCP\JSON::callCheck();
// Load translations
$l = OC_L10N::get('mozilla_sync');
// Get inputs and set correct settings
$quota = filter_var($_POST['quota'], FILTER_VALIDATE_INT);
if ($quota === false) {
    // Send error message
    \OCP\JSON::error(array("data" => array("message" => $l->t("Invalid input"))));
} else {
    // Update settings values
    \OCA\mozilla_sync\User::setQuota($quota);
    // Send success message
    \OCP\JSON::success(array("data" => array("message" => $l->t("Quota saved"))));
}
/* vim: set ts=4 sw=4 tw=80 noet : */
Ejemplo n.º 15
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('files_irods');
$source = $_GET['source'];
$f = \OC\Files\Filesystem::fopen($source, 'r');
$meta = stream_get_meta_data($f)['wrapper_data']->metadata;
$html = "<table id='metadata'>\n           <thead>\n             <tr>\n               <th>Key</th>\n               <th>Value</th>\n               <th>Units</th>\n               <th>Actions</th>\n             </tr>\n           </thead>\n           <tbody>";
foreach ($meta as $m) {
    $html .= sprintf("<tr><td class='editable' data-name='name' data-pk={$m->id}>%s</td>\n                    <td class='editable' data-name='value' data-pk={$m->id}>%s</td>\n                    <td class='editable' data-name='units' data-pk={$m->id}>%s</td>\n                    <td><button class='btn btn-danger remove-metadata' data-pk={$m->id}><i class='glyphicon glyphicon-remove'></i> Remove</button></td>\n                    </tr>", $m->name, $m->value, $m->units);
}
$html .= "</tbody></table>";
\OCP\JSON::success(array('data' => $html));
Ejemplo n.º 16
0
 * Copyright (c) 2013, Sam Tuke <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = \OC::$server->getL10N('files_encryption');
if (isset($_POST['userEnableRecovery']) && (0 == $_POST['userEnableRecovery'] || '1' === $_POST['userEnableRecovery'])) {
    $userId = \OCP\USER::getUser();
    $view = new \OC\Files\View('/');
    $util = new \OCA\Encryption\Util($view, $userId);
    // Save recovery preference to DB
    $return = $util->setRecoveryForUser($_POST['userEnableRecovery']);
    if ($_POST['userEnableRecovery'] === '1') {
        $util->addRecoveryKeys();
    } else {
        $util->removeRecoveryKeys();
    }
} else {
    $return = false;
}
// Return success or failure
if ($return) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('File recovery settings updated'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Could not update file recovery'))));
}
Ejemplo n.º 17
0
<?php

OCP\JSON::checkAppEnabled('files_external');
OCP\JSON::callCheck();
OCP\JSON::checkAdminUser();
$pattern = '';
$limit = null;
$offset = null;
if (isset($_GET['pattern'])) {
    $pattern = $_GET['pattern'];
}
if (isset($_GET['limit'])) {
    $limit = $_GET['limit'];
}
if (isset($_GET['offset'])) {
    $offset = $_GET['offset'];
}
$groups = \OC_Group::getGroups($pattern, $limit, $offset);
$users = \OCP\User::getDisplayNames($pattern, $limit, $offset);
$results = array('groups' => $groups, 'users' => $users);
\OCP\JSON::success($results);
Ejemplo n.º 18
0
                        $response["ops"] = array();
                        $response["head_seq"] = $currentHead;
                    }
                } else {
                    // HEADs do not match
                    $response["ops"] = $op->getOpsAfterJson($esId, $seqHead);
                    $response["head_seq"] = $currentHead;
                    $response["result"] = $hasOps ? 'conflict' : 'new_ops';
                }
                $inactiveMembers = $member->updateByTimeout($esId);
                foreach ($inactiveMembers as $inactive) {
                    $op->removeCursor($esId, $inactive);
                    $op->removeMember($esId, $inactive);
                }
            } else {
                // Error - no seq_head passed
                throw new BadRequestException();
            }
            break;
        default:
            $ex = new BadRequestException();
            $ex->setBody($request->getRawRequest());
            throw $ex;
            break;
    }
    \OCP\JSON::success($response);
} catch (BadRequestException $e) {
    header('HTTP/1.1 400: BAD REQUEST');
    \OCP\JSON::error(array('err' => 'bad request:[' . $e->getBody() . ']'));
}
exit;
Ejemplo n.º 19
0
<?php

/**
 * ownCloud - ownpad_lite plugin
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\ownpad_lite;

\OCP\JSON::checkLoggedIn();
\OCP\JSON::callCheck();
$search = UrlParam::post(UrlParam::SHARE_SEARCH);
\OCP\JSON::success(array('data' => Contacts::search($search)));
exit;
Ejemplo n.º 20
0
//Step 1 - fetch & extract
if (!App::getSource($packageUrl, $packageVersion)) {
    try {
        //Do we have any remains of the previous update attempt?
        Downloader::cleanUp($packageVersion);
        Downloader::getPackage($packageUrl, $packageVersion);
        App::setSource($packageUrl, $packageVersion, true);
        \OCP\JSON::success(array());
    } catch (\Exception $e) {
        App::log($e->getMessage());
        \OCP\JSON::error(array('msg' => 'Unable to fetch package'));
    }
    exit;
}
//Step 2 - backup & update
//Do we have any remains of the previous update attempt?
Updater::cleanUp();
try {
    $backupPath = Backup::create();
    App::setSource($packageUrl, $packageVersion, false);
    Updater::update($packageVersion, $backupPath);
    //Cleanup
    Downloader::cleanUp($packageVersion);
    Updater::cleanUp();
    \OCP\JSON::success(array('backup' => $backupPath . '.zip'));
} catch (\Exception $e) {
    App::log($e->getMessage());
    App::setSource($packageUrl, $packageVersion, false);
    \OCP\JSON::error(array('msg' => 'Failed to create backup'));
}
exit;
Ejemplo n.º 21
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
//encryption app needs to be loaded
OC_App::loadApp('files_encryption');
// init encryption app
$params = array('uid' => \OCP\User::getUser(), 'password' => $_POST['password']);
$view = new OC\Files\View('/');
$util = new \OCA\Encryption\Util($view, \OCP\User::getUser());
$l = \OC_L10N::get('settings');
$result = $util->initEncryption($params);
if ($result !== false) {
    try {
        $successful = $util->decryptAll();
    } catch (\Exception $ex) {
        \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR);
        $successful = false;
    }
    $util->closeEncryptionSession();
    if ($successful === true) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Files decrypted successfully'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, please check your owncloud.log or ask your administrator'))));
    }
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t decrypt your files, check your password and try again'))));
}
Ejemplo n.º 22
0
}
if ($_POST['recoveryPassword'] !== $_POST['confirmPassword']) {
    $errorMessage = $l->t('Repeated recovery key password does not match the provided recovery key password');
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
    exit;
}
// Enable recoveryAdmin
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
    $return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
    // Return success or failure
    if ($return) {
        $successMessage = $l->t('Recovery key successfully enabled');
    } else {
        $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!');
    }
    // Disable recoveryAdmin
} elseif (isset($_POST['adminEnableRecovery']) && '0' === $_POST['adminEnableRecovery']) {
    $return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
    if ($return) {
        $successMessage = $l->t('Recovery key successfully disabled');
    } else {
        $errorMessage = $l->t('Could not disable recovery key. Please check your recovery key password!');
    }
}
// Return success or failure
if ($return) {
    \OCP\JSON::success(array('data' => array('message' => $successMessage)));
} else {
    \OCP\JSON::error(array('data' => array('message' => $errorMessage)));
}
Ejemplo n.º 23
0
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * 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/>
 *
 */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
OCP\JSON::checkAppEnabled('files_versions');
$source = (string) $_GET['source'];
$start = (int) $_GET['start'];
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
$count = 5;
//show the newest revisions
$versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $source);
if ($versions) {
    $endReached = false;
    if (count($versions) <= $start + $count) {
        $endReached = true;
    }
    $versions = array_slice($versions, $start, $count);
    \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached)));
} else {
    \OCP\JSON::success(array('data' => array('versions' => false, 'endReached' => true)));
}
Ejemplo n.º 24
0
            }
            break;
        case 'EMAIL':
        case 'TEL':
        case 'IMPP':
        case 'URL':
            debug('Setting element: (EMAIL/TEL/ADR)' . $element);
            $property->setValue($value);
            break;
        default:
            $vcard->{$name} = $value;
            break;
    }
    setParameters($property, $parameters, true);
    // Do checksum and be happy
    if (in_array($name, $multi_properties)) {
        $checksum = substr(md5($property->serialize()), 0, 8);
    }
}
//debug('New checksum: '.$checksum);
//$vcard->children[$line] = $property; ???
try {
    VCard::edit($id, $vcard);
} catch (Exception $e) {
    bailOut($e->getMessage());
}
if (in_array($name, $multi_properties)) {
    \OCP\JSON::success(array('data' => array('line' => $line, 'checksum' => $checksum, 'oldchecksum' => $_POST['checksum'], 'lastmodified' => App::lastModified($vcard)->format('U'))));
} else {
    \OCP\JSON::success(array('data' => array('lastmodified' => App::lastModified($vcard)->format('U'))));
}
Ejemplo n.º 25
0
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * Script to handle admin settings for encrypted key recovery
 */
use OCA\Encryption;
\OCP\JSON::checkAdminUser();
\OCP\JSON::checkAppEnabled('files_encryption');
\OCP\JSON::callCheck();
$l = OC_L10N::get('files_encryption');
$return = false;
// Enable recoveryAdmin
$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId');
if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') {
    $return = \OCA\Encryption\Helper::adminEnableRecovery($recoveryKeyId, $_POST['recoveryPassword']);
    // Return success or failure
    if ($return) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully enabled'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Could not enable recovery key. Please check your recovery key password!'))));
    }
    // Disable recoveryAdmin
} elseif (isset($_POST['adminEnableRecovery']) && '0' === $_POST['adminEnableRecovery']) {
    $return = \OCA\Encryption\Helper::adminDisableRecovery($_POST['recoveryPassword']);
    // Return success or failure
    if ($return) {
        \OCP\JSON::success(array('data' => array('message' => $l->t('Recovery key successfully disabled'))));
    } else {
        \OCP\JSON::error(array('data' => array('message' => $l->t('Could not disable recovery key. Please check your recovery key password!'))));
    }
}
Ejemplo n.º 26
0
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* 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 along with this library.  If not, see <http://www.gnu.org/licenses/>.
*
*/
\OCP\JSON::checkLoggedIn();
\OCP\JSON::checkAppEnabled('activity');
\OCP\JSON::callCheck();
$l = \OCP\Util::getL10N('activity');
$token = $tokenUrl = '';
if ($_POST['enable'] === 'true') {
    // Check for collisions
    $token = \OCP\Util::generateRandomBytes();
    $preferences = new \OC\Preferences(\OC_DB::getConnection());
    $conflicts = $preferences->getUsersForValue('activity', 'rsstoken', $token);
    while (!empty($conflicts)) {
        $token = \OCP\Util::generateRandomBytes();
        $conflicts = $preferences->getUsersForValue('activity', 'rsstoken', $token);
    }
    $tokenUrl = \OC::$server->getURLGenerator()->getAbsoluteURL(\OC::$server->getURLGenerator()->linkToRoute('activity.rss', array('token' => $token)));
}
\OCP\Config::setUserValue(\OCP\User::getUser(), 'activity', 'rsstoken', $token);
\OCP\JSON::success(array('data' => array('message' => $l->t('Your settings have been updated.'), 'rsslink' => $tokenUrl)));
Ejemplo n.º 27
0
<?php

/**
 * ownCloud - ownpad_lite plugin
 *
 * @author Victor Dubiniuk
 * @copyright 2012 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\ownpad_lite;

$serviceUrl = isset($_POST[App::CONFIG_ETHERPAD_URL]) ? $_POST[App::CONFIG_ETHERPAD_URL] : false;
$username = isset($_POST[App::CONFIG_USERNAME]) ? $_POST[App::CONFIG_USERNAME] : false;
$errors = array();
$username = preg_replace('/[^0-9a-zA-Z\\.\\-_]*/i', '', $username);
if ($username) {
    App::setUsername($username);
} else {
    $errors[] = App::ERROR_USERNAME_INVALID;
}
if ($serviceUrl) {
    if (preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $serviceUrl)) {
        App::setServiceUrl($serviceUrl);
    } else {
        $errors[] = App::ERROR_URL_INVALID;
    }
}
\OCP\JSON::success(array('data' => $errors));
Ejemplo n.º 28
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l = \OC::$server->getL10N('settings');
$util = new \OCA\Files_Encryption\Util(new \OC\Files\View(), \OC_User::getUser());
$result = $util->restoreBackup('decryptAll');
if ($result) {
    \OCP\JSON::success(array('data' => array('message' => $l->t('Backups restored successfully'))));
} else {
    \OCP\JSON::error(array('data' => array('message' => $l->t('Couldn\'t restore your encryption keys, please check your owncloud.log or ask your administrator'))));
}
Ejemplo n.º 29
0
<?php

/**
 * Copyright (c) 2013, Bjoern Schiessle <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 *
 * check migration status
 */
use OCA\Encryption\Util;
\OCP\JSON::checkAppEnabled('files_encryption');
$loginname = isset($_POST['user']) ? $_POST['user'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$migrationStatus = Util::MIGRATION_COMPLETED;
if ($loginname !== '' && $password !== '') {
    $username = \OCP\User::checkPassword($loginname, $password);
    if ($username) {
        $util = new Util(new \OC\Files\View('/'), $username);
        $migrationStatus = $util->getMigrationStatus();
    }
}
\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus)));
Ejemplo n.º 30
0
<?php

/**
 * ownCloud - gsync plugin
 * 
 * @author Victor Dubiniuk
 * @copyright 2012-2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 * 
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA_Gsync;

App::initAjaxController();
// Get data
if (isset($_POST[App::GOOGLE_CLIENT_ID])) {
    App::setClientId($_POST[App::GOOGLE_CLIENT_ID]);
} elseif (isset($_POST[App::GOOGLE_SECRET])) {
    App::setSecret($_POST[App::GOOGLE_SECRET]);
} elseif (isset($_POST[App::GOOGLE_REFRESH_TOKEN])) {
    $token = App::getRefreshToken();
    Request::revokeRefreshToken($token);
    App::setRefreshToken('');
} else {
    \OCP\JSON::error(array("data" => array("message" => App::$l10n->t("Invalid request"))));
}
\OCP\JSON::success(array("data" => array("message" => App::$l10n->t("Saved"))));