示例#1
0
$username = $_POST['username'];
$password = $_POST['password'];
$ocUser = new OCP\User();
$auth = $password !== null ? $ocUser->checkPassword($username, $password) : OCP\User::isLoggedIn();
if (!$auth) {
    OCP\JSON::encodedPrint(array('result' => 'noauth'));
    exit;
}
$data = array();
$data['xmpp'] = array();
$data['xmpp']['url'] = OCP\Config::getAppValue('ojsxc', 'boshUrl');
$data['xmpp']['domain'] = OCP\Config::getAppValue('ojsxc', 'xmppDomain');
$data['xmpp']['resource'] = OCP\Config::getAppValue('ojsxc', 'xmppResource');
$data['xmpp']['overwrite'] = validateBoolean(OCP\Config::getAppValue('ojsxc', 'xmppOverwrite'));
$data['xmpp']['onlogin'] = true;
$options = OCP\Config::getUserValue($username, 'ojsxc', 'options');
if ($options !== null) {
    $options = json_decode($options, true);
    foreach ($options as $prop => $value) {
        if ($prop !== 'xmpp' || $data['xmpp']['overwrite']) {
            foreach ($value as $key => $v) {
                if ($v !== "") {
                    $data[$prop][$key] = $v === 'false' || $v === 'true' ? validateBoolean($v) : $v;
                }
            }
        }
    }
}
$data['loginForm']['startMinimized'] = validateBoolean(OCP\Config::getAppValue('ojsxc', 'xmppStartMinimized'));
OCP\JSON::encodedPrint(array('result' => 'success', 'data' => $data));
示例#2
0
<?php

/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
require_once 'when/When.php';
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
// Look for the calendar id
$calendar_id = OC_Calendar_App::getCalendar($_GET['calendar_id'], false, false);
if ($calendar_id !== false) {
    if (!is_numeric($calendar_id['userid']) && $calendar_id['userid'] != OCP\User::getUser()) {
        OCP\JSON::error();
        exit;
    }
} else {
    $calendar_id = $_GET['calendar_id'];
}
$start = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['start']) : new DateTime('@' . $_GET['start']);
$end = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['end']) : new DateTime('@' . $_GET['end']);
$events = OC_Calendar_App::getrequestedEvents($calendar_id, $start, $end);
$output = array();
foreach ($events as $event) {
    $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
}
OCP\JSON::encodedPrint($output);
<?php

OCP\User::checkLoggedIn();
OCP\JSON::callCheck();
$secret = OCP\Config::getAppValue('ojsxc', 'iceSecret');
$user = OCP\User::getUser();
$ttl = OCP\Config::getAppValue('ojsxc', 'iceTtl') ?: 3600 * 24;
// one day (according to TURN-REST-API)
$url = OCP\Config::getAppValue('ojsxc', 'iceUrl');
$url = $url ? "turn:{$url}" : $url;
$username = OCP\Config::getAppValue('ojsxc', 'iceUsername') ?: ($secret ? time() + $ttl . ':' . $user : $user);
$credential = OCP\Config::getAppValue('ojsxc', 'iceCredential') ?: ($secret ? base64_encode(hash_hmac('sha1', $username, $secret, true)) : '');
$data = array('ttl' => $ttl, 'iceServers' => array(array('urls' => array($url), 'credential' => $credential, 'username' => $username)));
OCP\JSON::encodedPrint($data);
示例#4
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
if (isset($_POST["count"])) {
    $count = (int) $_POST["count"];
} else {
    //$count = 10;
    //FIXME
    $count = null;
}
OCP\JSON::encodedPrint(OC_Notify::getNotifications(null, $count));
示例#5
0
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* 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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('storagecharts2');
$l = new OC_L10N('storagecharts2');
// Update and save the new configuration
if (is_numeric($_POST['s']) && in_array($_POST['k'], array('hu_size', 'hu_size_hus', 'hu_ratio'))) {
    OC_DLStCharts::setUConfValue($_POST['k'], $_POST['s']);
    switch ($_POST['k']) {
        case 'hu_size':
            OCP\JSON::encodedPrint(array('r' => OC_DLStChartsLoader::loadChart('chisto_us', $l)));
            break;
        case 'hu_size_hus':
            OCP\JSON::encodedPrint(array('r' => OC_DLStChartsLoader::loadChart('clines_usse', $l)));
            break;
    }
} else {
    // default
    OCP\JSON::encodedPrint(array('r' => OC_DLStChartsLoader::loadChart('cpie_rfsus', $l)));
}
示例#6
0
<?php

