Blame view

sources/apps/ownpad_lite/ajax/settings.php 858 Bytes
42e4f8d60   Kload   add all apps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  <?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;
  
  \OCP\JSON::checkLoggedIn();
  \OCP\JSON::callCheck();
  
  $serviceUrl = UrlParam::post(UrlParam::CONFIG_URL);
  $username = UrlParam::post(UrlParam::CONFIG_USERNAME);
  
  $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));
  exit();