Browse Source

[UPDATE] remove deprecated files

experimental
Georgi Hristov 3 years ago
parent
commit
dd661faac2
7 changed files with 0 additions and 497 deletions
  1. +0
    -37
      modules/Utils/Attachment/create_remote.php
  2. +0
    -114
      modules/Utils/Attachment/get.php
  3. +0
    -82
      modules/Utils/Attachment/get_all.php
  4. +0
    -56
      modules/Utils/Attachment/get_remote.php
  5. +0
    -41
      modules/Utils/Attachment/paste.php
  6. +0
    -20
      modules/Utils/Attachment/remote.js
  7. +0
    -147
      modules/Utils/Attachment/upload.php

+ 0
- 37
modules/Utils/Attachment/create_remote.php View File

@@ -1,37 +0,0 @@
<?php
/**
* Use this module if you want to add attachments to some page.
* @author Paul Bukowski <pbukowski@telaxus.com>
* @copyright Copyright &copy; 2008, Telaxus LLC
* @license MIT
* @version 1.0
* @package epesi-utils
* @subpackage attachment
*/
if(!isset($_REQUEST['cid']) || !isset($_REQUEST['file']))
die('Invalid usage');
$cid = $_REQUEST['cid'];
$id = $_REQUEST['file'];
if(isset($_REQUEST['description']))
$description = $_REQUEST['description'];
else
$description = '';

define('CID', $cid);
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();

if(!Acl::is_user())
die('Permission denied');
$file = DB::GetRow('SELECT uaf.attach_id, uaf.original FROM utils_attachment_file uaf WHERE uaf.id=%d',array($id));
$rec = Utils_RecordBrowserCommon::get_record('utils_attachment', $file['attach_id']);
if (!$rec) die('Invalid attachment.');
$access_fields = Utils_RecordBrowserCommon::get_access('utils_attachment', 'view', $rec);
if (!isset($access_fields['note']) || !$access_fields['note'])
die('Access forbidden');

$t = time()+3600*24*7;
print(Utils_AttachmentCommon::create_remote($id, $description, $t));

?>

+ 0
- 114
modules/Utils/Attachment/get.php View File

@@ -1,114 +0,0 @@
<?php
/**
* Use this module if you want to add attachments to some page.
* @author Paul Bukowski <pbukowski@telaxus.com>
* @copyright Copyright &copy; 2008, Telaxus LLC
* @license MIT
* @version 1.0
* @package epesi-utils
* @subpackage attachment
*/


if(!isset($_REQUEST['cid']) || !isset($_REQUEST['id']))
die('Invalid usage');
$cid = $_REQUEST['cid'];
$id = $_REQUEST['id'];
$disposition = (isset($_REQUEST['view']) && $_REQUEST['view'])?'inline':'attachment';

define('CID', $cid);
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();

if(!Acl::is_user())
die('Permission denied');
$file = DB::GetRow('SELECT uaf.attach_id, uaf.original, uaf.filestorage_id FROM utils_attachment_file uaf WHERE uaf.id=%d',array($id));
$rec = Utils_RecordBrowserCommon::get_record('utils_attachment', $file['attach_id']);
if (!$rec) die('Invalid attachment.');
$access_fields = Utils_RecordBrowserCommon::get_access('utils_attachment', 'view', $rec);
if (!isset($access_fields['note']) || !$access_fields['note'])
die('Access forbidden');

$original = $file['original'];
$local = $rec['id'];
$fsid = $file['filestorage_id'];
$crypted = $rec['crypted'];

$meta = Utils_FileStorageCommon::meta($fsid);

if(headers_sent())
die('Some data has already been output to browser, can\'t send file');

$password = '';
if($crypted)
$password = $_SESSION['client']['cp'.$rec['id']];

$t = time();
$remote_address = get_client_ip_address();
$remote_host = gethostbyaddr($remote_address);
DB::Execute('INSERT INTO utils_attachment_download(attach_file_id,created_by,created_on,download_on,description,ip_address,host_name) VALUES (%d,%d,%T,%T,%s,%s,%s)',array($id,Acl::get_user(),$t,$t,$disposition,$remote_address,$remote_host));

