[Openupload-svn-update] SF.net SVN: openupload:[372] trunk/plugins
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2010-03-18 18:25:23
|
Revision: 372
http://openupload.svn.sourceforge.net/openupload/?rev=372&view=rev
Author: tsdogs
Date: 2010-03-18 18:25:15 +0000 (Thu, 18 Mar 2010)
Log Message:
-----------
version 0.5 modifications
Modified Paths:
--------------
trunk/plugins/captcha.inc.php
trunk/plugins/compress.inc.php
trunk/plugins/email.inc.php
trunk/plugins/expire.inc.php
trunk/plugins/filesize.inc.php
trunk/plugins/mimetypes.inc.php
trunk/plugins/password.inc.php
Modified: trunk/plugins/captcha.inc.php
===================================================================
--- trunk/plugins/captcha.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/captcha.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -5,35 +5,36 @@
function CaptchaPlugin() {
$this->fields = array('captcha');
$this->description = tr('Add captcha protection to file download and user registration');
+ $this->category = 'protection';
}
- function uploadOptions(&$finfo,$acl) {
+ function uploadDisplayUploadOptions(&$upload,$acl) {
if ($acl!='enable') return true;
$this->display('uploadOptions');
return true;
}
- function uploadConfirm(&$finfo,$acl) {
+ function uploadValidateUploadOptions(&$upload,$acl) {
global $_POST;
if ($acl!='enable') return true;
- $finfo[0]['captcha'] = $_POST['captcha'];
+ $upload['captcha'] = $_POST['captcha'];
return true;
}
- function downloadRequest($finfo,$acl) {
- if ($finfo[0]['captcha']==1) {
+ function uploadDisplayDownloadOptions($upload,$acl) {
+ if ($upload['captcha']==1) {
$this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
- $this->display('downloadRequest');
+ $this->display('downloadOptions');
return false;
}
return true;
}
- function downloadConfirm($finfo,$acl) {
+ function uploadValidateDownloadOptions($upload,$acl) {
global $_POST;
- if ($finfo[0]['captcha']==1) {
+ if ($upload['captcha']==1) {
require_once(app()->config['INSTALL_ROOT'].'/plugins/securimage/securimage.php');
$securimage = new Securimage();
$result = $securimage->check($_POST['captcha_code']);
@@ -43,13 +44,13 @@
return true;
}
- function registerForm($uinfo,$acl) {
+ function registerForm($upload,$acl) {
$this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
$this->display('registerForm');
return true;
}
- function registerConfirm(&$uinfo,$acl) {
+ function registerConfirm(&$upload,$acl) {
global $_POST;
require_once(app()->config['INSTALL_ROOT'].'/plugins/securimage/securimage.php');
@@ -59,8 +60,8 @@
return $result;
}
- function removeRequest($finfo,$acl) {
- if ($finfo[0]['captcha']==1) {
+ function uploadDisplayRemoveForm(&$upload,$acl) {
+ if ($upload['captcha']==1) {
$this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
$this->display('removeRequest');
return false;
@@ -68,15 +69,71 @@
return true;
}
- function removeConfirm($finfo,$acl) {
- return $this->downloadConfirm($finfo,$acl);
+ function uploadValidateRemoveRequest(&$upload,$acl) {
+ return $this->uploadValidateDownloadOptions($upload,$acl);
}
- function fileDetail(&$finfo,$acl) {
- if ($finfo[0]['captcha']!='')
- $this->display('fileDetail');
+ function uploadDisplayElementDetail(&$upload,$acl) {
+ if ($upload['captcha']!='')
+ $this->display('uploadDetail');
return true;
}
+
+ function invitationDisplayCreateForm(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('invitationForm');
+ return true;
+ }
+
+ function invitationValidateCreateForm(&$invitation,$acl) {
+ global $_POST;
+
+ if ($acl!='enable') return true;
+ $invitation['captcha'] = $_POST['captcha'];
+ return true;
+ }
+
+ function invitationDisplayCreateOptions(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('invitationOptions');
+ return true;
+ }
+
+ function invitationValidateCreateOptions(&$invitation,$acl) {
+ global $_POST;
+
+ if ($acl!='enable') return true;
+ $invitation['u']['captcha'] = $_POST['captcha'];
+ return true;
+ }
+
+ function invitationDisplayUploadForm(&$invitation,$acl) {
+ if ($invitation['captcha']==1) {
+ $this->assign('captcha_img',app()->config['WWW_ROOT'].'/plugins/captcha.php');
+ $this->display('downloadOptions');
+ return false;
+ }
+ return true;
+ }
+
+ function invitationValidateUploadForm($invitation,$acl) {
+ global $_POST;
+
+ if ($invitation['captcha']==1) {
+ require_once(app()->config['INSTALL_ROOT'].'/plugins/securimage/securimage.php');
+ $securimage = new Securimage();
+ $result = $securimage->check($_POST['captcha_code']);
+ if (!$result) app()->error(tr('Wrong captcha code! please try again.'));
+ return $result;
+ } else
+ return true;
+ }
+
+ function invitationDisplayElementDetail(&$invitation,$acl) {
+ $this->display('invitationDetail');
+ return true;
+ }
+
}
?>
\ No newline at end of file
Modified: trunk/plugins/compress.inc.php
===================================================================
--- trunk/plugins/compress.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/compress.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -9,9 +9,10 @@
array('name' => 'extension', 'description' => tr('Extensions corresponding to commands.'), 'type' => 'list'),
array('name' => 'compression', 'description' => tr('Name of compression commands'), 'type' => 'list'),
);
+ $this->category = 'advanced';
}
- function uploadOptions(&$finfo, $acl) {
+ function uploadDisplayUploadOptions(&$upload, $acl) {
if ($acl != 'enable') return true;
$group = $this->getGroup('command');
if (count($this->config['command'][$group])==0 and count($this->config['command']['*'])>0) {
@@ -26,11 +27,11 @@
return true;
}
- function uploadConfirm(&$finfo, $acl) {
+ function uploadValidateUploadOptions(&$upload, $acl) {
global $_POST;
if ($acl != 'enable') return true;
if ($_POST['compress']!='') {
- if ($finfo[0]['compress']==1) return true; /* file already compressed */
+ if ($upload['compress']==1) return true; /* file already compressed */
$group = $this->getGroup('command');
if (count($this->config['command'][$group])==0 and count($this->config['command']['*'])>0) {
$this->config['command'][$group]=$this->config['command']['*'];
@@ -43,14 +44,14 @@
$tmpdir = randomName(20,20);
$res = mkdir(app()->config['DATA_PATH'].'/tmp/'.$tmpdir);
/* move the uploaded files to that folder with the original name */
- foreach ($finfo as $f) {
+ foreach ($upload['files'] as $f) {
rename($f['tmp'],app()->config['DATA_PATH'].'/tmp/'.$tmpdir.'/'.$f['name']);
$files .= ' "'.chop($f['name']).'"';
$lfiles .= ' "'.app()->config['DATA_PATH'].'/tmp/'.$tmpdir.'/'.chop($f['name']).'"';
}
/* execute the compress command */
$cmd=$this->config['command'][$group][$_POST['compress']];
- $params['%1']=$finfo[0]['tmp'];
+ $params['%1']=$upload['files'][0]['tmp'];
$params['%2']=$files;
$params['%3']=$lfiles;
$params['%4']=app()->config['DATA_PATH'].'/tmp/'.$tmpdir;
@@ -60,19 +61,20 @@
exec($cmd,$output);
chdir($pwd);
/* remove the files */
- foreach ($finfo as $f) {
+ foreach ($upload['files'] as $f) {
unlink(app()->config['DATA_PATH'].'/tmp/'.$tmpdir.'/'.$f['name']);
}
rmdir(app()->config['DATA_PATH'].'/tmp/'.$tmpdir);
/* update the file information with the compressed one */
- $finfo[0]['mime']='binary/octet-stream';
- $finfo[0]['name']=$tmpdir.'.'.$this->config['extension'][$group][$_POST['compress']];
- $finfo[0]['size']=filesize($finfo[0]['tmp'].'.'.$this->config['extension'][$group][$_POST['compress']]);
- $finfo[0]['tmp']=$finfo[0]['tmp'].'.'.$this->config['extension'][$group][$_POST['compress']];
- for ($i=1; $i<count($finfo); $i++)
- unset($finfo[$i]);
+ $upload['files'][0]['mime']='binary/octet-stream';
+ $upload['files'][0]['name']=$tmpdir.'.'.$this->config['extension'][$group][$_POST['compress']];
+ $upload['files'][0]['size']=filesize($upload['files'][0]['tmp'].'.'.$this->config['extension'][$group][$_POST['compress']]);
+ $upload['files'][0]['tmp']=$upload['files'][0]['tmp'].'.'.$this->config['extension'][$group][$_POST['compress']];
+ $upload['size']=$upload['files'][0]['size'];
+ for ($i=1; $i<count($upload['files']); $i++)
+ unset($upload['files'][$i]);
/* tell the program that the file is already compressed, so not to run it again */
- $finfo[0]['compress']=1;
+ $upload['compress']=1;
}
}
return true;
Modified: trunk/plugins/email.inc.php
===================================================================
--- trunk/plugins/email.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/email.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -7,43 +7,42 @@
$this->options = array(
array('name' => 'multirecipients', 'description' => tr('allow multiple recipients (1 = enable)'), 'type' => 'text'),
);
-
}
- function uploadOptions(&$finfo,$acl) {
+ function uploadDisplayUploadOptions(&$upload,$acl) {
if ($acl!='enable') return true;
$this->display('uploadOptions');
return true;
}
- function uploadConfirm(&$finfo,$acl) {
+ function uploadValidateUploadOptions(&$upload,$acl) {
global $_POST;
if ($acl!='enable') return true;
+
/* do e-mail checking and so */
-/* $this->display('upload'); */
$group = $this->getGroup('maxrecipients');
- $finfo[0]['emailme']=$_POST['emailme'];
- $finfo[0]['emailfrom']=app()->config['site']['email'];
- $finfo[0]['emailto']=$_POST['emailto'];
- $finfo[0]['email_removelink']=$_POST['removelink'];
- $finfo[0]['subject']=$_POST['subject'];
- $finfo[0]['message']=$_POST['message'];
- if ($finfo[0]['emailme']=="yes") {
+ $upload['emailme']=$_POST['emailme'];
+ $upload['emailfrom']=app()->config['site']['email'];
+ $upload['emailto']=$_POST['emailto'];
+ $upload['email_removelink']=$_POST['removelink'];
+ $upload['subject']=$_POST['subject'];
+ $upload['message']=$_POST['message'];
+ if ($upload['emailme']=="yes") {
if ($_SESSION['user']['email']=='') {
/* check valid e-mail */
if (!validEmail($_POST['email'])) {
app()->error(tr('Your e-mail address isn\'t valid!'));
return false;
}
- $finfo[0]['emailfrom']=$_POST['email'];
+ $upload['emailfrom']=$_POST['email'];
} else {
- $finfo[0]['emailfrom']=$_SESSION['user']['email'];
+ $upload['emailfrom']=$_SESSION['user']['email'];
}
}
if (!isset($this->config['multirecipients'][$group]) and isset($this->config['multirecipients']['*'])) {
$this->config['multirecipients'][$group]=$this->config['multirecipients']['*'];
}
- if ($finfo[0]['emailto']!='') {
+ if ($upload['emailto']!='') {
if ($this->config['multirecipients'][$group]=='1') {
$emailto = split(';',$_POST['emailto']);
} else {
@@ -52,64 +51,132 @@
foreach ($emailto as $destination) {
if (!validEmail($destination)) {
app()->error(tr('Destination e-mail address "%1" isn\'t valid!',$destination));
+ /* maybe I should not fail here, just report the error. */
return false;
}
}
}
-
return true;
}
- function uploadFileInfo(&$finfo,$acl) {
+ function uploadExecuteUploadActions(&$upload,$acl,$template = 'uploadNotify', $notify = true) {
global $_SESSION;
if ($acl!='enable') return true;
/* send the e-mails */
- app()->tpl->assign('finfo',$finfo);
- if ($finfo[0]['emailme']=="yes") {
+ app()->tpl->assign('upload',$upload);
+ if ($upload['emailme']=="yes") {
app()->tpl->assign('remove','yes');
- $subject = app()->config['site']['title'].': '.tr("Information about your uploaded file: %1",$finfo[0]['description']);
- sendMail(app()->config['site']['email'],'noreply',$finfo[0]['emailfrom'],$subject,'plugins/email/notify');
+ $subject = app()->config['site']['title'].': '.tr("Information about your uploaded file: %1",$upload['description']);
+ $r = sendMail(app()->config['site']['email'],$upload['emailfrom'],$subject,'plugins/email/'.$template);
+ if ($notify)
+ if ($r)
+ app()->message(tr('E-mail was sent to: %1!',$upload['emailfrom']));
+ else
+ app()->error(tr('E-mail was NOT sent to: %1!',$upload['emailfrom']));
}
- if ($finfo[0]['emailto']!='') {
- $subject = $finfo[0]['subject']!=''?$finfo[0]['subject']:tr("An upload was delivered to you");
+ if ($upload['emailto']!='') {
+ $subject = $upload['subject']!=''?$upload['subject']:tr("An upload was delivered to you");
$subject = app()->config['site']['title'].': '.$subject;
- app()->tpl->assign('remove',$finfo[0]['email_removelink']);
- sendMail($finfo[0]['emailfrom'],$finfo[0]['emailfrom'],$finfo[0]['emailto'],$subject,'plugins/email/notify');
+ app()->tpl->assign('remove',$upload['email_removelink']);
+ $r = sendMail($upload['emailfrom'],$upload['emailto'],$subject,'plugins/email/'.$template);
+ if ($notify)
+ if ($r)
+ app()->message(tr('E-mail was sent to: %1!',$upload['emailto']));
+ else
+ app()->error(tr('E-mail was NOT sent to: %1!',$upload['emailto']));
}
/* don't send it twice */
- $finfo[0]['emailme']=='';
- $finfo[0]['emailto']=='';
+ $upload['emailme']=='';
+ $upload['emailto']=='';
return true;
}
- function fileDetail(&$finfo,$acl) {
+ function uploadDisplayElementDetail(&$upload,$acl) {
global $_GET;
if ($acl!='enable') return true;
if (isset($_GET['emailme'])) {
app()->tpl->assign('remove','yes');
- $subject = app()->config['site']['title'].': '.tr("Information about your uploaded file: %1",$finfo[0]['description']);
- app()->tpl->assign('finfo',$finfo);
- sendMail(app()->config['site']['email'],'noreply',$_SESSION['user']['email'],$subject,'plugins/email/notify');
- app()->message(tr('E-mail was sent!'));
+ $subject = app()->config['site']['title'].': '.tr("Information about your uploaded file: %1",$upload['description']);
+ app()->tpl->assign('upload',$upload);
+ $r = sendMail(app()->config['site']['email'],$_SESSION['user']['email'],$subject,'plugins/email/uploadNotify');
+ if ($r)
+ app()->message(tr('E-mail was sent to: %1!',$_SESSION['user']['email']));
+ else
+ app()->error(tr('E-mail was NOT sent to: %1!',$_SESSION['user']['email']));
redirect('?action=l&step=2&id='.$_GET['id']);
- return false;
+ return false; /* force redirect */
} else if (isset($_GET['sendemail']) and isset($_GET['emailto']) and ($_GET['emailto']!='')) {
$subject = $_GET['subject']!=''?$_GET['subject']:tr("An upload was delivered to you");
$subject = app()->config['site']['title'].': '.$subject;
- $finfo[0]['subject']=$_GET['subject'];
- $finfo[0]['message']=$_GET['message'];
- app()->tpl->assign('finfo',$finfo);
+ $emailto = split(';',$_GET['emailto']);
+
+ app()->tpl->assign('upload',$upload);
app()->tpl->assign('remove',$_GET['removelink']);
- sendMail($_SESSION['user']['email'],$_SESSION['user']['email'],$_GET['emailto'],$subject,'plugins/email/notify');
- app()->message(tr('E-mail was sent to: %1!',$_GET['emailto']));
+ foreach ($emailto as $to) {
+ $to = trim($to);
+ if (!validEmail($to)) {
+ app()->error(tr('Invalid e-mail address: %1!',$to));
+ } else {
+ $r = sendMail($_SESSION['user']['email'],$to,$subject,'plugins/email/uploadNotify');
+ if ($r)
+ app()->message(tr('E-mail was sent to: %1!',$to));
+ else
+ app()->error(tr('E-mail was NOT sent to: %1!',$to));
+ }
+ }
redirect('?action=l&step=2&id='.$_GET['id']);
- return false;
+ return false; /* force redirect */
} else {
- app()->tpl->assign('finfo',$finfo);
- $this->display('fileDetail');
+ app()->tpl->assign('upload',$upload);
+ $this->display('uploadDetail');
return true;
}
}
+
+
+ function invitationDisplayCreateForm(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('uploadOptions');
+ return true;
+ }
+
+ function invitationValidateCreateForm(&$invitation,$acl) {
+ if ($acl != 'enable') return true;
+
+ return $this->uploadValidateUploadOptions($invitation,$acl);
+ }
+
+ function invitationDisplayCreateOptions(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('uploadOptions');
+ return true;
+ }
+
+ function invitationValidateCreateOptions(&$invitation,$acl) {
+ if ($acl != 'enable') return true;
+
+ /* let the invitation save info about the upload */
+ $this->fields = array ( 'emailme','emailfrom','emailto','email_removelink','subject','message' );
+ return $this->uploadValidateUploadOptions($invitation['u'],$acl);
+ }
+
+ function invitationDisplayElementDetail(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ if ($acl != 'enable') return true;
+
+ return $this->uploadDisplayElementDetail($invitation,$acl);
+ }
+
+
+ function invitationExecuteCreateActions(&$invitation,$acl) {
+ if ($acl != 'enable') return true;
+ return $this->uploadExecuteUploadActions($invitation,$acl,'invitationNotify',true);
+ }
+
+ function invitationExecuteUploadActions($invitation,$acl) {
+ if ($acl != 'enable') return true;
+ return $this->uploadExecuteUploadActions($invitation['u'],$acl,'uploadNotify',false);
+ }
}
Modified: trunk/plugins/expire.inc.php
===================================================================
--- trunk/plugins/expire.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/expire.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -7,10 +7,11 @@
$this->options = array(
array('name' => 'days', 'description' => tr('N. Of Days'), 'type' => 'text'),
);
- $this->fields = array('expire');
+ //$this->fields = array('expire');
+ $this->category = 'advanced';
}
- function uploadForm(&$finfo,$acl) {
+ function uploadDisplayUploadForm(&$upload,$acl) {
if ($acl!='enable') return true;
$group = $this->getGroup('days');
/* now set */
@@ -18,13 +19,13 @@
$this->config['days'][$group]=$this->config['days']['*'];
}
if ($this->config['days'][$group]>0) {
- $this->assign('msg',tr('Files will be kept on our server for %1 days',$this->config['days'][$group]));
+ app()->tpl->assign('days',$this->config['days'][$group]);
$this->display('uploadForm');
}
return true;
}
- function calculateExpireDate() {
+ function _calculateExpireDate() {
$group = $this->getGroup('days');
/* now set */
@@ -32,43 +33,44 @@
$this->config['days'][$group]=$this->config['days']['*'];
}
if ($this->config['days'][$group]>0) {
- $expire=date('Y-m-d',time()+($this->config['days'][$group]*24*60*60));
+ $expire=date('Y-m-d H:i:s',time()+($this->config['days'][$group]*24*60*60));
} else {
$expire='9999-12-31';
}
return $expire;
}
- function uploadOptions(&$finfo,$acl) {
+ function uploadValidateUploadOptions(&$upload,$acl) {
if ($acl!='enable') return true;
- $expire = $this->calculateExpireDate();
+ $expire = $this->_calculateExpireDate();
if ($expire!='') {
if ($expire == '9999-12-31')
- app()->tpl->assign('expire',tr('Never'));
+ app()->tpl->assign('expire_date',tr('Never'));
else
- app()->tpl->assign('expire',$expire);
- $this->display('uploadOptions');
+ app()->tpl->assign('expire_date',$expire);
+ //$this->display('uploadOptions');
}
+ $upload['expire_date']=$expire;
return true;
}
- function uploadConfirm(&$finfo,$acl) {
+ function uploadDisplayUploadResult(&$upload,$acl) {
if ($acl!='enable') return true;
- $finfo[0]['expire']=$this->calculateExpireDate();
return true;
}
- function fileDetail(&$finfo, $acl) {
+ function uploadDisplayElementDetail(&$upload, $acl) {
if ($acl != 'enable') return true;
- if ($finfo[0]['expire']!='') {
- app()->tpl->assign('expire',$finfo[0]['expire']);
- $this->display('fileDetail');
+ if ($upload['expire_date']!='') {
+ app()->tpl->assign('expire_date',$upload['expire']);
+ $this->display('uploadDetail');
}
return true;
}
+
}
?>
\ No newline at end of file
Modified: trunk/plugins/filesize.inc.php
===================================================================
--- trunk/plugins/filesize.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/filesize.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -9,30 +9,29 @@
$this->options = array(
array('name' => 'maxsize', 'description' => tr('Maximum File Size'), 'type' => 'text'),
);
+ $this->category = 'protection';
}
- function init() {
+ function setupUpload(&$upload,$acl) {
+
/* check if it's enabled */
$group = $this->getGroup('maxsize');
- $acl = 'disable'; /* disabled by default */
+ /*$acl = 'disable';
if (isset(app()->pluginAcl[$this->name])) {
$acl = app()->pluginAcl[$this->name]['access'];
- }
- if ($acl!='enable') {
- /* reset to default */
- app()->user->setInfo('max_upload_size',app()->config['max_upload_size']*1024*1024);
- } else {
+ }*/
+ if ($acl=='enable') {
$this->loadConfig();
if (!isset($this->config['maxsize'][$group]) and isset($this->config['maxsize']['*'])>0) {
$this->config['maxsize'][$group]=$this->config['maxsize']['*'];
}
if ($this->config['maxsize'][$group]>0) {
- app()->user->setInfo('max_upload_size',$this->config['maxsize'][$group]*1024*1024);
+ $upload['max_upload_size']=$this->config['maxsize'][$group]*1024*1024;
}
}
- ini_set('max_upload_size',app()->user->info('max_upload_size'));
- ini_set('post_max_size',app()->user->info('max_upload_size'));
+ return true;
}
+
}
?>
\ No newline at end of file
Modified: trunk/plugins/mimetypes.inc.php
===================================================================
--- trunk/plugins/mimetypes.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/mimetypes.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -8,10 +8,11 @@
array('name' => 'allowed', 'description' => tr('Allowed mime types'), 'type' => 'list'),
array('name' => 'message', 'description' => tr('Types in message'), 'type' => 'text'),
);
- /* load the plugin configuration */
+ $this->category = 'protection';
+ /* load the plugin configuration */
}
- function uploadForm(&$finfo,$acl) {
+ function uploadDisplayUploadForm(&$upload,$acl) {
if ($acl!='enable') return true;
$group = $this->getGroup('allowed');
if (count($this->config['allowed'][$group])==0 and count($this->config['allowed']['*'])>0) {
@@ -28,7 +29,7 @@
return true;
}
- function uploadComplete(&$finfo,$acl) {
+ function uploadValidateUploadForm(&$upload,$acl) {
if ($acl!='enable') return true;
$group = $this->getGroup('allowed');
if (count($this->config['allowed'][$group])==0 and count($this->config['allowed']['*'])>0) {
@@ -39,9 +40,9 @@
app()->error(tr('WARNING: no mime types defined. Plugin has been disabled!'));
} else {
$result = true;
- foreach ($finfo as $f) {
+ foreach ($upload['files'] as $f) {
if (array_search($f['mime'],$this->config['allowed'][$group])===FALSE) {
- app()->error(tr('This file type (%1) is not allowed on this site!',$f['mime']));
+ app()->error(tr('This file type (%1) is not allowed on this site! [ %2 ]',$f['mime'],$f['name']));
$result = false;
}
}
@@ -49,5 +50,14 @@
}
return true;
}
+
+ function invitationDisplayUploadFiles(&$upload,$acl) {
+ return $this->uploadDisplayUploadForm($upload['u'],$acl);
+ }
+
+ function invitationValidateUploadFiles(&$upload,$acl) {
+ return $this->uploadValidateUploadForm($upload['u'],$acl);
+ }
+
}
?>
\ No newline at end of file
Modified: trunk/plugins/password.inc.php
===================================================================
--- trunk/plugins/password.inc.php 2010-03-18 18:24:44 UTC (rev 371)
+++ trunk/plugins/password.inc.php 2010-03-18 18:25:15 UTC (rev 372)
@@ -5,9 +5,10 @@
function PasswordPlugin() {
$this->fields = array('password');
$this->description = tr('Option to add password protection for file download');
+ $this->category = 'protection';
}
- function uploadOptions(&$finfo,$acl) {
+ function uploadDisplayUploadOptions(&$upload,$acl) {
if ($acl!='enable') return true;
if (isset(app()->plugins['email']) and
isset(app()->pluginAcl['email']) and
@@ -20,36 +21,36 @@
return true;
}
- function uploadConfirm(&$finfo,$acl) {
+ function uploadValidateUploadOptions(&$upload,$acl) {
global $_POST;
if (isset($_POST['protect']) and $acl=='enable') {
- $finfo[0]['password'] = crypt($_POST['protect']);
+ $upload['password'] = crypt($_POST['protect']);
if (isset($_POST['protect_notify'])) { /* want the e-mail to include the password? */
- $finfo[0]['plainpassword'] = $_POST['protect'];
+ $upload['plainpassword'] = $_POST['protect'];
} else {
- $finfo[0]['plainpassword']='';
+ $upload['plainpassword']='';
}
} else {
- $finfo[0]['password'] = crypt("");
- $finfo[0]['plainpassword'] = "";
+ $upload['password'] = crypt("");
+ $upload['plainpassword'] = "";
}
return true;
}
- function downloadRequest($finfo,$acl) {
- if (($finfo[0]['password']!='') and ($finfo[0]['password']!=crypt("",$finfo[0]['password'])) ) {
- $this->display('downloadRequest');
+ function uploadDisplayDownloadOptions($upload,$acl) {
+ if (($upload['password']!='') and ($upload['password']!=crypt("",$upload['password'])) ) {
+ $this->display('downloadOptions');
return false;
}
return true;
}
- function downloadConfirm($finfo,$acl) {
+ function uploadValidateDownloadOptions($upload,$acl) {
global $_POST;
- if (($finfo[0]['password']!='') and ($finfo[0]['password']!=crypt("",$finfo[0]['password'])) ) {
- $result = $finfo[0]['password']==crypt($_POST['protect'],$finfo[0]['password']);
+ if (($upload['password']!='') and ($upload['password']!=crypt("",$upload['password'])) ) {
+ $result = $upload['password']==crypt($_POST['protect'],$upload['password']);
if (!$result) app()->error(tr('Wrong password!'));
return $result;
} else {
@@ -57,19 +58,91 @@
}
}
- function removeRequest($finfo,$acl) {
- return $this->downloadRequest($finfo,$acl);
+ function uploadDisplayRemoveForm($upload,$acl) {
+ return $this->uploadDisplayDownloadOptions($upload,$acl);
}
- function removeConfirm($finfo,$acl) {
- return $this->downloadConfirm($finfo,$acl);
+ function uploadValidateRemoveForm($upload,$acl) {
+ return $this->uploadValidateDownloadOptions($upload,$acl);
}
- function fileDetail(&$finfo,$acl) {
- if (($finfo[0]['password']!='') and ($finfo[0]['password']!=crypt("",$finfo[0]['password'])) )
- $this->display('fileDetail');
+ function uploadDisplayElementDetail(&$upload,$acl) {
+ if (($upload['password']!='') and ($upload['password']!=crypt("",$upload['password'])) )
+ app()->tpl->assign('password','yes');
+
+ $this->display('uploadDetail');
return true;
}
+
+
+ function invitationDisplayElementDetail(&$invitation,$acl) {
+ if (($invitation['password']!='') and ($invitation['password']!=crypt("",$invitation['password'])) )
+ app()->tpl->assign('invitation_password','yes');
+ if (($invitation['u']['password']!='') and ($invitation['u']['password']!=crypt("",$invitation['u']['password'])) )
+ app()->tpl->assign('upload_password','yes');
+
+ $this->display('invitationDetail');
+ return true;
+ }
+
+
+ function invitationDisplayCreateForm(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ if (isset(app()->plugins['email']) and
+ isset(app()->pluginAcl['email']) and
+ app()->pluginAcl['email']['access']=='enable') {
+ app()->tpl->assign('emailplugin',true);
+ } else {
+ app()->tpl->assign('emailplugin',false);
+ }
+ $this->display('invitationForm');
+ return true;
+ }
+
+ function invitationValidateCreateForm(&$invitation,$acl) {
+ global $_POST;
+
+ if (isset($_POST['protect']) and $acl=='enable') {
+ $invitation['password'] = crypt($_POST['protect']);
+ if (isset($_POST['protect_notify'])) { /* want the e-mail to include the password? */
+ $invitation['plainpassword'] = $_POST['protect'];
+ } else {
+ $invitation['plainpassword']='';
+ }
+ } else {
+ $invitation['password'] = crypt("");
+ $invitation['plainpassword'] = "";
+ }
+ return true;
+ }
+
+ function invitationDisplayCreateOptions(&$invitation,$acl) {
+ if ($acl!='enable') return true;
+ $this->display('invitationOptions');
+ return true;
+ }
+
+ function invitationValidateCreateOptions(&$invitation,$acl) {
+ global $_POST;
+
+ if (isset($_POST['protect']) and $acl=='enable') {
+ $invitation['u']['password'] = crypt($_POST['protect']);
+ $invitation['u']['plainpassword']='';
+ } else {
+ $invitation['u']['password'] = crypt("");
+ $invitation['u']['plainpassword'] = "";
+ }
+ return true;
+ }
+
+ function invitationDisplayUploadForm(&$invitation,$acl) {
+ return $this->uploadDisplayDownloadOptions($invitation,$acl);
+ }
+
+ function invitationValidateUploadForm($invitation,$acl) {
+ return $this->uploadValidateDownloadOptions($invitation,$acl);
+ }
+
}
?>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|