Commit f903548e authored by Frank Bergmann's avatar Frank Bergmann

- Remove outdated code

parent 736b9e32
# /file-storage/download.tcl
ad_page_contract {
see if this person is authorized to read the file in question
guess the MIME type from the original client filename
have the Oracle driver grab the BLOB and write it to the connection
@author aure@arsdigita.com
@creation-date July 1999
@cvs-id download.tcl,v 3.4.2.3 2000/07/27 21:22:13 jwong Exp
modified by randyg@arsdigita.com, January 2000 to use the general
permissions module
} {
file_name:notnull
project_id:integer
} -errors {
file_name:notnull {No file was specified}
project_id:integer {The project_id specified doesn't look like an integer.}
}
set user_id [auth::require_login]
set project_path [im_filestorage_project_path $project_id]
set file "$project_path/$file_name"
set guessed_file_type [ns_guesstype $file]
ns_log notice "file_name=$file_name"
ns_log notice "file=$file"
ns_log notice "file_type=$guessed_file_type"
db_dml insert_action "
insert into im_fs_actions (
action_type_id
user_id
action_date
file_name
) values (
[im_file_action_download],
:user_id,
now(),
:file_name
)"
if {[file readable $file]} {
ad_returnfile 200 $guessed_file_type $file
} else {
ad_returnredirect "/error.tcl"
}
# /www/intranet/filestorage/index.tcl
ad_page_contract {
Show the content a specific subdirectory
} {
}
doc_return 200 text/html "ok"
ad_page_contract {
insert a file into the file system
} {
folder
{folder_type ""}
project_id:integer
return_url
upload_file
{file_title:trim ""}
{description ""}
}
set user_id [auth::require_login]
set user_is_admin_p [im_is_user_site_wide_or_intranet_admin $user_id]
set page_title "Upload into '$folder'"
set context_bar [im_context_bar [list "/intranet/projects/" "Projects"] [list "/intranet/projects/view?group_id=$project_id" "One Project"] "Upload File"]
# check the user input first
#
set exception_text ""
set exception_count 0
if {!$user_is_admin_p && ![im_biz_object_member_p $user_id $project_id] } {
append exception_text "<li>You are not a member of this project.\n"
incr exception_count
}
if {"" == $folder_type} {
append exception_text "<LI>Internal Error: folder_type not specified"
incr exception_count
}
if { $exception_count > 0 } {
ad_return_complaint $exception_count $exception_text
return 0
}
# Get the file from the user.
# number_of_bytes is the upper-limit
set max_n_bytes [im_parameter -package_id [im_package_filestorage_id] MaxNumberOfBytes "" 0]
set tmp_filename [ns_queryget upload_file.tmpfile]
im_security_alert_check_tmpnam -location "upload-2.tcl" -value $tmp_filename
ns_log Notice "upload-2: tmp_filename=$tmp_filename"
if { $max_n_bytes && ([file size $tmp_filename] > $max_n_bytes) } {
ad_return_complaint 1 "Your file is larger than the maximum permissible upload size: [util_commify_number $max_n_bytes] bytes"
return 0
}
set file_extension [string tolower [file extension $upload_file]]
# remove the first . from the file extension
regsub "\." $file_extension "" file_extension
set guessed_file_type [ns_guesstype $upload_file]
set n_bytes [file size $tmp_filename]
# strip off the C:\directories... crud and just get the file name
if {![regexp {([^//\\]+)$} $upload_file match client_filename]} {
# couldn't find a match
set client_filename $upload_file
}
if {[regexp {\.\.} $client_filename]} {
set error "<li>Path contains forbidden characters<br>
Please don't use '.' characters."
ad_return_complaint "User Error" $error
}
# ---------- Determine the location where to save the file -----------
switch $folder_type {
"project" {
set project_path [im_filestorage_project_path $project_id]
set dest_path "$project_path/$folder/$client_filename"
}
"company" {
set path [im_filestorage_company_path $project_id]
set dest_path "$path/$folder/$client_filename"
}
"user" {
set path [im_filestorage_user_path $project_id]
set dest_path "$path/$folder/$client_filename"
}
default {
ad_return_complaint 1 "<LI>Unknown folder type \"$folder_type\"."
return
}
}
# --------------- Let's copy the file into the FS --------------------
if { [catch {
ns_log Notice "/bin/cp $tmp_filename $dest_path"
exec /bin/cp $tmp_filename $dest_path
} err_msg] } {
# Probably some permission errors
ad_return_complaint "Error writing upload file" $err_msg
return
}
# --------------- Log the interaction --------------------
db_dml insert_action "
insert into im_fs_actions (
action_type_id
user_id
action_date
file_name
) values (
[im_file_action_upload],
:user_id,
now(),
'$dest_path/$client_filename'
)"
set page_content "
<H2>Upload Successful</H2>
You have successfully uploaded $n_bytes bytes of '$client_filename'.<br>
You can now return to the project page.
<P>
<form method=post action=\"$return_url\">
<input type=submit value=\"Return to Previous Page\">
</form>
"
db_release_unused_handles
doc_return 200 text/html [im_return_template]
# /intranet/filestorage/upload.tcl
ad_page_contract {
Serve the user a form to upload a new file or URL
@author aure@arsdigita.com
@author frank.bergmann@project-open.com
@creation-date 030909
} {
folder:notnull
{folder_type ""}
project_id:notnull
return_url:notnull
}
set user_id [auth::require_login]
set page_title "Upload New File/URL"
set context_bar [im_context_bar [list "/intranet/projects/" "Projects"] [list "/intranet/projects/view?group_id=$project_id" "One Project"] "Upload File"]
if {"" == $folder_type} {
ad_return_complaint 1 "<LI>Internal Error: folder_type not specified"
return
}
# replace the "root" folder "/" with an empty string
if {$folder eq "/" } {
set folder ""
}
set alt_msg "Use the &quot;Browse...&quot; button to locate your file, then click &quot;Open&quot;."
set page_content "
<form enctype=multipart/form-data method=POST action=upload-2.tcl>
[export_vars -form {folder folder_type project_id return_url}]
<table border=0>
<tr>
<td align=right>Filename: </td>
<td>
<input type=file name=upload_file size=30>
<img src=/images/help.gif width=16 height=16 title=\"$alt_msg\" alt=\"$alt_msg\">
</td>
</tr>
<!--
<tr>
<td align=right> Title: </td>
<td>
<input size=40 name=file_title>
</td>
</tr>
<tr>
<td valign=top align=right>Comments: </td>
<td colspan=2>
<textarea rows=5 cols=50 name=description wrap></textarea>
</td>
</tr>
-->
<tr>
<td></td>
<td>
<input type=submit value=\"Submit and Upload\">
</td>
</tr>
</table>
</form>
"
db_release_unused_handles
set page_title "Upload into '$folder'"
doc_return 200 text/html [im_return_template]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment