Post by alix on Jan 27, 2008 3:55:21 GMT -5
Here is my first program. I made it so I could display and exchange photos with friends. If you wanted to exchange other files than JPG, it wouldn't be difficult either.
If I manage to put it online, I will add the link later.
All comments welcome !
@+
[update of program : 29/01/08]
If I manage to put it online, I will add the link later.
All comments welcome !
@+
[update of program : 29/01/08]
'#############################################
'
' PHOTOSHARE by Alix Whittal - Jan 2008
'
'#############################################
'***********************************************************
'
' ENTER YOUR OWN PARAMETERS HERE !
'
' -> usertot = number of users who are going to share photos
' -> user$(1,2) = 1=name of user - 2=password
' -> filename$ = name of directory containing the uploads
'
' The username are the same as their upload directory
' i.e. John will upload their files to the
' public/upload/John directory
'
'************************************************************
global UploadUrl$, UploadDir$
UploadUrl$ = "uploads/"
UploadDir$="uploads\"
usertot=4
dim user$(usertot,2)
user$(1,1)="Tim"
user$(1,2)="a"
user$(2,1)="Tom"
user$(2,2)="b"
user$(3,1)="Tess"
user$(3,2)="c"
user$(4,1)="Miss"
user$(4,2)="d"
'******************************************
' END OF PARAMETERS AREA
'******************************************
global DefaultDir$ 'bug in RB fixed in next version
for i=1 to usertot
familygroup$= familygroup$ + user$(i,1) + ","
next
a = mkdir("public\";UploadDir$)
print a
'******************************************
' MAIN PROGRAM
'******************************************
[Start]
cls
print "-------------------------------------------------------------"
print "- Welcome to AlixBasix Friendly Photoshare utility !!! -"
print "-------------------------------------------------------------"
Print "-------> CHOOSE A FAMILY :"
radiogroup #rgroup, familygroup$, user$(1,1)
#rgroup horizontal(1)
link #exec, "submit!", [ChooseAction]
wait
[ChooseAction]
groupChoice$ = #rgroup selection$()
cls
print groupChoice$
print "~~~~~~~~~~~~~~~~~"
radiogroup #rgroup2, "View/Download,Upload,Choose Again", ""
link #exec, "submit!", [MakeAction]
wait
[MakeAction]
family$=groupChoice$+"\"
groupChoice2$ = #rgroup2 selection$()
if groupChoice2$="" then print "please make a selection !"
if groupChoice2$="Choose Again" then goto [Start]
if groupChoice2$ = "View/Download" then result=DiplayJPG(groupChoice$, 4)
'Only users with valid passwords can upload files
if groupChoice2$ = "Upload" then goto [ValidUserCheck]
wait
[ValidUserCheck]
cls
userok=0
userno=0
input "Username";username$
for i=1 to usertot
if username$ = user$(i,1) then
userno=i
userok=1
exit for
end if
next i
if userok = 0 then
cls
print "Invalid username"
goto [ValidUserCheck]
end if
userok=0
cls
print "Password ?"
passwordbox #pw, ""
link #action, "Submit", [ValidPasswordCheck]
wait
[ValidPasswordCheck]
pass$= #pw CONTENTS$()
if pass$ <> user$(userno,2) then
print "Invalid Password"
goto [ValidUserCheck]
wait
end if
[UploadMenu]
cls
print:print
print " *** NOTE !!! ***"
print " Photos maximum size = 1024x768"
print " ------------------------------"
print " to resize JPG files, you can use the Image Resizer from Microsoft"
print " Image Resizer enables you to resize one or MANY image files with a right-click"
html "<a href=""http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx target=_blank"">Download Image Resizer</a>"
print:print
print:print
link #action, "Finished with uploads", [NoMore]
link #action, "Continue with uploads", [UploadAgain]
wait
[NoMore]
goto [Start]
wait
[UploadAgain]
path$="public\" + UploadDir$ + groupChoice$
a = mkdir(path$)
if a then
print "Created directory: ";path$
end if
result=UploadJPG(path$)
goto [UploadMenu]
wait
'*******************************************************
' FUNCTIONS AND SUBS
'*******************************************************
'
' DIPLAYJPG : get JPG files and display n at a time
'******************************************************
function DiplayJPG(groupChoice$, n)
path$="public\" + UploadDir$ + groupChoice$
a = mkdir(path$)
if a then
print "Created directory: ";path$
end if
print "To download, Click right on picture and select SAVE AS"
filepath$="public\"+UploadDir$+groupChoice$+"\*.jpg"
files #g, filepath$
if #g HASANSWER() then
count = #g rowcount()
for i = 1 to count
if #g hasanswer() then
'retrieve info for next file
dummy$ = #g nextfile$()
img$="../public/";UploadUrl$;groupChoice$;"/";#g NAME$()
if count4 = 4 then
html "<br>"
count4=0
end if
count4=count4+1
html "<img src="""; img$; """ width=""200"" hight=""150"">"
end if
next
else
emptymsg$="there are no files in " + groupChoice$ + "'s folder"
Print emptymsg$
end if
End Function
'**************************************************
' UPLOADJPG
'**************************************************
function UploadJPG(path$)
upload "Select a file to upload."; file$
if file$ <> "" then
open file$ for binary as #f
filedata$ = input$(#f, LOF(#f))
close #f
open path$ + "\" + file$ for binary as #g
print #g, filedata$
close #g
'delete uploaded file from root directory
kill file$
end if
end function