Blame view
sources/apps/external/ajax/setsites.php
1.17 KB
|
d1bafeea1
|
1 2 3 4 5 6 7 |
<?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. */ |
|
6d9380f96
|
8 |
OCP\JSON::checkAppEnabled('external');
|
|
d1bafeea1
|
9 10 11 12 13 14 15 16 17 |
OCP\User::checkAdminUser();
OCP\JSON::callCheck();
$sites = array();
for ($i = 0; $i < sizeof($_POST['site_name']); $i++) {
if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) {
array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i])));
}
}
|
|
6d9380f96
|
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$l=OC_L10N::get('external');
foreach($sites as $site) {
if (strpos($site[1], 'https://') === 0) {
continue;
}
if (strpos($site[1], 'http://') === 0) {
continue;
}
if (strncmp($site[1], '/', 1) === 0) {
continue;
}
OC_JSON::error(array("data" => array( "message" => $l->t('Please enter valid urls - they have to start with either http://, https:// or /') )));
return;
}
|
|
d1bafeea1
|
33 |
|
|
6d9380f96
|
34 35 36 37 38 39 40 |
if (sizeof($sites) == 0) {
$appConfig = \OC::$server->getAppConfig();
$appConfig->deleteKey('external', 'sites');
} else {
OCP\Config::setAppValue('external', 'sites', json_encode($sites));
}
OC_JSON::success(array("data" => array( "message" => $l->t("External sites saved.") )));
|