if (isset($_REQUEST['thumbnail'])) {
$o_filename = $meta['file'];
$f_filename = $o_filename.'_thumbnail';
if(!file_exists($f_filename)) {
if(!file_exists($o_filename))
die('File doesn\'t exists');
$image_info = getimagesize($o_filename);
$image_type = $image_info[2];
$image = false;
switch ($image_type) {
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($o_filename); break;
case IMAGETYPE_GIF: $image = imagecreatefromgif($o_filename); break;
case IMAGETYPE_PNG: $image = imagecreatefrompng($o_filename); break;
default: $buffer = file_get_contents($o_filename);
}
if ($image) {
$img_w = imagesx($image);
$img_h = imagesy($image);
$max = 300;
$w = ($img_w>=$img_h)?$max:floor($max*$img_w/$img_h);
$h = ($img_h>=$img_w)?$max:floor($max*$img_h/$img_w);
$new_image = imagecreatetruecolor($w, $h);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $w, $h, $img_w, $img_h);
switch ($image_type) {
case IMAGETYPE_JPEG: imagejpeg($new_image,$f_filename,95); break;
case IMAGETYPE_GIF: imagegif($new_image,$f_filename); break;
case IMAGETYPE_PNG: imagepng($new_image,$f_filename); break;
}
$buffer = file_get_contents($f_filename);
if($crypted) {
$buffer = Utils_AttachmentCommon::encrypt($buffer,$password);
file_put_contents($f_filename,$buffer);
}
}
} else {
$buffer = file_get_contents($f_filename);
}
} else {
$f_filename = $meta['file'];
if(!file_exists($f_filename))
die('File doesn\'t exists');
@ini_set('memory_limit',ceil(filesize($f_filename)*2/1024/1024+64).'M');
$buffer = file_get_contents($f_filename);
}

if($crypted) {
$buffer = Utils_AttachmentCommon::decrypt($buffer,$password);
if($buffer===false) die('Invalid attachment or password');
$mime = Utils_FileStorageCommon::get_mime_type(null, $original, $buffer);
} else {
$mime = Utils_FileStorageCommon::get_mime_type($f_filename, $original);
}

$expires = 24*60*60;
header('Pragma: public');
header('Cache-Control: maxage='.(24*60*60));
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+(24*60*60)) . ' GMT');
header('Content-Type: '.$mime);
header('Content-Length: '.strlen($buffer));
header('Content-disposition: '.$disposition.'; filename="'.$original.'"');
echo $buffer;

?>

+ 0
- 82
modules/Utils/Attachment/get_all.php View File

@@ -1,82 +0,0 @@
<?php
/**
* Use this module if you want to add attachments to some page.
* @author Paul Bukowski <pbukowski@telaxus.com>
* @copyright Copyright &copy; 2008, Telaxus LLC
* @license MIT
* @version 1.0
* @package epesi-utils
* @subpackage attachment
*/

if(!isset($_REQUEST['cid']) || !isset($_REQUEST['id']))
die('Invalid usage');
$cid = $_REQUEST['cid'];
$id = $_REQUEST['id'];

define('CID', $cid);
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();

if(!Acl::is_user())
die('Permission denied');
$rec = Utils_RecordBrowserCommon::get_record('utils_attachment', $id);
if (!$rec) die('Invalid attachment.');
$access_fields = Utils_RecordBrowserCommon::get_access('utils_attachment', 'view', $rec);
if (!isset($access_fields['note']) || !$access_fields['note'])
die('Access forbidden');

$password = '';
$crypted = $rec['crypted'];
if($crypted)
$password = $_SESSION['client']['cp'.$rec['id']];
$files = DB::GetAssoc('SELECT id, original, filestorage_id FROM utils_attachment_file uaf WHERE uaf.attach_id=%d AND uaf.deleted=0', array($id));

$zip_filename = tempnam("tmp", "zip");

$zip = new ZipArchive();
//create the file and throw the error if unsuccessful
if ($zip->open($zip_filename, ZIPARCHIVE::OVERWRITE )!==TRUE) {
die("cannot open $zip_filename for writing - contact with administrator");
}
//add each files of $file_name array to archive
$t = time();
$remote_address = get_client_ip_address();
$remote_host = gethostbyaddr($remote_address);
$local = $rec['id'];
$size = 0;
foreach($files as $fid=>$row)
{
try {
$meta = Utils_FileStorageCommon::meta($row['filestorage_id']);
} catch(Exception $e) { continue; }
$f_filename = $meta['file'];
$size += filesize($f_filename);
@ini_set('memory_limit',ceil($size*2/1024/1024+64).'M');
$buffer = file_get_contents($f_filename);
if($crypted) {
$buffer = Utils_AttachmentCommon::decrypt($buffer,$password);
if($buffer===false) continue;
}
DB::Execute('INSERT INTO utils_attachment_download(attach_file_id,created_by,created_on,download_on,description,ip_address,host_name) VALUES (%d,%d,%T,%T,%s,%s,%s)',array($fid,Acl::get_user(),$t,$t,'zip',$remote_address,$remote_host));
$zip->addFromString($row['original'],$buffer);
}
$zip->close();

