<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">##################################################
# npa_upload.pl v2.5 (BETA)for NewsPro			 # 
# By Russ Mckendrick							 # 
# With help and inspiration from Jim Logan		 # 
# Email: russ@rock-city.co.uk					 # 
# Web:   www.rock-city.co.uk					 #
##################################################
# NewsPro Addon Hooks

push(@Addons_Loaded, 'Upload v2.5');
push(@Addons_PageHandler, 'npa_upload_PageHandler');
push(@Addons_MainPage, 'npa_upload_MainPage');
#push(@Addons_MainPage, 'npa_upload_delete_MainPage');
push(@Addons_NPHTMLFoot, 'npa_upload_HTMLFoot');
#push(@Addons_NPHTMLFoot, 'npa_upload_delete_HTMLFoot');
push(@Addons_LoadHelp, 'npa_upload_LoadHelp');
push(@Addons_AdvancedSettingsLoad, 'Addnpa_Upload_Settings');
push(@Addons_DisplaySubForm_Post4, 'npa_upload_body');
#push(@Addons_DisplaySubForm_Post3, 'npa_UploadList_Link');
push(@Addons_NPHTMLHead_Head, 'npa_UploadList_Head');
$Addons_List{'Upload v2.5'} = ['npa_upload.pl', '&lt;b&gt;BETA&lt;/b&gt;Upload and view files from with NewsPro.'];

##################################################
# What are we doing?

