summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/application.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-26 11:37:37 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-26 11:37:37 +0100
commit06aef4e8b1f2086971c62b064f810e24785fb215 (patch)
tree67ce56c333819bb075c094848180e5090b4fafed /apps/files_sharing/application.php
parentadc986f3e4b83670f69e2ce48044595193be4e69 (diff)
downloadnextcloud-server-06aef4e8b1f2086971c62b064f810e24785fb215.tar.gz
nextcloud-server-06aef4e8b1f2086971c62b064f810e24785fb215.zip
Revert "Updating license headers"
This reverts commit 6a1a4880f0d556fb090f19a5019fec31916f5c36.
Diffstat (limited to 'apps/files_sharing/application.php')
-rw-r--r--apps/files_sharing/application.php24
1 files changed, 6 insertions, 18 deletions
diff --git a/apps/files_sharing/application.php b/apps/files_sharing/application.php
index 5e23df5cfd0..3302848106f 100644
--- a/apps/files_sharing/application.php
+++ b/apps/files_sharing/application.php
@@ -1,25 +1,13 @@
<?php
/**
- * @author Bjoern Schiessle <schiessle@owncloud.com>
- * @author Lukas Reschke <lukas@owncloud.com>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * 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/>
+ * @author Lukas Reschke
+ * @copyright 2014 Lukas Reschke lukas@owncloud.com
*
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
*/
+
namespace OCA\Files_Sharing;
use OC\AppFramework\Utility\SimpleContainer;
ace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php
/**
 * ownCloud - Addressbook
 *
 * @author Thomas Tanghus
 * @copyright 2012 Thomas Tanghus <thomas@tanghus.net>
 *
 * 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('contacts');
OCP\JSON::callCheck();

// Firefox and Konqueror tries to download application/json for me.  --Arthur
OCP\JSON::setContentTypeHeader('text/plain');
require_once 'loghandler.php';
$l10n = OC_Contacts_App::$l10n;
// If it is a Drag'n'Drop transfer it's handled here.
$fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
if ($fn) {
	if (!isset($_GET['id'])) {
		bailOut($l10n->t('No contact ID was submitted.'));
	}
	$id = $_GET['id'];
	$tmpkey = 'contact-photo-'.md5($fn);
	$data = file_get_contents('php://input');
	$image = new OC_Image();
	sleep(1); // Apparently it needs time to load the data.
	if($image->loadFromData($data)) {
		if($image->width() > 400 || $image->height() > 400) {
			$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
		}
		if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
			debug('Couldn\'t save correct image orientation: '.$tmpkey);
		}
		if(OC_Cache::set($tmpkey, $image->data(), 600)) {
			OCP\JSON::success(array(
				'data' => array(
					'mime'=>$_SERVER['CONTENT_TYPE'], 
					'name'=>$fn, 
					'id'=>$id, 
					'tmp'=>$tmpkey)));
			exit();
		} else {
			bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
		}
	} else {
		bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey);
	}
}

// Uploads from file dialog are handled here.
if (!isset($_POST['id'])) {
	bailOut($l10n->t('No contact ID was submitted.'));
}
if (!isset($_FILES['imagefile'])) {
	bailOut($l10n->t('No file was uploaded. Unknown error'));
}

$error = $_FILES['imagefile']['error'];
if($error !== UPLOAD_ERR_OK) {
	$errors = array(
		0=>$l10n->t("There is no error, the file uploaded with success"),
		1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
		2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
		3=>$l10n->t("The uploaded file was only partially uploaded"),
		4=>$l10n->t("No file was uploaded"),
		6=>$l10n->t("Missing a temporary folder")
	);
	bailOut($errors[$error]);
}
$file=$_FILES['imagefile'];

if(file_exists($file['tmp_name'])) {
	$tmpkey = 'contact-photo-'.md5(basename($file['tmp_name']));
	$image = new OC_Image();
	if($image->loadFromFile($file['tmp_name'])) {
		if($image->width() > 400 || $image->height() > 400) {
			$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
		}
		if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
			debug('Couldn\'t save correct image orientation: '.$tmpkey);
		}
		if(OC_Cache::set($tmpkey, $image->data(), 600)) {
			OCP\JSON::success(array(
				'data' => array(
					'mime'=>$file['type'],
					'size'=>$file['size'],
					'name'=>$file['name'], 
					'id'=>$_POST['id'], 
					'tmp'=>$tmpkey,
					)));
			exit();
		} else {
			bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
		}
	} else {
		bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
	}
} else {
	bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
}