OCP\JSON::checkAppEnabled('files_versions');
$source = $_GET['source'];
list($uid, $filename) = OCA\Files_Versions\Storage::getUidAndFilename($source);
$count = 5;
//show the newest revisions
if ($versions = OCA\Files_Versions\Storage::getVersions($uid, $filename, $count)) {
    $versionsFormatted = array();
    foreach ($versions as $version) {
        $versionsFormatted[] = OCP\Util::formatDate($version['version']);
    }
    $versionsSorted = array_reverse($versions);
    if (!empty($versionsSorted)) {
        OCP\JSON::encodedPrint($versionsSorted);
    }
} else {
    return;
}
示例#7
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled("notify");
OCP\JSON::encodedPrint(OC_Notify::getUnreadNumber());
示例#8
0
        $groups[] = "<option value='" . $group . "(group)'>" . $group . " (group) </option>";
    }
    $allUsers = OC_User::getUsers();
    foreach ($allUsers as $user) {
        if ($user != $self) {
            $users[] = "<option value='" . $user . "'>" . $user . "</option>";
        }
    }
} else {
    $userGroups = OC_Group::getUserGroups($self);
    foreach ($userGroups as $group) {
        $groupUsers = OC_Group::usersInGroup($group);
        $userCount = 0;
        foreach ($groupUsers as $user) {
            if ($user != $self) {
                $users[] = "<option value='" . $user . "'>" . $user . "</option>";
                $userCount++;
            }
        }
        // Don't include the group if only the current user is a member of it
        if ($userCount > 0) {
            $groups[] = "<option value='" . $group . "(group)'>" . $group . " (group) </option>";
        }
    }
    $users = array_unique($users);
}
$users[] = "</optgroup>";
$groups[] = "</optgroup>";
$users = array_merge($users, $groups);
OCP\JSON::encodedPrint($users);
} else {
    $base = dirname($query);
}
$query = substr($query, strlen($base));
if ($base != '/') {
    $query = substr($query, 1);
}
$queryLen = strlen($query);
$query = strtolower($query);
// echo "$base - $query";
$files = array();
if (OC_Filesystem::file_exists($base) and OC_Filesystem::is_dir($base)) {
    $dh = OC_Filesystem::opendir($base);
    if ($dh) {
        if (substr($base, -1, 1) != '/') {
            $base = $base . '/';
        }
        while (($file = readdir($dh)) !== false) {
            if ($file != "." && $file != "..") {
                if (substr(strtolower($file), 0, $queryLen) == $query) {
                    $item = $base . $file;
                    if (!$dirOnly or OC_Filesystem::is_dir($item)) {
                        $files[] = (object) array('id' => $item, 'label' => $item, 'name' => $item);
                    }
                }
            }
        }
    }
}
OCP\JSON::encodedPrint($files);
示例#10
0
/**
 * ownCloud - Mail
 *
 * @author Thomas Müller
 * @copyright 2012 Thomas Müller <*****@*****.**>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
 * 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/>.
 *
 */
// Check if we are a user
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('mail');
$term = isset($_GET['term']) ? $_GET['term'] : null;
$receivers = OCA\Mail\App::getMatchingRecipient($term);
if (isset($receivers['error'])) {
    OCP\JSON::error(array('data' => array('message' => $receivers['error'])));
    exit;
}
OCP\JSON::encodedPrint($receivers);
示例#11
0
 * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('tasks');
$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$user_timezone = OC_Calendar_App::getTimezone();
$tasks = array();
foreach ($calendars as $calendar) {
    $calendar_tasks = OC_Calendar_Object::all($calendar['id']);
    foreach ($calendar_tasks as $task) {
        if ($task['objecttype'] != 'VTODO') {
            continue;
        }
        if (is_null($task['summary'])) {
            continue;
        }
        $object = OC_VObject::parse($task['calendardata']);
        $vtodo = $object->VTODO;
        try {
            $tasks[] = OC_Task_App::arrayForJSON($task['id'], $vtodo, $user_timezone);
        } catch (Exception $e) {
            OCP\Util::writeLog('tasks', $e->getMessage(), OCP\Util::ERROR);
        }
    }
}
OCP\JSON::encodedPrint($tasks);
示例#12
0
                    $song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']);
                    OCP\JSON::encodedPrint($song);
                }
            }
            break;
        case 'play':
            @ob_end_clean();
            $ftype = OC_Filesystem::getMimeType($arguments['path']);
            if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') {
                echo 'Not an audio file';
                exit;
            }
            $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
            OC_MEDIA_COLLECTION::registerPlay($songId);
            header('Content-Type:' . $ftype);
            OCP\Response::enableCaching(3600 * 24);
            // 24 hour
            header('Accept-Ranges: bytes');
            header('Content-Length: ' . OC_Filesystem::filesize($arguments['path']));
            $mtime = OC_Filesystem::filemtime($arguments['path']);
            OCP\Response::setLastModifiedHeader($mtime);
            OC_Filesystem::readfile($arguments['path']);
            exit;
        case 'find_music':
            $music = OC_FileCache::searchByMime('audio');
            $ogg = OC_FileCache::searchByMime('application', 'ogg');
            $music = array_merge($music, $ogg);
            OCP\JSON::encodedPrint($music);
            exit;
    }
}
<?php