sub npa_upload_PageHandler {
if (query_string() eq "npa_upload_mainpage") {
&amp;npa_upload_main;
exit;
}
if (query_string() eq "npa_UploadList_remote") {
&amp;npa_UploadList_Remote;
exit;
}
if (query_string() eq "npa_upload_delete") {
&amp;npa_upload_remove;
exit;
}
if (query_string() eq "npa_remove_success") {
&amp;npa_remove_succ;
exit;
}
elsif (query_string() eq "npa_upload_success") {
&amp;npa_upload_succ;
exit;
}

# 
##################################################


##################################################
# Add the open new window javascript in the header
sub npa_UploadList_Head {
print qq~
&lt;script language="JavaScript"&gt;
&lt;!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//--&gt;
&lt;/script&gt;
~;	
}

##################################################
# Add the link in the bottom menu
sub npa_upload_HTMLFoot {
print qq~ &lt;a href="$scripturl?npa_upload_mainpage"  class="navlink"&gt;Upload/View Files&lt;/a&gt; |~;
} 

##################################################
# Add the delete link in the main menu for webmasters only
sub npa_upload_delete_HTMLFoot {
if ($up == 3) {
	print qq~ &lt;a href="$scripturl?npa_upload_delete" class="navlink"&gt;Delete File&lt;/a&gt;|~
}
}

##################################################
# Add the delete link in the bottom menu for webmasters only
sub npa_upload_delete_MainPage {
if ($up == 3) {
	print qq~	&lt;b&gt;&lt;a href="$scripturl?npa_upload_delete"&gt;Delete File&lt;/a&gt;:&lt;/b&gt; Delete a file.&lt;br&gt;&lt;br&gt;~;
}
}

##################################################
# Add the link in the main menu
sub npa_upload_MainPage {
print qq~
	&lt;b&gt;&lt;a href="$scripturl?npa_upload_mainpage"&gt;Upload/View Files&lt;/a&gt;:&lt;/b&gt; Upload a file or view a list of files.&lt;br&gt;&lt;br&gt;
~;
} 

##################################################
# Add some online help
sub npa_upload_LoadHelp {
$Help{'npa_upload_mainpage'} = q~Select a file you want to upload by using the "Choose" button, you can select serveral at a time. Once you have made your selection click "Upload".~;
$Help{'npa_upload_success'} = q~Your selected files have been uploaded.~;
# $Help{'npa_upload_delete'} = q~Select a file you wish to delete, the click on "DELETE SELECTED FILE" &lt;b&gt;PLEASE NOTE&lt;/b&gt; You can not undo this fucntion once "DELETE SELECTED FILE" has been clicked.~;
$Help{'npa_remove_success'} = q~Your selected file have been deleted.~;
}
##################################################

# Setup all of the setting needed in the advance setting part of news pro
sub Addnpa_Upload_Settings {
$AdvDescr{'UploadDir'} = "Full serverpath to where your files are, no trailing slash ( eg. /home/site/path/to/image/dir ).";
$AdvDescr{'UploadURL'} = "The URL to the directory specified above, no trailing slash ( eg. http://www.yourname.com/image/dir ).";
$AdvDescr{'UploadDir2'} = "Full serverpath to a second upload directory ( please leave blank if you are only using one directory ).";
$AdvDescr{'UploadURL2'} = "The URL to a second upload directory ( please leave blank if you are only using one directory ).";
$AdvDescr{'UploadDir3'} = "Full serverpath to a third upload directory ( please leave blank if you are only using one directory ).";
$AdvDescr{'UploadURL3'} = "The URL to a third upload directory ( please leave blank if you are only using one directory ).";
$AdvDescr{'AllowAll'} = "Do you wish to allow all file types?  yes or no (no capital letters).";
$AdvDescr{'TheExt'} = "If the above = no then which is the only extention to allow. Remember to have the LAST 4 characters eg .gif";
$AdvDescr{'RemoteWidth'} = "The width (in pixels) of the remote window";
$AdvDescr{'RemoteHeight'} = "The height (in pixels) of the remote window";
push(@advancedsettings, 'draw_line','UploadDir','UploadURL','AllowAll','TheExt','RemoteWidth','RemoteHeight','UploadDir2','UploadURL2','UploadDir3','UploadURL3',);
}

##################################################
# Add the remote window link to the Submit Form

sub npa_UploadList_Link {
unless ($NPConfig{'UploadDir'} &amp;&amp; $NPConfig{'UploadURL'} &amp;&amp; $NPConfig{'AllowAll'} &amp;&amp; $NPConfig{'RemoteWidth'} &amp;&amp; $NPConfig{'RemoteHeight'}) {
print "You have not set-up npa_upload.pl, please goto &lt;a href=\"$scripturl?advset\"&gt;\"Advanced Settings\"&lt;/a&gt; and enter the UploadDir, UploadURL, AllowAll, RemoteWidth and RemoteHeight.";
}

print qq~&lt;table width="95%" border="0" cellspacing="0" cellpadding="3" align="center"&gt;&lt;tr&gt;
&lt;td&gt;&lt;div align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$scripturl?npa_UploadList_remote','','scrollbars=yes,resizable=yes,width=200,height=400')"&gt;Click here to open a list of files you can use.&lt;/a&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;~;
}


##################################################
# Upload Main Page (Thanks to Jim Logan for the mod)

sub npa_upload_main {
&amp;NPHTMLHead("Upload a file");
unless ($NPConfig{'UploadDir'} &amp;&amp; $NPConfig{'UploadURL'} &amp;&amp; 
$NPConfig{'AllowAll'} &amp;&amp; $NPConfig{'RemoteWidth'} &amp;&amp; 
$NPConfig{'RemoteHeight'}) {
print "You have not set-up npa_upload.pl, please goto &lt;a 
href=\"$scripturl?advset\"&gt;\"Advanced Settings\"&lt;/a&gt; and enter the 
UploadDir, UploadURL, AllowAll, RemoteWidth and RemoteHeight.";
&amp;NPHTMLFoot;
exit;
}
&amp;npa_upload_body;
&amp;NPHTMLFoot;
}

##################################################
# Main Page Content (Thanks to Jim Logan for the mod)

sub npa_upload_body {
print qq~
&lt;form method="POST" action="upload.pl" enctype="multipart/form-data"&gt;
&lt;div align="center"&gt;
&lt;center&gt;
&lt;h4&gt;&lt;font face="Arial"&gt;File Uploader 2.5&lt;/font&gt;&lt;/h4&gt;
&lt;table border="0" cellspacing="0" cellpadding="3" width="95%"&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 1: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE1"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 2: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE2"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 3: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE3"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 4: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE4"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 5: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE5"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 6: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE6"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 7: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE7"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;File 8: &lt;/font&gt;&lt;/b&gt; 
&lt;input type="file" name="FILE8"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td align="center"&gt; 
&lt;div align="center"&gt;&lt;b&gt;&lt;font face="Arial, Verdana, Helvetica" size="2"&gt;Please select a directory from the list below (please leave as the default if you are not sure)&lt;/font&gt;&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td align="center"&gt; 
&lt;div align="center"&gt; 
&lt;select name="THEDIR"&gt;
&lt;option value="$NPConfig{'UploadDir'}" selected&gt;$NPConfig{'UploadURL'}&lt;/option&gt;~;
if ($NPConfig{'UploadDir2'}) {
print qq~&lt;option value="$NPConfig{'UploadDir2'}"&gt;$NPConfig{'UploadURL2'}&lt;/option&gt;~;
}
if ($NPConfig{'UploadDir2'}) {
print qq~&lt;option value="$NPConfig{'UploadDir3'}"&gt;$NPConfig{'UploadURL3'}&lt;/option&gt;~;
}
print qq~&lt;/select&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt; 
&lt;td align="center"&gt; 
&lt;div align="center"&gt; 
&lt;input type="submit" value="Upload Now" name="submit"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;
&lt;/div&gt;
&lt;/form&gt;
~;
&amp;npa_UploadList_Files;
}
}

