public function actionGetLocalFileByUrl() {
		$url = $this->request->url;
		if (!$url) {
			throw new \Exception('Need full url', Consts::ERROR_CODE_BAD_REQUEST);
		}

		$parts = parse_url($url);

		if (empty($parts['path'])) {
			throw new \Exception('Empty url', Consts::ERROR_CODE_BAD_REQUEST);
		}

		$found = false;
		$path = '';
		$root = '';

		$key = 0;

		foreach ($this->config->sources as $key => $source) {
			if ($this->request->source && $this->request->source !== 'default' && $key !== $this->request->source && $this->request->path !== './') {
				continue;
			}

			$base = parse_url($source->baseurl);

			$path = preg_replace('#^(/)?' . $base['path'] . '#', '', $parts['path']);


			$root = $source->getPath();

			if (file_exists($root . $path) && is_file($root . $path)) {
				$file = new File($root . $path);
				if ($file->isGoodFile($source)) {
					$found = true;
					break;
				}
			}
		}

		if (!$found) {
			throw new \Exception('File does not exist or is above the root of the connector', Consts::ERROR_CODE_FAILED);
		}

		return [
			'path' => str_replace($root, '', dirname($root . $path) . Consts::DS),
			'name' => basename($path),
			'source' => $key
		];
	}
public function actionGetLocalFileByUrl() {
		$url = $this->request->url;
		if (!$url) {
			throw new \Exception('Need full url', Consts::ERROR_CODE_BAD_REQUEST);
		}

		$parts = parse_url($url);

		if (empty($parts['path'])) {
			throw new \Exception('Empty url', Consts::ERROR_CODE_BAD_REQUEST);
		}

		$found = false;
		$path = '';
		$root = '';

		$key = 0;

		foreach ($this->config->sources as $key => $source) {
			if ($this->request->source && $this->request->source !== 'default' && $key !== $this->request->source && $this->request->path !== './') {
				continue;
			}

			$base = parse_url($source->baseurl);

			$path = preg_replace('#^(/)?' . $base['path'] . '#', '', $parts['path']);


			$root = $source->getPath();

			if (file_exists($root . $path) && is_file($root . $path)) {
				$file = new File($root . $path);
				if ($file->isGoodFile($source)) {
					$found = true;
					break;
				}
			}
		}

		if (!$found) {
			throw new \Exception('File does not exist or is above the root of the connector', Consts::ERROR_CODE_FAILED);
		}

		return [
			'path' => str_replace($root, '', dirname($root . $path) . Consts::DS),
			'name' => basename($path),
			'source' => $key
		];
	}
public function actionGetLocalFileByUrl ( ) { $ url = $ this -> request -> url ; if ( ! $ url ) { throw new \ Exception ( 'Need full url' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ parts = parse_url ( $ url ) ; if ( empty ( $ parts [ 'path' ] ) ) { throw new \ Exception ( 'Empty url' , Consts :: ERROR_CODE_BAD_REQUEST ) ; } $ found = false ; $ path = '' ; $ root = '' ; $ key = 0 ; foreach ( $ this -> config -> sources as $ key => $ source ) { if ( $ this -> request -> source && $ this -> request -> source !== 'default' && $ key !== $ this -> request -> source && $ this -> request -> path !== './' ) { continue ; } $ base = parse_url ( $ source -> baseurl ) ; $ path = preg_replace ( '#^(/)?' . $ base [ 'path' ] . '#' , '' , $ parts [ 'path' ] ) ; $ root = $ source -> getPath ( ) ; if ( file_exists ( $ root . $ path ) && is_file ( $ root . $ path ) ) { $ file = new File ( $ root . $ path ) ; if ( $ file -> isGoodFile ( $ source ) ) { $ found = true ; break ; } } } if ( ! $ found ) { throw new \ Exception ( 'File does not exist or is above the root of the connector' , Consts :: ERROR_CODE_FAILED ) ; } return [ 'path' => str_replace ( $ root , '' , dirname ( $ root . $ path ) . Consts :: DS ) , 'name' => basename ( $ path ) , 'source' => $ key ] ; }
Get filepath by URL for local files

@metod actionGetFileByURL
Get filepath by URL for local files