/**
 * Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
$timeformat = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'timeformat', "24");
OCP\JSON::encodedPrint(array("timeformat" => $timeformat));
?>
 
示例#14
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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
$l = new OC_L10N('storagecharts2');
// build user list
$uids = OCP\User::getUsers();
$users = array();
foreach ($uids as $user) {
    array_push($users, '{"name":"' . $user . '","displayName":"' . OCP\User::getDisplayName($user) . '"}');
}
if (array_key_exists('s', $_POST) && array_key_exists('k', $_POST) && is_numeric($_POST['s']) && in_array($_POST['k'], array('hu_size', 'hu_size_hus', 'hu_ratio'))) {
    // Update and save the new configuration
    OC_DLStCharts::setUConfValue($_POST['k'], $_POST['s']);
    switch ($_POST['k']) {
        case 'hu_size':
            OCP\JSON::encodedPrint(array('data' => array('chart' => OC_DLStChartsLoader::loadChart('chisto_us', $l), 'users' => $users)));
            break;
        case 'hu_size_hus':
            OCP\JSON::encodedPrint(array('data' => array('chart' => OC_DLStChartsLoader::loadChart('clines_usse', $l), 'users' => $users)));
            break;
    }
} else {
    // default
    OCP\JSON::encodedPrint(array('data' => array('chart' => OC_DLStChartsLoader::loadChart('cpie_rfsus', $l), 'users' => $users)));
}
示例#15
0
<?php

/**
 * Copyright (c) 2011, 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
require_once 'when/When.php';
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('calendar');
session_write_close();
// Look for the calendar id
$calendar_id = OC_Calendar_App::getCalendar($_GET['calendar_id'], false, false);
if ($calendar_id !== false) {
    if (!is_numeric($calendar_id['userid']) && $calendar_id['userid'] != OCP\User::getUser()) {
        OCP\JSON::error();
        exit;
    }
} else {
    $calendar_id = $_GET['calendar_id'];
}
$start = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['start']) : new DateTime('@' . $_GET['start']);
$end = version_compare(PHP_VERSION, '5.3.0', '>=') ? DateTime::createFromFormat('U', $_GET['end']) : new DateTime('@' . $_GET['end']);
$events = OC_Calendar_App::getrequestedEvents($_GET['calendar_id'], $start, $end);
$output = array();
foreach ($events as $event) {
    $output = array_merge($output, OC_Calendar_App::generateEventOutput($event, $start, $end));
}
OCP\JSON::encodedPrint(OCP\Util::sanitizeHTML($output));
示例#16
0
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* 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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/

$pr = $_POST['p'];

OCP\JSON::checkAppEnabled('ocdownloader');
OCP\JSON::checkLoggedIn();

$k = Array('e' => TRUE);
if(preg_match('/^pr_([0-9]{1,4})$/', $pr, $m)){
	$p = OC_ocDownloader::getProvider($m[1]);
	if(isset($p['pr_name'])){
		$k['e'] = FALSE;
		$k['n'] = strtolower($p['pr_name']);
	}
}

OCP\JSON::encodedPrint($k);
示例#17
0
<?php

/**
 * Copyright (c) 2012 Georg Ehrke <ownclouddev at georgswebsite dot de>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
OCP\JSON::checkLoggedIn();
$firstday = OCP\Config::getUserValue(OCP\USER::getUser(), 'calendar', 'firstday', 'mo');
OCP\JSON::encodedPrint(array('firstday' => $firstday));
示例#18
0
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* 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 Lesser General Public 
* License along with this library.  If not, see <http://www.gnu.org/licenses/>.
* 
*/
OCP\JSON::checkLoggedIn();
if (in_array($_POST['k'], array('hu_size', 'sc_sort', 'hu_size_hus'))) {
    switch ($_POST['o']) {
        case 'set':
            $i = NULL;
            if (is_array($_POST['i'])) {
                $i = serialize($_POST['i']);
            } elseif (is_numeric($_POST['i'])) {
                $i = $_POST['i'];
            }
            OC_DLStCharts::setUConfValue($_POST['k'], $i);
            break;
        case 'get':
            $v = OC_DLStCharts::getUConfValue($_POST['k']);
            OCP\JSON::encodedPrint(array('r' => $v['uc_val']));
            break;
    }
}
示例#19
0
                    $error = $l->t('Upload failed. Could not find uploaded file');
                }
            } catch (Exception $ex) {
                $error = $ex->getMessage();
            }
        } else {
            // file already exists
            $meta = \OC\Files\Filesystem::getFileInfo($target);
            if ($meta === false) {
                $error = $l->t('Upload failed. Could not get file info.');
            } else {
                $data = \OCA\Files\Helper::formatFileInfo($meta);
                $data['permissions'] = $data['permissions'] & $allowedPermissions;
                $data['status'] = 'existserror';
                $data['originalname'] = $files['tmp_name'][$i];
                $data['uploadMaxFilesize'] = $maxUploadFileSize;
                $data['maxHumanFilesize'] = $maxHumanFileSize;
                $data['permissions'] = $meta['permissions'] & $allowedPermissions;
                $data['directory'] = $returnedDir;
                $result[] = $data;
            }
        }
    }
} else {
    $error = $l->t('Invalid directory.');
}
if ($error === false) {
    OCP\JSON::encodedPrint($result);
} else {
    OCP\JSON::error(array(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats))));
}
示例#20
0
<?php

OCP\JSON::checkLoggedIn();
OCP\JSON::encodedPrint((bool) OCP\Config::getUserValue(OCP\User::getUser(), 'notify', 'autorefresh', true));