##################################################
# Delete Main Page

sub npa_upload_remove {
&amp;NPHTMLHead("Delete a file");
unless ($NPConfig{'UploadDir'} &amp;&amp; $NPConfig{'UploadURL'} &amp;&amp; $NPConfig{'AllowAll'} &amp;&amp; $NPConfig{'RemoteWidth'} &amp;&amp; $NPConfig{'RemoteHeight'}) {
print "You have not set-up npa_upload.pl, please goto &lt;a href=\"$scripturl?advset\"&gt;\"Advanced Settings\"&lt;/a&gt; and enter the UploadDir, UploadURL, AllowAll, RemoteWidth and RemoteHeight.";
&amp;NPHTMLFoot;
exit;
}
print qq~
&lt;form method="POST" action="upremove.pl" enctype="multipart/form-data"&gt;
~;

my $filelist = 0; 

print qq~&lt;b&gt;Listing For $NPConfig{'UploadURL'}&lt;/b&gt;&lt;TABLE&gt;~; 

opendir (DIR, $NPConfig{'UploadDir'}); 

print qq~&lt;TR&gt;~; 
while ($filelist == 0) {

for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 

if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~
&lt;TD WIDTH="10%" valign="middle" align="center"&gt;
&lt;table width="100%" border="0" cellspacing="0" cellpadding="2"&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;IMG SRC="$NPConfig{'UploadURL'}/$file" ALT="$file" WIDTH="80"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt; 
&lt;input type="radio" name="FILE1" value="$file"&gt;Delete&lt;/font&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/TD&gt;
~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;

} 
closedir(DIR);

print qq~&lt;/TABLE&gt;
&lt;table width="100%" border="0" cellspacing="0" cellpadding="3"&gt;
&lt;tr&gt; 
&lt;td colspan="2"&gt; 
&lt;div align="center"&gt; 
&lt;input type="submit" value="DELETE SELECTED FILE" name="submit"&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
~;
&amp;NPHTMLFoot;
}


##################################################
# 
# Display the remote page
#  

sub npa_UploadList_Remote {

my $filelist = 0; 

&amp;NPHTMLHead("Picture List"); 

print qq~ &lt;TABLE&gt; ~; 

opendir (DIR, $NPConfig{'UploadDir'}); 


while ($filelist == 0) {
#print qq~ &lt;TR&gt; ~; 

for ($i = 0; $i &lt; 1; $i++) {
if (defined($file = readdir(DIR))) { 

if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TR&gt;&lt;TD WIDTH="12,5%"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;$file"&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt;~;
}
}
else {
$filelist = 1;
}
}
#print qq~ &lt;/TR&gt; ~;

} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;
~;
} 

