code beautifications
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* download.php, zarafa contact to vcf im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* 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
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
class DownloadHandler
|
||||
{
|
||||
|
||||
public static function doDownload() {
|
||||
public static function doDownload()
|
||||
{
|
||||
if (isset($_GET["token"])) {
|
||||
$token = $_GET["token"];
|
||||
} else {
|
||||
@@ -23,7 +44,7 @@ class DownloadHandler
|
||||
|
||||
$file = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD . "vcf_" . $token . ".vcf";
|
||||
|
||||
if(!file_exists($file)) { // invalid token
|
||||
if (!file_exists($file)) { // invalid token
|
||||
return false;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
* plugin.contactimporter.php, zarafa contact to vcf im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* Copyright (C) 2012-2013 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
|
||||
@@ -28,18 +28,22 @@ require_once __DIR__ . "/download.php";
|
||||
* With this plugin you can import a vcf file to your zarafa addressbook
|
||||
*
|
||||
*/
|
||||
class Plugincontactimporter extends Plugin {
|
||||
class Plugincontactimporter extends Plugin
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function Plugincontactimporter() {}
|
||||
function Plugincontactimporter()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Function initializes the Plugin and registers all hooks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function init() {
|
||||
function init()
|
||||
{
|
||||
$this->registerHook('server.core.settings.init.before');
|
||||
$this->registerHook('server.index.load.custom');
|
||||
}
|
||||
@@ -51,8 +55,9 @@ class Plugincontactimporter extends Plugin {
|
||||
* @param mixed $data object(s) related to the hook
|
||||
* @return void
|
||||
*/
|
||||
function execute($eventID, &$data) {
|
||||
switch($eventID) {
|
||||
function execute($eventID, &$data)
|
||||
{
|
||||
switch ($eventID) {
|
||||
case 'server.core.settings.init.before' :
|
||||
$this->injectPluginSettings($data);
|
||||
break;
|
||||
@@ -69,15 +74,15 @@ class Plugincontactimporter extends Plugin {
|
||||
* settings.
|
||||
* @param Array $data Reference to the data of the triggered hook
|
||||
*/
|
||||
function injectPluginSettings(&$data) {
|
||||
function injectPluginSettings(&$data)
|
||||
{
|
||||
$data['settingsObj']->addSysAdminDefaults(Array(
|
||||
'zarafa' => Array(
|
||||
'v1' => Array(
|
||||
'plugins' => Array(
|
||||
'contactimporter' => Array(
|
||||
'enable' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE,
|
||||
'enable_export' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE_EXPORT,
|
||||
'default_addressbook' => PLUGIN_CONTACTIMPORTER_DEFAULT
|
||||
'enable' => PLUGIN_CONTACTIMPORTER_USER_DEFAULT_ENABLE,
|
||||
'default_addressbook' => PLUGIN_CONTACTIMPORTER_DEFAULT
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -85,4 +90,5 @@ class Plugincontactimporter extends Plugin {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -3,7 +3,7 @@
|
||||
* upload.php, zarafa contact to vcf im/exporter
|
||||
*
|
||||
* Author: Christoph Haas <christoph.h@sprinternet.at>
|
||||
* Copyright (C) 2012-2013 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,17 +20,18 @@
|
||||
* 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) {
|
||||
/**
|
||||
* respond/echo JSON
|
||||
* @param $arr
|
||||
*/
|
||||
function respondJSON($arr)
|
||||
{
|
||||
echo json_encode($arr);
|
||||
}
|
||||
|
||||
@@ -39,11 +40,12 @@ function respondJSON($arr) {
|
||||
* @param $length the lenght of the generated string
|
||||
* @return string a random string
|
||||
*/
|
||||
function randomstring($length = 6) {
|
||||
function randomstring($length = 6)
|
||||
{
|
||||
// $chars - all allowed charakters
|
||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
srand((double)microtime() * 1000000);
|
||||
$i = 0;
|
||||
$pass = "";
|
||||
while ($i < $length) {
|
||||
@@ -58,15 +60,15 @@ function randomstring($length = 6) {
|
||||
$destpath = PLUGIN_CONTACTIMPORTER_TMP_UPLOAD;
|
||||
$destpath .= $_FILES['vcfdata']['name'] . randomstring();
|
||||
|
||||
if(is_readable ($_FILES['vcfdata']['tmp_name'])) {
|
||||
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'],$destpath);
|
||||
|
||||
if($result) {
|
||||
respondJSON(array ('success'=>true, 'vcf_file'=>$destpath));
|
||||
if (is_readable($_FILES['vcfdata']['tmp_name'])) {
|
||||
$result = move_uploaded_file($_FILES['vcfdata']['tmp_name'], $destpath);
|
||||
|
||||
if ($result) {
|
||||
respondJSON(array('success' => true, 'vcf_file' => $destpath));
|
||||
} else {
|
||||
respondJSON(array ('success'=>false,'error'=>"File could not be moved to TMP path! Check plugin config and folder permissions!"));
|
||||
respondJSON(array('success' => false, 'error' => "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' => "File could not be read by server, upload error!"));
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user