if(headers_sent())
die('Some data has already been output to browser, can\'t send file');

header("Content-type: application/zip");
header("Content-Length: " . filesize($zip_filename));
header("Content-Disposition: attachment; filename=note_".$id.'.zip');
header("Pragma: no-cache");
header("Expires: 0");
@ob_end_flush();
@flush();
$fp = fopen($zip_filename, 'rb');
while (!feof($fp)) {
print fread($fp, 1024);
}
fclose($fp);
@unlink($zip_filename);

+ 0
- 56
modules/Utils/Attachment/get_remote.php View File

@@ -1,56 +0,0 @@
<?php
/**
* Use this module if you want to add attachments to some page.
* @author Paul Bukowski <pbukowski@telaxus.com>
* @copyright Copyright &copy; 2008, Telaxus LLC
* @license MIT
* @version 1.0
* @package epesi-utils
* @subpackage attachment
*/
if(!isset($_REQUEST['token']) || !isset($_REQUEST['id']))
die('Invalid usage');
$id = $_REQUEST['id'];
$token = $_REQUEST['token'];

define('CID', false);
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();

$query = 'SELECT ual.id as aid,uaf.id,uaf.filestorage_id,uaf.attach_id,uaf.original,uad.ip_address,uad.attach_file_id,uad.created_by,uad.created_on,uad.description FROM (utils_attachment_file uaf INNER JOIN utils_attachment_download uad ON uad.attach_file_id=uaf.id) INNER JOIN utils_attachment_data_1 ual ON uaf.attach_id=ual.id WHERE uad.id='.DB::qstr($id).' AND uad.token='.DB::qstr($token).' AND uad.expires_on>'.DB::DBTimeStamp(time()).' AND uad.remote=';
$row = DB::GetRow($query.'1');
if($row==false) {
$row = DB::GetRow($query.'2');
if($row==false)
die('No such file');
$duplicate = true;
} else $duplicate = false;
$original = $row['original'];
$file_id = $row['id'];
$local = $row['aid'];
$fsid = $row['filestorage_id'];
$filename = $local.'/'.$file_id;

if(headers_sent())
die('Some data has already been output to browser, can\'t send file');

$t = time();
$remote_address = get_client_ip_address();
$remote_host = gethostbyaddr($remote_address);
if($duplicate)
DB::Execute('INSERT INTO utils_attachment_download(attach_file_id,created_by,created_on,download_on,description,ip_address,host_name,remote) VALUES (%d,%d,%T,%T,%s,%s,%s,2)',array($file_id,$row['created_by'],$row['created_on'],$t,$row['description'],$remote_address,$remote_host));
else
DB::Execute('UPDATE utils_attachment_download SET remote=2, download_on=%T, ip_address=%s, host_name=%s WHERE id=%d',array($t,$remote_address,$remote_host,$id));
$meta = Utils_FileStorageCommon::meta($fsid);
$f_filename = $meta['file'];
if(!file_exists($f_filename))
die('File doesn\'t exists');

@ini_set('memory_limit',ceil(filesize($f_filename)/1024/1024+64).'M');
$buffer = file_get_contents($f_filename);
header('Content-Type: '.Utils_FileStorageCommon::get_mime_type($f_filename,$original));
header('Content-Length: '.strlen($buffer));
header('Content-disposition: attachment; filename="'.$original.'"');
echo $buffer;
?>

+ 0
- 41
modules/Utils/Attachment/paste.php View File