##################################################
# 
# Display The Files

sub  npa_UploadList_Files{

if ($NPConfig{'UploadDir'}) {
my $filelist = 0; 
print qq~Listing For - &lt;b&gt;"$NPConfig{'UploadURL'}"&lt;/b&gt;&lt;TABLE&gt;~; 
opendir (DIR, $NPConfig{'UploadDir'}); 
print qq~&lt;TR&gt;~; 
while ($filelist == 0) {
for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 
if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TD WIDTH="10%" valign="middle" align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-2"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/TD&gt;~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;
} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;~;
} 

if ($NPConfig{'UploadDir2'}) {
my $filelist = 0; 
print qq~Listing For - &lt;b&gt;"$NPConfig{'UploadURL2'}"&lt;/b&gt;&lt;TABLE&gt;~; 
opendir (DIR, $NPConfig{'UploadDir2'}); 
print qq~&lt;TR&gt;~; 
while ($filelist == 0) {

for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 

if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TD WIDTH="10%" valign="middle" align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL2'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/TD&gt;~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;
} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;~;
}

if ($NPConfig{'UploadDir3'}) {
my $filelist = 0; 
print qq~Listing For - &lt;b&gt;"$NPConfig{'UploadURL3'}"&lt;/b&gt;&lt;TABLE&gt;~; 
opendir (DIR, $NPConfig{'UploadDir3'}); 
print qq~&lt;TR&gt;~; 
while ($filelist == 0) {

for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 

if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TD WIDTH="10%" valign="middle" align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL3'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/TD&gt;~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;
} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;~;
}

}
##################################################
# 
# Display The File Names

sub  npa_UploadList_FilesNames{

if ($NPConfig{'UploadDir'}) {
my $filelist = 0; 
print qq~&lt;TABLE&gt;~; 
opendir (DIR, $NPConfig{'UploadDir'}); 
print qq~&lt;TR&gt;~; 
while ($filelist == 0) {
for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 
if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TD WIDTH="10%" valign="middle" align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/TD&gt;~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;
} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;~;
} 

if ($NPConfig{'UploadDir2'}) {
my $filelist = 0; 
print qq~&lt;TABLE&gt;~; 
opendir (DIR, $NPConfig{'UploadDir2'}); 
print qq~&lt;TR&gt;~; 
while ($filelist == 0) {

for ($i = 0; $i &lt; 6; $i++) {
if (defined($file = readdir(DIR))) { 

if ( $file !~ /^\.\.?$/) { # Only if not a File handle "." and ".."
print qq~&lt;TD WIDTH="10%" valign="middle" align="center"&gt;&lt;a href="#" onClick="MM_openBrWindow('$NPConfig{'UploadURL2'}/$file','','scrollbars=yes,resizable=yes,width=$NPConfig{'RemoteWidth'},height=$NPConfig{'RemoteHeight'}')"&gt;&lt;font face="Geneva, Verdana, Helvetica" size="-3"&gt;$file&lt;/font&gt;&lt;/a&gt;&lt;/TD&gt;~;
}
}
else {
$filelist = 1;
}
}
print qq~&lt;/TR&gt;~;
} 
closedir(DIR);
print qq~ &lt;/TABLE&gt;~;
}

}

##################################################
# Uploaded File

sub npa_upload_succ {
&amp;NPHTMLHead("Files Uploaded");
print qq~ Your file(s) have now been uploaded, you should now be able to see them in the list below		
~;
&amp;npa_UploadList_FilesNames;
&amp;NPHTMLFoot;
}

##################################################
# Deleted File

sub npa_remove_succ {
&amp;NPHTMLHead("Files Deleted");
print qq~ The file have now been deleted.		
~;
&amp;npa_UploadList_FilesNames;
&amp;NPHTMLFoot;
}

##################################################
1;
</pre></body></html>