News:

Wondering if this will always be free?  See why free is better.

Main Menu

SMF Login on custom upload page (unsure how)

Started by Sacky, June 19, 2006, 08:53:15 PM

Previous topic - Next topic

Sacky

I have a data sheet that people can upload to, however i also have a forum, so id like to somehow read the cookie or make a user login before s/he can use it. Its not part of the SMF forum in any way, but its in the same database, ive tested the upload script and it works fine, but the problem is the authentication part.
Heres the upload script:

<title>Peergle - Upload</title>
<div align="center"><img src="/Peergle.jpg" width=276 height=110 alt="Google">
</div>
<form action="" name=f>
  <div align="center">
    <table border=0 cellspacing=0 cellpadding=4>
      <tr>
        <td nowrap align="center"><font size=-1> <font face="Arial, Helvetica, sans-serif"><a href="../index.html">Peergle</a>&nbsp;&nbsp;&nbsp;&nbsp; <a href="../forum/index.php">Forum</a>&nbsp;&nbsp;&nbsp;&nbsp; <u><font color="grey">Download Client</font></u>&nbsp;&nbsp;&nbsp;&nbsp;
          <!-- <a href="development.htm">Download Client</a>&nbsp;&nbsp;&nbsp;&nbsp; -->
          <strong>Upload</strong></font>
              <!-- <a href="development.htm">Development</a> -->
        </font> </td>
      </tr>
    </table>
    <div align="center">
      <table width="30%" cellpadding=0 cellspacing=0>
        <tr>
          <td width=15%>&nbsp;</td>
          <td width="64%" align=center><input type=hidden name=hl value=en>
          <input name="userfile2" type="file" id="userfile2">
        <br>        </td>
          <td valign=center nowrap width=21%><font size=-2>
            <label><br>
            </label>
            <!-- <a href=/preferences?hl=en>Preferences</a> -->
          </font> </td>
        </tr>
        <tr>
          <td height="82"></td>
          <td align="center"><label><strong><font size="-1" face="Arial, Helvetica, sans-serif">Description</font></strong><br>
                    <textarea name="textarea" id="description"></textarea>
                    </textarea>
          </label></td>
        </tr>
      </table> 
    </div>
    <p align="center">
      <input name="upload22" type="submit" class="box" id="upload22" value=" Upload ">
    </p>
  </div>
</form>
<?php
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName $_FILES['userfile']['name'];
$tmpName  $_FILES['userfile']['tmp_name'];
$fileSize $_FILES['userfile']['size'];
$fileType $_FILES['userfile']['type'];

$fp      fopen($tmpName'r');
$content fread($fpfilesize($tmpName));
$content addslashes($content);
fclose($fp);

if(!
get_magic_quotes_gpc())
{
    
$fileName addslashes($fileName);
}

include 
'../peergle/config.php';
include 
'../peergle/opendb.php';

$query "INSERT INTO upload (name, size, type, content ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$content')";

mysql_query($query) or die('Error, query failed');
include 
'../peergle/closedb.php';

echo 
"<br>File $fileName uploaded<br>";
}
?>


I was trying to find a solution and found something called a global like $COOKIE, but im not sure how that corresponds to SMF
I was going to make a small login script but the passwords are hashed, so im unsure of how to go about it...

Also how would i implement the description feature into the descriptions bit in mySQL, i understand how to make post go there but not text tables
Thanks for your time :)

Advertisement: