View Single Post
  #4  
Old 11-12-2010, 06:41 AM
B16MCC B16MCC is offline
 
Join Date: Feb 2002
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Outbackmark, thanks for the link , I am actually already that mod but it's far too advanced for this simple task I want to offer my moderators.

OK Lynne, here's what I've got so far.

Here's the custom template I've made that's linked to a navbar tab.
HTML Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle}</title>
    {vb:raw headinclude}
  </head>
  <body>
    
    {vb:raw header}
    
    {vb:raw navbar}
   
    <h2 class="blockhead">Services Database Upload</h2>
    <div class="blockbody">
      <div class="blockrow">

<center>
<br></br>
Welcome Moderators, to the Services Database update page.
<br></br>
Download The Database <a href="http://www.xxxxxxxxxx.com/spreadsheet.xlsm">Here.</a> 
<br></br>
<br></br>
When you have finished updating the spreadsheet please upload it using the form below.
<br></br>
<br></br>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">spreadsheet.xlsm : </label>
<input type="file" name="file" id="file" />
<br />
<br></br>
<input type="submit" name="submit" value="Submit" />
</form>
</center>
      </div>
    </div>
    {vb:raw footer}
  </body>
</html>

That's my simple upload form and here's the associated php script that it runs.

PHP Code:
<?php
if ($_FILES["file"]["size"] < 4194304)
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " . ($_FILES["file"]["size"] / 4096) . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";

    if (
file_exists("upload/" $_FILES["file"]["name"]))
      {
      echo 
$_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"uploads/" $_FILES["file"]["name"]);
      echo 
"Stored in: " "uploads/" $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo 
"Invalid file";
  }
?>
OK , yes its very basic but it works, I'm not a web coder. I'm happy , for now, with the template HTML code but I need a little help with the PHP if possible please.

Firstly, when it checks to see if the file exists, I simply want to over rite it, if it does exist.

Secondly, when the uploaded file is moved to the Uploads folder, I want to change this to a location outside of my forum root folder if possible.

A bonus would be a check to see if the file is the correct name which is 'services_db.xlsm'

A second bonus would be to check if the user is a member of the allowed user groups and deny access to the page if they are not. Although the navbar tab is hidden from certain user groups the page could still be addressed directly and so a user group check would make it more secure.

I'm sure what seem to me like huge hurdles in this simple page are very easily over come with a little expert help. Any help would be greatly appreciated and if a donation to a coder for example, would help then of course I'd be happy to do so.
Many thanks.
B16MCC
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01179 seconds
  • Memory Usage 1,798KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete