Thread: [Openupload-svn-update] SF.net SVN: openupload:[74] trunk/lib/modules/default
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-24 10:58:37
|
Revision: 74
http://openupload.svn.sourceforge.net/openupload/?rev=74&view=rev
Author: tsdogs
Date: 2008-10-24 09:13:19 +0000 (Fri, 24 Oct 2008)
Log Message:
-----------
fix user administration
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/auth.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-24 08:57:58 UTC (rev 73)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-24 09:13:19 UTC (rev 74)
@@ -185,8 +185,7 @@
$this->nextStep(1);
}
} else {
- $user = app()->auth->info($_GET['id']);
- $user = $user[0];
+ $user = app()->auth->userinfo($_GET['id']);
}
$this->tpl->assign('edituser',$user);
}
Modified: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php 2008-10-24 08:57:58 UTC (rev 73)
+++ trunk/lib/modules/default/auth.inc.php 2008-10-24 09:13:19 UTC (rev 74)
@@ -39,7 +39,7 @@
if (!app()->user->loggedin()) {
$this->menu['login']=tr('Login');
} else {
- if (app()->auth->features['adminusers']=='yes')
+ if (app()->auth->features['useradmin']=='yes')
$this->menu['profile']=tr('Preferences');
$this->menu['logout']=tr('Logout');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-10-24 11:15:46
|
Revision: 75
http://openupload.svn.sourceforge.net/openupload/?rev=75&view=rev
Author: tsdogs
Date: 2008-10-24 09:19:12 +0000 (Fri, 24 Oct 2008)
Log Message:
-----------
if auth does not support user admin, disable registration / profile change
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/auth.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-24 09:13:19 UTC (rev 74)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-24 09:19:12 UTC (rev 75)
@@ -140,7 +140,6 @@
if (isset($_GET['id'])) {
$active=$_GET['active']==1?0:1;
$user = app()->auth->userinfo($_GET['id']);
- $user = $user[0];
if ($user['login']==$_GET['id']) {
$user['active']=$active;
app()->auth->useredit($user,false);
Modified: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php 2008-10-24 09:13:19 UTC (rev 74)
+++ trunk/lib/modules/default/auth.inc.php 2008-10-24 09:19:12 UTC (rev 75)
@@ -43,7 +43,8 @@
$this->menu['profile']=tr('Preferences');
$this->menu['logout']=tr('Logout');
}
- $this->tpl->assign('register',app()->checkACL(app()->user->group(),'auth','register')=='allow');
+ if (app()->auth->features['useradmin']=='yes')
+ $this->tpl->assign('register',app()->checkACL(app()->user->group(),'auth','register')=='allow');
}
@@ -87,6 +88,11 @@
global $_GET;
global $_POST;
+ if (app()->auth->features['useradmin']!='yes') {
+ app()->error(tr('Registration is not supported by Auth Module'));
+ redirect();
+ }
+
if (isset($_GET['regid'])) {
/* confirm registration */
$_SESSION['user']['regidconfirm']=$_GET['regid'];
@@ -104,6 +110,11 @@
function registerConfirm() {
global $_SESSION;
global $_POST;
+
+ if (app()->auth->features['useradmin']!='yes') {
+ app()->error(tr('Registration is not supported by Auth Module'));
+ redirect();
+ }
if (isset($_POST['registerlogin'])) {
/* check for the unique login */
@@ -184,6 +195,12 @@
function registerEnable() {
global $_SESSION;
+
+ if (app()->auth->features['useradmin']!='yes') {
+ app()->error(tr('Registration is not supported by Auth Module'));
+ redirect();
+ }
+
/* if everything is ok register the user */
if (isset($_SESSION['user']['regidconfirm'])) {
$user = app()->db->read('users',array('regid' => $_SESSION['user']['regidconfirm']));
@@ -197,12 +214,23 @@
}
function profile() {
+
+ if (app()->auth->features['useradmin']!='yes') {
+ app()->error(tr('User profile change not supported by Auth Module'));
+ redirect();
+ }
+
$user = app()->user->info();
$this->tpl->assign('puser',$user);
}
function profileedit() {
global $_POST;
+
+ if (app()->auth->features['useradmin']!='yes') {
+ app()->error(tr('User profile change not supported by Auth Module'));
+ redirect();
+ }
$user = app()->user->info();
if (isset($_POST['username'])) {
/* check for valid values*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2010-03-18 18:24:21
|
Revision: 370
http://openupload.svn.sourceforge.net/openupload/?rev=370&view=rev
Author: tsdogs
Date: 2010-03-18 18:24:11 +0000 (Thu, 18 Mar 2010)
Log Message:
-----------
version 0.5 modifications
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/auth.inc.php
Added Paths:
-----------
trunk/lib/modules/default/invitation.inc.php
trunk/lib/modules/default/upload.inc.php
Removed Paths:
-------------
trunk/lib/modules/default/files.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2010-03-18 18:22:36 UTC (rev 369)
+++ trunk/lib/modules/default/admin.inc.php 2010-03-18 18:24:11 UTC (rev 370)
@@ -26,11 +26,11 @@
4 => "pluginoptionedit",
5 => "pluginoptiondelete",
),
- "adminfiles" => array (
- 1 => "files",
- 2 => "filedel",
- 3 => "filesplugin",
- 4 => "filemultidel",
+ "adminuploads" => array (
+ 1 => "uploads",
+ 2 => "uploaddel",
+ 3 => "uploadplugin",
+ 4 => "uploadmultidel",
),
"adminmaintenance" => array (
1 => "maintenance",
@@ -410,57 +410,61 @@
$this->tpl->assign('defaultgroup',app()->config['nologingroup']);
}
- function files() {
- $NUM = 50;
+ function uploads() {
+ global $_GET;
- $page = 1;
- if (isset($_GET['page'])) {
- $page=$_GET['page'];
- }
- $limit = ($NUM*($page-1)).','.$NUM;
- $count = app()->db->count('files');
- $this->tpl->assign('pages',ceil($count / $NUM)+1);
+ $rows = isset($_GET['limit'])?$_GET['limit']:20;
+ $page = isset($_GET['page'])?$_GET['page']:1;
+ $count = app()->db->count('uploads');
+ $pages = ceil($count / $rows)+1;
+ if ($page>$pages-1) { $page = $pages-1; }
+ if ($page<1) { $page = 1; }
+ $offset = ($page -1)*$rows;
$this->tpl->assign('pagen',$page);
- $files = app()->db->read('files',array(),array('upload_date desc'),$limit);
+ $this->tpl->assign('pages',$pages);
+ $this->tpl->assign('limit',$rows);
+ $this->tpl->assign('uploads',$uploads);
+ $files = app()->db->read('uploads',array(),array('upload_date desc'),$offset.','.$rows);
$this->tpl->assign('files',$files);
}
- function filedelete($id) {
- app()->db->delete('files',array('id' => $id));
- app()->db->delete('file_options',array('file_id' => $id));
- unlink(app()->config['DATA_PATH'].'/'.$id);
+ function uploaddelete($id) {
+
+ app()->db->delete('uploads',array('id' => $id));
+ /* delete the files from filesystem */
+ $files = app()->db->read('upload_files',array('upload_id' => $id));
+ foreach ($files as $k => $f) {
+ $file = app()->config['DATA_PATH'].'/files/'.$id.'_'.$k;
+ @unlink($file);
+ }
+ app()->db->delete('upload_files',array('upload_id' => $id));
+ app()->db->delete('upload_options',array('upload_id' => $id));
}
- function filedel() {
- global $_GET;
-
+ function uploaddel() {
if ($_GET['id']!='') {
- $f = app()->db->read('files',array('id'=>$_GET['id']));
+ $f = app()->db->read('uploads',array('id'=>$_GET['id']));
if ($f[0]['id']==$_GET['id']) {
- $this->filedelete($_GET['id']);
+ $this->uploaddelete($_GET['id']);
}
}
$this->nextStep(1);
}
- function filemultidel() {
+
+ function uploadmultidel() {
global $_POST;
foreach ($_POST as $k => $v) {
if (($v == 1) and (strpos($k,'file_'))!==FALSE) {
$fid = substr($k,5,strlen($k)-5);
- $f = app()->db->read('files',array('id'=>$fid));
- if ($f[0]['id']==$fid) {
- app()->db->delete('files',array('id' => $fid));
- app()->db->delete('file_options',array('file_id' => $fid));
- unlink(app()->config['DATA_PATH'].'/'.$fid);
- }
+ $this->uploaddelete($fid);
}
}
$this->nextStep(1);
}
- function filesplugin() {
+ function uploadplugin() {
global $_GET;
if (isset($_GET['plugin'])) {
if (isset(app()->plugins[$_GET['plugin']])) {
@@ -887,8 +891,8 @@
$ban['access']='deny';
app()->db->insert('banned',$ban);
app()->message(tr('IP %1 has been banned!',$ip));
- if (isset($_GET['nextaction']))
- $this->nextStep(1,$_GET['nextaction']);
+ if (isset($_GET['newaction']))
+ $this->nextStep(1,$_GET['newaction']);
} else {
app()->error(tr('IP %1 was already in state: %2!',$ip,$ban['access']));
if (isset($_GET['newaction']))
@@ -1070,24 +1074,25 @@
function logs() {
global $_GET;
- $NUM = 50;
- $page = 1;
- if (isset($_GET['page'])) {
- $page=$_GET['page'];
- }
$filter = array();
if (isset($_GET['level'])) {
if ($_GET['level']!='') {
$filter = array('level' => $_GET['level']);
}
}
- $limit = ($NUM*($page-1)).','.$NUM;
+ $rows = isset($_GET['limit'])?$_GET['limit']:20;
+ $page = isset($_GET['page'])?$_GET['page']:1;
$count = app()->db->count('activitylog',$filter);
- $this->tpl->assign('pages',ceil($count / $NUM)+1);
+ $pages = ceil($count / $rows)+1;
+ if ($page>$pages-1) { $page = $pages-1; }
+ if ($page<1) { $page = 1; }
+ $offset = ($page -1)*$rows;
$this->tpl->assign('pagen',$page);
+ $this->tpl->assign('pages',$pages);
+ $this->tpl->assign('limit',$rows);
$this->tpl->assign('level',$_GET['level']);
- $logs = app()->db->read('activitylog',$filter,array('log_time desc'),$limit);
+ $logs = app()->db->read('activitylog',$filter,array('log_time desc'),$offset.','.$rows);
$this->tpl->assign('logs',$logs);
}
Modified: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php 2010-03-18 18:22:36 UTC (rev 369)
+++ trunk/lib/modules/default/auth.inc.php 2010-03-18 18:24:11 UTC (rev 370)
@@ -39,8 +39,8 @@
if (!app()->user->loggedin()) {
$this->menu['login']=tr('Login');
} else {
- if (app()->auth->features['useradmin']=='yes')
- $this->menu['profile']=tr('Preferences');
+ /*if (app()->auth->features['useradmin']=='yes')
+ $this->mainmenu['profile']=tr('Preferences');*/
$this->menu['logout']=tr('Logout');
}
if (app()->auth->features['useradmin']=='yes')
@@ -89,7 +89,7 @@
global $_POST;
if (app()->auth->features['useradmin']!='yes') {
- app()->log('error','registerForm','','ERROR','Registration not supporte by Auth Module');
+ app()->log('error','registerForm','','ERROR','Registration not supported by Auth Module');
app()->error(tr('Registration is not supported by Auth Module'));
redirect();
}
@@ -170,7 +170,7 @@
$subject = tr('[%1] User registration confirmation e-mail',app()->config['site']['title']);
$this->tpl->assign('reguser',$user);
$this->tpl->assign('reglink',app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?action=register®id='.$user['regid']);
- sendMail(app()->config['site']['email'],'noreply',$user['email'],$subject,'modules/auth/emailconfirm');
+ sendMail(app()->config['site']['email'],$user['email'],$subject,'modules/auth/emailconfirm');
} else {
$user['active'] = 1;
}
Deleted: trunk/lib/modules/default/files.inc.php
===================================================================
--- trunk/lib/modules/default/files.inc.php 2010-03-18 18:22:36 UTC (rev 369)
+++ trunk/lib/modules/default/files.inc.php 2010-03-18 18:24:11 UTC (rev 370)
@@ -1,608 +0,0 @@
-<?php
-
-
-function cgiupload_get_info($fid) {
- return array();
-}
-
-class FilesModule extends OpenUploadModule {
-var $actions = array (
- "u" => array (
- 1 => "uploadForm",
- 2 => "uploadOptions",
- 3 => "uploadConfirm",
- 4 => "uploadFileInfo",
- 99 => "uploadProgress",
- ),
- "d" => array (
- 1 => "downloadForm",
- 2 => "downloadRequest",
- 3 => "downloadConfirm",
- ),
- "g" => array (
- 1 => "serveFile",
- ),
- "r" => array (
- 1 => "removeRequest",
- 2 => "removeConfirm",
- 3 => "removeResult",
- ),
- "l" => array (
- 1 => "fileList",
- 2 => "fileDetail",
- ),
- );
-var $page;
-var $menu;
-
- function FilesModule() {
- if (app()->user->info('login')!='')
- $files = tr("My Files");
- else
- $files = tr("Public Files");
- $this->page = array (
- "u" => array (
- "title" => tr("File upload"),
- ),
- "d" => array (
- "title" => tr("File download"),
- ),
- "r" => array (
- "title" => tr("File Removal"),
- ),
- "l" => array (
- "title" => $files,
- ),
- );
- $this->menu = array (
- "u" => tr("File Upload"),
- "l" => $files,
- //"d" => tr("File Download"),
- //"r" => tr("File Removal"),
- );
- }
-
- function init() {
- /* initialize */
- }
-
- /* real implementation */
-
- function uploadForm() {
- global $_SESSION;
-
- unset($_SESSION['user']['u']);
- $_SESSION['user']['identifier']=randomName(40,40);
- $this->tpl->assign('uploadscript',$_SERVER['PHP_SELF']);
- switch (app()->config['progress']) {
- case 'uploadprogress':
- $this->tpl->assign('identifiername','UPLOAD_IDENTIFIER');
- break;
- case 'apc':
- $this->tpl->assign('identifiername',ini_get('apc.rfc1867_name'));
- break;
- case 'cgi':
- $_SESSION['user']['identifier']=randomName(32,32);
- $this->tpl->assign('uploadscript',app()->config['progress_cgi'].'?upload_id='.session_id());
- /* update information on the file */
-$_CGI['temp_dir'] = '/tmp/';
-$_CGI['upload_id'] = $_SESSION['user']['identifier'];
-$_CGI['upload_dir'] = '/tmp/';
-$_CGI['path_to_link_file'] = '/tmp/'.session_id().'.link';
-$_CGI['embedded_upload_results'] = 0;
-$_CGI['redirect_method'] = 1;
-$_CGI['redirect_url'] = app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/';
-$_CGI['cgi_upload_hook'] = 0;
-$_CGI['debug_upload'] = 0;
-$_CGI['delete_link_file'] = 0;
-$_CGI['purge_temp_dirs'] = 1;
-$_CGI['purge_temp_dirs_limit'] = 1;
-$_CGI['max_upload_size'] = $_SESSION['user']['max_upload_size'];
-$c = '';
-foreach ($_CGI as $k => $value) {
- $c .= $k.'<=>'.$value."\n";
-}
- file_put_contents('/tmp/'.session_id().'.link',$c);
- $this->tpl->assign('identifiername','UPLOAD_IDENTIFIER');
- break;
- default:
- $this->tpl->assign('identifiername','UPLOAD_IDENTIFIER');
- break;
- }
- app()->tpl->assign('identifier',$_SESSION['user']['identifier']);
- $result = app()->pluginAction('uploadForm',$finfo);
- }
-
- function uploadProgress() {
- global $_SESSION;
-
- if (isset($_SESSION['user']['identifier'])) {
- ob_clean();
- header("Cache-Control: no-cache, must-revalidate");
- header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- // need this 'cause of IE problems
- header('Content-Type: text/html; Charset=utf-8');
-
- $progress = array('complete' => 0, 'total' => 0, 'percentage' => 0, 'files' => 0);
- switch (app()->config['progress']) {
- case 'uploadprogress':
- $res = uploadprogress_get_info($_SESSION['user']['identifier']);
- if (isset($res['bytes_uploaded'])) {
- $progress['complete'] = $res['bytes_uploaded'];
- if ($res['bytes_total']>0) {
- $progress['total'] = $res['bytes_total'];
- $progress['percentage'] = floor(($res['bytes_uploaded'] / $res['bytes_total'])*100);
- }
- $progress['files'] = $res['files_uploaded'];
- }
- break;
- case 'apc':
- $res = apc_fetch(ini_get('apc.rfc1867_prefix').$_SESSION['user']['identifier']);
- if ($res) {
- $progress['complete'] = $res['current'];
- $progress['total'] = $res['total'];
- if ($res['total']>0)
- $progress['percentage'] = floor(($res['current'] / $res['total'])*100);
- $progress['files'] = 0;
- }
- break;
- case 'cgixyz':
- $res = cgiupload_get_info($_SESSION['user']['identifier']);
- if (isset($res['bytes_uploaded'])) {
- $progress['complete'] = $res['bytes_uploaded'];
- if ($res['bytes_total']>0) {
- $progress['total'] = $res['bytes_total'];
- $progress['percentage'] = floor(($res['bytes_uploaded'] / $res['bytes_total'])*100);
- }
- $progress['files'] = $res['files_uploaded'];
- }
- break;
- }
- app()->tpl->assign('progress',$progress);
- app()->display('modules/files/uploadProgress');
- exit;
- }
- echo 'user not allowed';
- exit;
- }
-
- function uploadOptions() {
- global $_SESSION;
- global $_FILES;
- global $_SERVER;
-
- switch (app()->config['progress']) {
- case 'cgi':
- /* populate the variables so that it will be available to the following code */
-
- break;
- }
- if (isset($_FILES['upload'])) {
- if ($_FILES['upload']['error']>0) {
- switch ($_FILES['upload']['error']) { /* taken from here: http://it.php.net/manual/en/features.file-upload.errors.php */
- case 1: $msg = 'Maximum upload size for site wide configuration reached'; break;
- case 2: $msg = 'Maximum file size exceeded!'; break;
- case 3: $msg = 'Partial file transfer error!'; break;
- case 4: $msg = 'No file was uploaded!'; break;
- case 6: $msg = 'Missing temporary directory'; break;
- case 7: $msg = 'Can\'t write to temporary diretory!'; break;
- case 8: $msg = 'Upload blocked by extension!'; break;
- default:
- $msg = tr('Upload failed for Unknown error code: %1',$_FILES['upload']['error']); break;
- }
- app()->log('warning','uploadOptions','','DENY','Upload error: '.$msg);
- app()->error(tr($msg));
- $this->nextStep(1);
- } else if ($_FILES['upload']['size']>app()->user->info('max_upload_size')) {
- app()->log('warning','uploadOptions','','DENY','Maximum file size exceeded!');
- app()->error(tr('Maximum file size exceeded!'));
- break;
- } else {
- /* prepare the file */
- $tmpname = app()->config['DATA_PATH'].'/tmp/'.randomName();
- for ($i = 0; $i<app()->config['multiupload']; $i++) {
- $u = 'upload';
- $tmpnamex = $tmpname;
- if ($i>0) {
- $u = 'upload_'.$i;
- $tmpnamex = $tmpname.'_'.$i;
- }
- if (isset($_FILES[$u]) and $_FILES[$u]['tmp_name']!='') {
- move_uploaded_file($_FILES[$u]['tmp_name'],$tmpnamex);
- $_SESSION['user']['u'][$i]['tmp']=$tmpnamex;
- $_SESSION['user']['u'][$i]['mime']=$_FILES[$u]['type'];
- $_SESSION['user']['u'][$i]['name']=$_FILES[$u]['name'];
- $_SESSION['user']['u'][$i]['size']=$_FILES[$u]['size'];
- $_SESSION['user']['u'][$i]['ip']=$_SERVER['REMOTE_ADDR'];
- $_SESSION['user']['u'][$i]['user_login']=app()->user->info('login');
- }
- }
- $result = app()->pluginAction('uploadComplete',$_SESSION['user']['u']);
- if (!$result) { /* some plugin blocked the upload */
- /* remove the file */
- foreach ($_SESSION['user']['u'] as $f) {
- @unlink($f['tmp']);
- }
- unset($_SESSION['user']['u']);
- redirect();
- }
- $this->nextStep(app()->step);
- }
- } else if (!isset($_SESSION['user']['u'][0])) {
- redirect();
- }
- if (!$result) { /* some plugin blocked the upload */
- /* remove the files */
- unset($_SESSION['user']['u']);
- redirect();
- }
- $this->tpl->assign('finfo',$_SESSION['user']['u'][0]);
- $this->tpl->assign('files',$_SESSION['user']['u']);
- /* ask for information on the file */
- }
-
- function uploadConfirm() {
- global $_POST;
- global $_SESSION;
-
- /* save the file */
- /* send an e-mail if requested */
- /* display the information on the upload */
- if (isset($_POST['description'])) {
- /* now check plugins and if ok add file otherwise redirect */
- $result = app()->pluginAction('uploadConfirm',$_SESSION['user']['u']);
- if (!$result)
- $this->prevStep();
- for ($i = 0; $i<count($_SESSION['user']['u']); $i++) {
- $finfo = $_SESSION['user']['u'][$i];
- $finfo['description'] = $_POST['description'];
- if ($i==0) {
- $s = isset(app()->config['id_max_length'])?app()->config['id_max_length']:30;
- $a = isset(app()->config['id_use_alpha'])?app()->config['id_use_alpha']=='yes':false;
- $finfo['id']= app()->db->newRandomId('files','id',$s,$a);
- $mainid = $finfo['id'];
- $remove = app()->db->newRandomId('files','remove',$s,$a);
- $date = date('Y-m-d H:i:s');
- } else {
- $finfo['id']=$mainid.'_'.$i;
- }
- /* everything ok then add the file */
- $finfo['remove']= $remove;
- $finfo['upload_date'] = $date;
- app()->db->insert('files',$finfo,array('id','name','mime','description','size','remove','user_login','ip','upload_date'));
- if ($i==0) {
- foreach (app()->plugins as $plugin) {
- if (count($plugin->fields)>0) {
- foreach ($plugin->fields as $f) {
- if (isset($finfo[$f])) {
- $pinfo['file_id'] = $finfo['id'];
- $pinfo['module'] = $plugin->name;
- $pinfo['name']=$f;
- $pinfo['value']=$finfo[$f];
- app()->db->insert('file_options',$pinfo,array('file_id','module','name','value'));
- }
- }
- }
- }
- } else {
- $pinfo['file_id'] = $finfo['id'];
- $pinfo['module'] = 'files';
- $pinfo['name']='group';
- $pinfo['value']=$mainid;
- app()->db->insert('file_options',$pinfo,array('file_id','module','name','value'));
- }
- /* move the file to the actual location */
- rename($_SESSION['user']['u'][$i]['tmp'],app()->config['DATA_PATH'].'/'.$finfo['id']);
- $_SESSION['user']['u'][$i]=$finfo;
- }
- app()->log('notice','uploadConfirm','','ALLOW',$mainid);
- $this->nextStep();
- }
- }
-
- function setupLinks(&$finfo) {
- /* get the file info */
- $a = 'action'; $i = 'id'; $r = 'removeid';
- if (app()->config['use_short_links']=='yes') {
- $a = 'a'; $i = 'i'; $r = 'r';
- }
- $finfo[0]['downloadlink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?'.$a.'=d&'.$i.'='.$finfo[0]['id'];
- $finfo[0]['removelink']=app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].
- '/?'.$a.'=r&'.$i.'='.$finfo[0]['id'].'&'.$r.'='.$finfo[0]['remove'];
- }
-
- function uploadFileInfo() {
- if (isset($_SESSION['user']['u'][0]['id'])) {
- $finfo = $_SESSION['user']['u'];
- $this->setupLinks($finfo);
- $result = app()->pluginAction('uploadFileInfo',$finfo,false);
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- $this->tpl->assign('webbase',app()->config['WWW_SERVER'].app()->config['WWW_ROOT']);
- } else {
- redirect();
- }
- }
-/**/
- function loadFile($id) {
- $finfo = app()->db->read('files',array('id'=>$id));
- $pinfo = app()->db->read('file_options',array('file_id' => $id));
- foreach ($pinfo as $v) {
- $finfo[0][$v['name']]=$v['value'];
- }
- $afiles = app()->db->read('file_options',array('module' => 'files', 'name' => 'group', 'value' => $id));
- if (count($afiles)>0) {
- foreach ($afiles as $k => $a) {
- $afile = app()->db->read('files',array('id'=>$a['file_id']));
- $finfo[$k+1]=$afile[0];
- }
- }
-//print_r($finfo); exit();
- return $finfo;
- }
-
- function downloadForm() {
- global $_SESSION;
- global $_GET;
-
- unset($_SESSION['user']['d']);
- if (isset($_GET['id']) or isset($_GET['i'])) {
- $_SESSION['user']['d'][0]['id'] = isset($_GET['id'])?$_GET['id']:$_GET['i'];
- $this->nextStep();
- }
- $finfo = array();
- app()->pluginAction('downloadForm',$finfo,false);
- }
-
- function downloadRequest() {
- global $_GET;
- global $_POST;
- global $_SESSION;
-
- $id = '';
- if (isset($_POST['id'])) {
- $id = $_POST['id'];
- } else if (isset($_SESSION['user']['d'][0]['id'])) {
- $id = $_SESSION['user']['d'][0]['id'];
- }
- /* check if download exists, and what are the properties */
- if ($id != '') {
- $finfo = $this->loadFile($id);
- if ($finfo[0]['id']!=$id or isset($finfo[0]['group'])) {
- app()->log('warning','downloadRequest','','DENY','File does not exist: ID:'.$id);
- app()->error(tr('Requested file does not exist!'));
- $this->prevStep();
- } else {
- $_SESSION['user']['d']=$finfo;
- $_SESSION['user']['d'][0]['protected'] = true;
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- $result = app()->pluginAction('downloadRequest',$finfo,false);
- if ($result) {
- app()->log('info','downloadRequest','','ALLOW',$id);
- $_SESSION['user']['d'][0]['protected']=false;
- $this->nextStep();
- }
- }
- }
- }
-
- function downloadConfirm() {
-
- /* here we do the actual download of the file */
- if (!isset($_SESSION['user']['d'])) {
- redirect();
- } else if ($_SESSION['user']['d'][0]['candownload']=='ok') {
- $finfo = $_SESSION['user']['d'];
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- /* download is allowed */
- } else {
- $finfo = $_SESSION['user']['d'];
- /* check wether the plugins are ok */
- $result = app()->pluginAction('downloadConfirm',$finfo);
- if (!$result)
- $this->prevStep();
- for ($i = 0; $i<count($finfo); $i++)
- $finfo[$i]['candownload']='ok';
- $_SESSION['user']['d']=$finfo;
- /* now the user can download it */
- $this->nextStep(app()->step);
- }
- }
-
- function serveFile() {
- global $_SESSION;
- global $_POST;
- global $_GET;
-
- $num = 0;
- if (isset($_GET['fid'])) {
- $num = $_GET['fid'];
- }
- /* here we do the actual download of the file */
- if (!isset($_SESSION['user']['d'])) {
- redirect();
- } else if ($_SESSION['user']['d'][$num]['candownload']!='ok') {
- $this->nextStep(2,'d');
- } else {
- $finfo = $_SESSION['user']['d'];
- /* check wether the plugins are ok */
- $result = app()->pluginAction('serveFile',$finfo);
- if (!$result)
- $this->nextStep(3,'d');
- //$_SESSION['user']['d'][$num]['candownload']='ok';
- /* if we got this far the download should begin serving */
- $file = app()->config['DATA_PATH'].'/'.$finfo[$num]['id'];
- $filesize = filesize($file);
- /* set to not timeout within default setting */
- if (isset(app()->config['max_download_time'])) {
- set_time_limit(app()->config['max_download_time']*60);
- } else {
- set_time_limit(7200); /* 2 hours should be enough */
- }
- app()->log('notice','serveFile','','ALLOW',$finfo[$num]['id']);
- /* disable and clean output buffer so it won't reach memory limit */
- ob_end_clean();
- header('Content-Description: File Transfer');
- header('Content-Type: '.$finfo[$num]['mime']);
- header('Content-Length: '.$filesize);
- header('Content-Disposition: attachment; filename="'.$finfo[$num]['name'].'"');
- header('Content-Transfer-Encoding: binary');
- header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
- header('Pragma: public');
-
- readfile($file);
- /* file should have been sent now let's reset the download info */
- if (!$_SESSION['user']['d'][0]['protected'])
- $_SESSION['user']['d'][$num]['candownload']='ok';
- else
- $_SESSION['user']['d'][$num]['candownload']='ko';
- exit(0);
- }
- }
-
- function removeRequest() {
- global $_GET;
- global $_SESSION;
-
- $id = '';
- if (isset($_GET['id']) or isset($_GET['i'])) {
- $id = isset($_GET['id'])?$_GET['id']:$_GET['i'];
- $r = isset($_GET['removeid'])?$_GET['removeid']:$_GET['r'];
- } else if (isset($_SESSION['user']['r'][0]['id'])) {
- $id = $_SESSION['user']['r'][0]['id'];
- $r = $_SESSION['user']['r'][0]['remove'];
- }
- /* check if file exists, and what are the properties */
- if ($id != '') {
- $finfo = $this->loadFile($id);
- if ($finfo[0]['id']!=$id or isset($finfo[0]['group'])) {
- app()->error(tr('Wrong file id!'));
- redirect();
- } else if ($r!=$finfo[0]['remove']) {
- app()->error(tr('Wrong file id!')); /* don't give the user much info on this */
- redirect();
- } else {
- $_SESSION['user']['r']=$finfo;
- $this->tpl->assign('files',$finfo);
- $this->tpl->assign('finfo',$finfo[0]);
- if (app()->config['allow_unprotected_removal']=='yes')
- $result = true;
- else
- $result = app()->pluginAction('removeRequest',$finfo,false);
- if ($result) {
- app()->log('info','removeRequest','','ALLOW',$id);
- $_SESSION['user']['r'][0]['canremove']='ok'; /* file has no protection */
- $this->nextStep();
- }
- }
- } else {
- app()->error(tr('Wrong file id!'));
- redirect();
- }
- }
-
- function removeConfirm() {
- $finfo = $_SESSION['user']['r'];
-
- /* here we do the actual remove of the file */
- if (!isset($_SESSION['user']['r'])) {
- redirect();
- } else if ($_SESSION['user']['r'][0]['canremove']=='ok') {
- $finfo = $_SESSION['user']['r'];
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- /* removal is allowed */
- } else {
- $finfo = $_SESSION['user']['r'];
- /* check wether the plugins are ok */
- if (app()->config['allow_unprotected_removal']=='yes')
- $result = true;
- else
- $result = app()->pluginAction('removeConfirm',$finfo);
- if (!$result)
- $this->prevStep();
- /* now we can remove the file */
- $_SESSION['user']['r'][0]['canremove']='ok';
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- }
- }
-
- function removeResult() {
- global $_POST;
-
- if (!isset($_SESSION['user']['r'])) {
- redirect();
- } else if (isset($_POST['confirmremove']) and ($_SESSION['user']['r'][0]['canremove']=='ok')) {
- $finfo = $_SESSION['user']['r'];
- $result = app()->pluginAction('removeResult',$finfo,false);
- if (!$result)
- $this->prevStep();
- foreach ($finfo as $f) {
- app()->db->delete('files',array('id' => $f['id']));
- app()->db->delete('file_options',array('file_id' => $f['id']));
- $file = app()->config['DATA_PATH'].'/'.$f['id'];
- @unlink($file);
- }
- app()->log('notice','removeResult','','ALLOW',$finfo[0]['id']);
- unset($_SESSION['user']['r']); /* remove any file reference */
- $this->tpl->assign('files',$finfo);
- $this->tpl->assign('finfo',$finfo[0]);
- } else {
- $this->prevStep();
- }
- }
-
- function fileList() {
- global $_GET;
- /* TODO: need paging ... */
- $rows = 20;
- $page = isset($_GET['page'])?$_GET['page']:1;
- $offset = ($page -1)*$rows;
- $count = app()->db->count('files',array('user_login'=>app()->user->info('login')));
- $pages = ceil($count / $rows)+1;
- $files = app()->db->read('files',array('user_login'=>app()->user->info('login')),array('upload_date desc'),$offset.','.$rows);
- $result = app()->pluginAction('fileList',$files,false);
- if (!$result)
- redirect();
- $this->tpl->assign('pagen',$page);
- $this->tpl->assign('pages',$pages);
- $this->tpl->assign('files',$files);
- }
-
- function fileDetail() {
- global $_GET;
-
- if (!isset($_GET['id'])) {
- $this->nextStep(1);
- }
- $finfo = $this->loadFile($_GET['id']);
- if (count($finfo)==0) {
- app()->error(tr('Wrong file id!'));
- $this->nextStep(1);
- } else if ($finfo[0]['user_login']!=app()->user->info('login')) {
- /* the user has no right to access this file !!! */
- app()->error(tr('Wrong file id!'));
- $this->nextStep(1);
- } else if (isset($finfo[0]['group'])) {
- /* it's a group file */
- app()->error(tr('Wrong file id!'));
- $this->nextStep(1);
- }
- $this->setupLinks($finfo);
- if (app()->user->info('login')=='') {
- unset($finfo[0]['removelink']);
- }
- $result = app()->pluginAction('fileDetail',$finfo,false);
- if (!$result) {
- $this->nextStep(1);
- }
- $this->tpl->assign('finfo',$finfo[0]);
- $this->tpl->assign('files',$finfo);
- }
-}
-
-?>
\ No newline at end of file
Added: trunk/lib/modules/default/invitation.inc.php
===================================================================
--- trunk/lib/modules/default/invitation.inc.php (rev 0)
+++ trunk/lib/modules/default/invitation.inc.php 2010-03-18 18:24:11 UTC (rev 370)
@@ -0,0 +1,488 @@
+
+<?php
+
+class InvitationModule extends BaseUploadModule {
+var $actions = array (
+ "i" => array ( /* handle invitation creation */
+ 1 => "createForm",
+ 2 => "createOptions",
+ 3 => "createInfo",
+ ),
+ "s" => array ( /* handle invitation uploads */
+ 1 => "uploadRequest",
+ 2 => "uploadForm",
+ 3 => "uploadFiles",
+ 4 => "uploadResult...
[truncated message content] |
|
From: <ts...@us...> - 2009-02-05 15:42:27
|
Revision: 229
http://openupload.svn.sourceforge.net/openupload/?rev=229&view=rev
Author: tsdogs
Date: 2009-02-05 15:42:18 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Add shorter links handling
Add options for configuring ids length and form
Modified Paths:
--------------
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/files.inc.php
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2009-02-05 15:40:38 UTC (rev 228)
+++ trunk/lib/modules/default/admin.inc.php 2009-02-05 15:42:18 UTC (rev 229)
@@ -803,6 +803,9 @@
$config['template']=$_POST['template'];
$config['multiupload']=$_POST['multiupload'];
$config['max_upload_size']=$_POST['max_upload_size'];
+ $config['use_short_links']=isset($_POST['use_short_links'])?'yes':'no';
+ $config['id_max_length']=$_POST['id_max_length'];
+ $config['id_use_alpha']=isset($_POST['id_use_alpha'])?'yes':'no';;
$config['progress']=$_POST['progress'];
$config['logging']['enabled']=isset($_POST['logging'])?'yes':'no';
$config['logging']['db_level']=$_POST['log_db_level'];
Modified: trunk/lib/modules/default/files.inc.php
===================================================================
--- trunk/lib/modules/default/files.inc.php 2009-02-05 15:40:38 UTC (rev 228)
+++ trunk/lib/modules/default/files.inc.php 2009-02-05 15:42:18 UTC (rev 229)
@@ -198,9 +198,11 @@
$finfo = $_SESSION['user']['u'][$i];
$finfo['description'] = $_POST['description'];
if ($i==0) {
- $finfo['id']= app()->db->newRandomId('files','id');
+ $s = isset(app()->config['id_max_length'])?app()->config['id_max_length']:30;
+ $a = isset(app()->config['id_use_alpha'])?app()->config['id_use_alpha']=='yes':false;
+ $finfo['id']= app()->db->newRandomId('files','id',$s,$a);
$mainid = $finfo['id'];
- $remove = app()->db->newRandomId('files','remove');
+ $remove = app()->db->newRandomId('files','remove',$s,$a);
$date = date('Y-m-d H:i:s');
} else {
$finfo['id']=$mainid.'_'.$i;
@@ -243,8 +245,12 @@
if (isset($_SESSION['user']['u'][0]['id'])) {
$finfo = $_SESSION['user']['u'];
/* get the file info */
- $finfo[0]['downloadlink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?action=d&id='.$finfo[0]['id'];
- $finfo[0]['removelink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?action=r&id='.$finfo[0]['id'].'&removeid='.$finfo[0]['remove'];
+ $a = 'action'; $i = 'id'; $r = 'removeid';
+ if (app()->config['use_short_links']=='yes') {
+ $a = 'a'; $i = 'i'; $r = 'r';
+ }
+ $finfo[0]['downloadlink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?'.$a.'=d&'.$i.'='.$finfo[0]['id'];
+ $finfo[0]['removelink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?'.$a.'=r&'.$i.'='.$finfo[0]['id'].'&'.$r.'='.$finfo[0]['remove'];
$result = app()->pluginAction('uploadFileInfo',$finfo,false);
$this->tpl->assign('finfo',$finfo[0]);
$this->tpl->assign('files',$finfo);
@@ -276,8 +282,8 @@
global $_GET;
unset($_SESSION['user']['d']);
- if (isset($_GET['id'])) {
- $_SESSION['user']['d'][0]['id'] = $_GET['id'];
+ if (isset($_GET['id']) or isset($_GET['i'])) {
+ $_SESSION['user']['d'][0]['id'] = isset($_GET['id'])?$_GET['id']:$_GET['i'];
$this->nextStep();
}
$finfo = array();
@@ -398,18 +404,19 @@
global $_SESSION;
$id = '';
- if (isset($_GET['id'])) {
- $id = $_GET['id'];
+ if (isset($_GET['id']) or isset($_GET['i'])) {
+ $id = isset($_GET['id'])?$_GET['id']:$_GET['i'];
} else if (isset($_SESSION['user']['r'][0]['id'])) {
$id = $_SESSION['user']['r'][0]['id'];
}
/* check if download exists, and what are the properties */
if ($id != '') {
$finfo = $this->loadFile($id);
+ $r = isset($_GET['removeid'])?$_GET['removeid']:$_GET['r'];
if ($finfo[0]['id']!=$id) {
app()->error(tr('Wrong file id!'));
redirect();
- } else if ($_GET['removeid']!=$finfo[0]['remove']) {
+ } else if ($r!=$finfo[0]['remove']) {
app()->error(tr('Wrong file id!')); /* don't give the user much info on this */
redirect();
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|