@@ -1,41 +0,0 @@
<?php
/**
* Use this module if you want to add attachments to some page.
* @author Arkadiusz Bisaga <abisaga@telaxus.com>
* @copyright Copyright &copy; 2012, Telaxus LLC
* @license MIT
* @version 1.0
* @package epesi-utils
* @subpackage attachment
*/
if(!isset($_REQUEST['cid']) || !isset($_REQUEST['data']))
die('Invalid usage');
define('CID', $_REQUEST['cid']);
define('READ_ONLY_SESSION',true);
require_once('../../../include.php');
ModuleManager::load_modules();
if(!Acl::is_user())
die('Permission denied');
$targetDir = Utils_AttachmentCommon::get_temp_dir();
Utils_AttachmentCommon::cleanup_paste_temp();
DB::Execute('INSERT INTO utils_attachment_clipboard (created_by) VALUES (%d)', array(Acl::get_user()));
$id = DB::Insert_ID('utils_attachment_clipboard', 'id');
$filename = 'clipboard'.'_'.$id;
$f_filename = $targetDir.'/'.$filename;
DB::Execute('UPDATE utils_attachment_clipboard SET filename=%s WHERE id=%d', array($f_filename, $id));
$data = explode(',', $_REQUEST['data']);
if (!isset($data[1])) die('Invalid file');
file_put_contents($f_filename, base64_decode($data[1]));
die(json_encode(array('id'=>$id, 'name'=>__('clipboard').'.png')));
?>

+ 0
- 20
modules/Utils/Attachment/remote.js View File

@@ -1,20 +0,0 @@
utils_attachment_get_link = function(attach_file_id,cidd,desc) {
new Ajax.Request('modules/Utils/Attachment/create_remote.php', {
method: 'post',
parameters: {
file: attach_file_id,
cid: cidd,
description: desc
},
onComplete: function(t) {
prompt('Url to this file (valid for 1 week)',t.responseText);
},
onException: function(t,e) {
throw(e);
},
onFailure: function(t) {
alert('Failure ('+t.status+')');
Epesi.text(t.responseText,'error_box','p');
}
});
};

+ 0
- 147
modules/Utils/Attachment/upload.php View File

@@ -1,147 +0,0 @@
<?php
/**
* upload.php
*
* Copyright 2009, Moxiecode Systems AB
* Released under GPL License.
*
* License: http://www.plupload.com/license
* Contributing: http://www.plupload.com/contributing
*/
// HTTP headers for no cache etc
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if(!isset($_GET['CID']))
die('Invalid request');
define('CID', $_GET['CID']);
//define('READ_ONLY_SESSION',1);
require_once('../../../include.php');
ModuleManager::load_modules();
if(!Acl::is_user())
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Unauthorised access."}, "id" : "id"}');
// Settings
$targetDir = Utils_AttachmentCommon::get_temp_dir();
$cleanupTargetDir = true; // Remove old files
$maxFileAge = 5 * 3600; // Temp file age in seconds
// 5 minutes execution time
@set_time_limit(5 * 60);
// Uncomment this one to fake upload time
// usleep(5000);
// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
$chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;
$orig_fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
// Clean the fileName for security reasons
$fileName = md5($orig_fileName . microtime());
// Make sure the fileName is unique but only if chunking is disabled
if ($chunks < 2 && file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName)) {
$count = 1;
while (file_exists($targetDir . DIRECTORY_SEPARATOR . $fileName . '_' . $count))
$count++;
$fileName = $fileName . '_' . $count;
}
$filePath = $targetDir . DIRECTORY_SEPARATOR . $fileName;
// Create target dir
if (!file_exists($targetDir))
@mkdir($targetDir);
// Remove old temp files
if ($cleanupTargetDir && is_dir($targetDir) && ($dir = opendir($targetDir))) {
while (($file = readdir($dir)) !== false) {
$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
// Remove temp file if it is older than the max age and is not the current file
if (filemtime($tmpfilePath) < time() - $maxFileAge) {
@unlink($tmpfilePath);
}
}
closedir($dir);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
if (isset($_SERVER["CONTENT_TYPE"]))
$contentType = $_SERVER["CONTENT_TYPE"];
if (!isset($contentType))
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Your browser did not include Content-Type header"}, "id" : "id"}');
// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
if (strpos($contentType, "multipart") !== false) {
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
// Open temp file
$out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($_FILES['file']['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($in);
fclose($out);
@unlink($_FILES['file']['tmp_name']);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
} else {
if($_FILES['file']['error']==UPLOAD_ERR_INI_SIZE || $_FILES['file']['error']==UPLOAD_ERR_FORM_SIZE) {
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "File size exceeded."}, "id" : "id"}');
} else {
$file_err = isset($_FILES['file']['error']) ? ' (' . $_FILES['file']['error'] . ')' : '';
die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file' . $file_err . '."}, "id" : "id"}');
}
}
} else {
// Open temp file
$out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096))
fwrite($out, $buff);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
fclose($in);
fclose($out);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
}
// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
$_SESSION['client']['utils_attachment'][CID]['files'][] = array('path' => $filePath, 'name' => $orig_fileName);
session_commit();
}
// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');
?>

Loading…
Cancel
Save