Added Translation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* download.php, zarafa calendar to ics im/exporter
|
||||
* download.php, Kopano calendar to ics im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* Copyright (C) 2012-2016 Christoph Haas
|
||||
@@ -25,50 +25,49 @@ namespace calendarimporter;
|
||||
|
||||
class DownloadHandler
|
||||
{
|
||||
/**
|
||||
* Download the given vcf file.
|
||||
* @return bool
|
||||
*/
|
||||
public static function doDownload()
|
||||
{
|
||||
if (isset($_GET["token"])) {
|
||||
$token = $_GET["token"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Download the given vcf file.
|
||||
*/
|
||||
public static function doDownload()
|
||||
{
|
||||
if (isset($_GET["token"])) {
|
||||
$token = $_GET["token"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($_GET["filename"])) {
|
||||
$filename = $_GET["filename"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (isset($_GET["filename"])) {
|
||||
$filename = $_GET["filename"];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// validate token
|
||||
if (!ctype_alnum($token)) { // token is a md5 hash
|
||||
return false;
|
||||
}
|
||||
// validate token
|
||||
if (!ctype_alnum($token)) { // token is a md5 hash
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics";
|
||||
$file = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD . "ics_" . $token . ".ics";
|
||||
|
||||
if (!file_exists($file)) { // invalid token
|
||||
return false;
|
||||
}
|
||||
if (!file_exists($file)) { // invalid token
|
||||
return false;
|
||||
}
|
||||
|
||||
// set headers here
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
// set headers here
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
|
||||
// no caching
|
||||
header('Expires: 0'); // set expiration time
|
||||
header('Content-Description: File Transfer');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Pragma: public');
|
||||
flush();
|
||||
// no caching
|
||||
header('Expires: 0'); // set expiration time
|
||||
header('Content-Description: File Transfer');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Pragma: public');
|
||||
flush();
|
||||
|
||||
// print the downloaded file
|
||||
readfile($file);
|
||||
ignore_user_abort(true);
|
||||
unlink($file);
|
||||
}
|
||||
// print the downloaded file
|
||||
readfile($file);
|
||||
ignore_user_abort(true);
|
||||
unlink($file);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* plugin.calendarimporter.php, zarafa calender to ics im/exporter
|
||||
* plugin.calendarimporter.php, Kopano calender to ics im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* Copyright (C) 2012-2014 Christoph Haas
|
||||
* Copyright (C) 2012-2016 Christoph Haas
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -30,65 +30,65 @@ require_once __DIR__ . "/download.php";
|
||||
*/
|
||||
class Plugincalendarimporter extends Plugin
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Function initializes the Plugin and registers all hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->registerHook('server.core.settings.init.before');
|
||||
$this->registerHook('server.index.load.custom');
|
||||
}
|
||||
/**
|
||||
* Function initializes the Plugin and registers all hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->registerHook('server.core.settings.init.before');
|
||||
$this->registerHook('server.index.load.custom');
|
||||
}
|
||||
|
||||
/**
|
||||
* Function is executed when a hook is triggered by the PluginManager
|
||||
*
|
||||
* @param string $eventID the id of the triggered hook
|
||||
* @param mixed $data object(s) related to the hook
|
||||
* @return void
|
||||
*/
|
||||
function execute($eventID, &$data)
|
||||
{
|
||||
switch ($eventID) {
|
||||
case 'server.core.settings.init.before' :
|
||||
$this->injectPluginSettings($data);
|
||||
break;
|
||||
case 'server.index.load.custom':
|
||||
if ($data['name'] == 'download_ics') {
|
||||
calendarimporter\DownloadHandler::doDownload();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Function is executed when a hook is triggered by the PluginManager
|
||||
*
|
||||
* @param string $eventID the id of the triggered hook
|
||||
* @param mixed $data object(s) related to the hook
|
||||
* @return void
|
||||
*/
|
||||
function execute($eventID, &$data)
|
||||
{
|
||||
switch ($eventID) {
|
||||
case 'server.core.settings.init.before' :
|
||||
$this->injectPluginSettings($data);
|
||||
break;
|
||||
case 'server.index.load.custom':
|
||||
if ($data['name'] == 'download_ics') {
|
||||
calendarimporter\DownloadHandler::doDownload();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the core Settings class is initialized and ready to accept sysadmin default
|
||||
* settings.
|
||||
* @param Array $data Reference to the data of the triggered hook
|
||||
*/
|
||||
function injectPluginSettings(&$data)
|
||||
{
|
||||
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||
'zarafa' => Array(
|
||||
'v1' => Array(
|
||||
'plugins' => Array(
|
||||
'calendarimporter' => Array(
|
||||
'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE,
|
||||
'enable_sync' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC,
|
||||
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT,
|
||||
'default_timezone' => PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
/**
|
||||
* Called when the core Settings class is initialized and ready to accept sysadmin default
|
||||
* settings.
|
||||
* @param Array $data Reference to the data of the triggered hook
|
||||
*/
|
||||
function injectPluginSettings(&$data)
|
||||
{
|
||||
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||
'zarafa' => Array(
|
||||
'v1' => Array(
|
||||
'plugins' => Array(
|
||||
'calendarimporter' => Array(
|
||||
'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE,
|
||||
'enable_sync' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE_SYNC,
|
||||
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT,
|
||||
'default_timezone' => PLUGIN_CALENDARIMPORTER_DEFAULT_TIMEZONE
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* upload.php, zarafa calender to ics exporter
|
||||
* upload.php, Kopano calender to ics im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* Copyright (C) 2012-2014 Christoph Haas
|
||||
* Copyright (C) 2012-2016 Christoph Haas
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -20,18 +20,19 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
/* disable error printing - otherwise json communication might break... */
|
||||
ini_set('display_errors', '0');
|
||||
|
||||
/**
|
||||
* respond/echo JSON
|
||||
* @param $arr
|
||||
*/
|
||||
function respondJSON($arr) {
|
||||
echo json_encode($arr);
|
||||
/**
|
||||
* respond/echo JSON
|
||||
* @param $arr
|
||||
*/
|
||||
function respondJSON($arr)
|
||||
{
|
||||
echo json_encode($arr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,34 +40,34 @@ function respondJSON($arr) {
|
||||
* @param $length the lenght of the generated string
|
||||
* @return string a random string
|
||||
*/
|
||||
function randomstring($length = 6) {
|
||||
// $chars - all allowed charakters
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
function randomstring($length = 6)
|
||||
{
|
||||
// $chars - all allowed charakters
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
$i = 0;
|
||||
$pass = "";
|
||||
while ($i < $length) {
|
||||
$num = rand() % strlen($chars);
|
||||
$tmp = substr($chars, $num, 1);
|
||||
$pass = $pass . $tmp;
|
||||
$i++;
|
||||
}
|
||||
return $pass;
|
||||
srand((double)microtime() * 1000000);
|
||||
$i = 0;
|
||||
$pass = "";
|
||||
while ($i < $length) {
|
||||
$num = rand() % strlen($chars);
|
||||
$tmp = substr($chars, $num, 1);
|
||||
$pass = $pass . $tmp;
|
||||
$i++;
|
||||
}
|
||||
return $pass;
|
||||
}
|
||||
|
||||
$destpath = PLUGIN_CALENDARIMPORTER_TMP_UPLOAD;
|
||||
$destpath .= $_FILES['icsdata']['name'] . randomstring();
|
||||
|
||||
if(is_readable ($_FILES['icsdata']['tmp_name'])) {
|
||||
$result = move_uploaded_file($_FILES['icsdata']['tmp_name'],$destpath);
|
||||
|
||||
if($result) {
|
||||
respondJSON(array ('success'=>true, 'ics_file'=>$destpath));
|
||||
} else {
|
||||
respondJSON(array ('success'=>false,'error'=>"File could not be moved to TMP path! Check plugin config and folder permissions!"));
|
||||
}
|
||||
if (is_readable($_FILES['icsdata']['tmp_name'])) {
|
||||
$result = move_uploaded_file($_FILES['icsdata']['tmp_name'], $destpath);
|
||||
|
||||
if ($result) {
|
||||
respondJSON(array('success' => true, 'ics_file' => $destpath));
|
||||
} else {
|
||||
respondJSON(array('success' => false, 'error' => dgettext("plugin_calendarimporter", "File could not be moved to TMP path! Check plugin config and folder permissions!")));
|
||||
}
|
||||
} else {
|
||||
respondJSON(array ('success'=>false,'error'=>"File could not be read by server, upload error!"));
|
||||
}
|
||||
?>
|
||||
respondJSON(array('success' => false, 'error' => dgettext("plugin_calendarimporter", "File could not be read by server, upload error!")));
|
||||
}
|
Reference in New Issue
Block a user