help me to code this... (post with file)

Started on the old forum in November 2009 · view the original in the archive · old links redirect here

14 replies · 755 views · started 17 years ago · 3 min read

4 participants
rap-4ever Developer · 180 posts #1

this is in genproc.php

else if($action=="post3") { $uid = getuid_sid($sid); $descript = $_POST["descript"]; $tid = $_POST["tid"]; $tfid = mysql_fetch_array(mysql_query("SELECT fid FROM ibwf_topics WHERE id='".$tid."'"));

if(!canaccess(getuid_sid($sid), $tfid[0])) { echo xhtmlheadnotheme("$sitetitle"); echo " "; echo "You Don't Have A Permission To View The Contents Of This Forum

"; echo "<a href="index.php?action=main">Home</a>"; echo " "; echo xhtmlfoot(); exit(); }

$reptxt = $_POST["reptxt"]; $qut = $_POST["qut"];

addonline(getuid_sid($sid),"Posted a Reply - xHTML:v3",""); echo "<head>\n"; echo "<title>$sitetitle</title>\n"; echo "<link rel="stylesheet" type="text/css" href="themes/$theme[0]">"; echo "<meta http-equiv="Cache-Control" content="must-revalidate" />\n"; echo "<meta http-equiv="Cache-Control" content="no-cache" />\n"; echo "<meta http-equiv="Pragma" content="no-cache" />\n"; echo "</head>"; echo "<body>"; echo "<table border="0" cellspacing="0" cellpadding="0" height="60" width="159">"; echo "<tr>"; echo "<td id="body" width="159">"; echo "</td>"; echo "</tr>"; echo "</table>";

echo "<table border="0" width="99%" cellspacing="0" cellpadding="0" class="boxed" align="center">"; echo "<tr>"; echo "<td class="boxedTitle" height="20">"; echo "<h1 align="center" class="boxedTitleText">posted reply</h1></td>"; echo "</tr>"; echo " "; $crdate = time(); $fid = getfid($tid);

  $res = false;
  $closed = mysql_fetch_array(mysql_query("SELECT closed FROM ibwf_topics WHERE id='".$tid."'"));

  if(($closed[0]!='1')||(ismod($uid)))
  {

    $lpost = mysql_fetch_array(mysql_query("SELECT dtpost FROM ibwf_posts WHERE uid='".$uid."' ORDER BY dtpost DESC LIMIT 1"));
    global $post_af;
    $antiflood = time()-$lpost[0];
    if($antiflood>$post_af)
            {
        if(trim($reptxt)!="")
  {
  $res = mysql_query("INSERT INTO ibwf_posts SET text='".$reptxt."', tid='".$tid."', uid='".$uid."', dtpost='".$crdate."', quote='".$qut."'");
      }
  if($res)
  {
    $usts = mysql_fetch_array(mysql_query("SELECT posts, plusses FROM ibwf_users WHERE id='".$uid."'"));
    $ups = $usts[0]+1;
    $upl = $usts[1]+10;
    mysql_query("UPDATE ibwf_users SET posts='".$ups."', plusses='".$upl."' WHERE id='".$uid."'");
    mysql_query("UPDATE ibwf_topics SET lastpost='".$crdate."' WHERE id='".$tid."'");
    echo "<img src=\"images/ok.gif\" alt=\"O\"/>Message Posted Successfully";
    echo "

<a href="index.php?action=viewtpc&tid=$tid&go=last">"; echo "View Topic</a>"; }else{ echo "<img src="images/notok.gif" alt="X"/>Error Posting Message"; } }else{ $af = $post_af -$antiflood; echo "<img src="images/notok.gif" alt="X"/>Antiflood Control: $af"; } }else{ echo "<img src="images/notok.gif" alt="X"/>Topic is closed for posting"; }

$size = $_FILES['attach']['size']/1024; $origname = $_FILES['attach']['name']; $ext = explode(".", strrev($origname)); switch(strtolower($ext[0])){ case "dim": $res = true; break; case "3pm": $res = true; break; case "mr": $res = true; break; case "fdp": $res = true; break; case "4pm": $res = true; break; case "iva": $res = true; break; case "rma": $res = true; break; case "vaw": $res = true; break; case "gpj": $res = true; break; case "gnp": $res = true; break; case "pmb": $res = true; break; case "fig": $res = true; break; case "pg3": $res = true; break; case "piz": $res = true; break; case "rar": $res = true; break; case "sis": $res = true; break; case "raj": $res = true; break; case "exe": $res = true; break; case "gepj": $res = true; break; } $tm = time(); $uploaddir = $mmsdir; //can be configured in config.php $who = getuid_nick($pmtou); echo " "; if($size>8048){ echo "File is larger than 8MB";

} else if ($res!=true){

    echo "File type not supported! Please attach only a JPG or JPEG or GIF or BMP or PNG or 3GP or MID or WAV or MP3 or MP4 or AVI or AMR or SIS or EXE or ZIP or JAR or RAR or PDF file";

} $tid = $_POST["tid"]; $name = mysql_fetch_array(mysql_query("SELECT (MAX(id)+1) FROM files")); $uploadfile = $name[0].".".strrev($ext[0]); move_uploaded_file($_FILES['attach']['tmp_name'], "$uploaddir/$uploadfile"); $ext=strrev($ext[0]); $res1 = mysql_query("INSERT INTO files SET uid='".$uid."', origname='".$origname."', filename='".$uploadfile."', size='$size', extension='".$ext."'");

if($res1){ echo "Poruka je poslata.."; } else { echo "Ne mozete upisati post..."; } echo " ";

echo " ";

echo "<a href="index.php?action=main"><img src="images/home.gif" alt="*"/>"; echo "Home</a>"; echo " ";

echo xhtmlfoot(); }

this is in index.php

echo "<form enctype="multipart/form-data" action="genproc.php?action=post3" method="post">"; echo "Tekst:<input name="reptxt" value="" maxlength="500"/> "; echo "<input type="hidden" name="tid" value="$tid"/>";

File: "; echo "<input id="inputText" type="file" name="attach"/> "; echo "<input id="inputButton" type="submit" name="submit" value="Send"/>"; echo "</form>";

and this is tables. CREATE TABLE IF NOT EXISTS files ( id int( 11 ) NOT NULL AUTO_INCREMENT , filename varchar( 15 ) NOT NULL default '', extension varchar( 5 ) NOT NULL default '', size int( 11 ) NOT NULL default '0', origname varchar( 50 ) NOT NULL default '', PRIMARY KEY ( id ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =268;

but i don't know how to show this in index.php?action=viewtpc ... pls help .😊

something else Fellow · 2,296 posts #2

just add that code onto viewtpc

echo "<center><form enctype=\"multipart/form-data\" action=\"genproc.php?action=post3\" method=\"post\">";
echo "Tekst:<input name=\"reptxt\" value=\"\" maxlength=\"500\"/><br/>";
echo "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
<br/><br/>File:<br/>";
echo "<input id=\"inputText\" type=\"file\" name=\"attach\"/><br/>";
echo "<input id=\"inputButton\" type=\"submit\" name=\"submit\" value=\"Send\"/>";
echo "</form></center>";

where ever u want it to show

rap-4ever Developer · 180 posts #3

something else wrote: just add that code onto viewtpc

echo "<center><form enctype=\"multipart/form-data\" action=\"genproc.php?action=post3\" method=\"post\">";
echo "Tekst:<input name=\"reptxt\" value=\"\" maxlength=\"500\"/><br/>";
echo "<input type=\"hidden\" name=\"tid\" value=\"$tid\"/>";
<br/><br/>File:<br/>";
echo "<input id=\"inputText\" type=\"file\" name=\"attach\"/><br/>";
echo "<input id=\"inputButton\" type=\"submit\" name=\"submit\" value=\"Send\"/>";
echo "</form></center>";

where ever u want it to show

lol...not that ....i want to show file which is uploded in folder,in user's posts (index.php?action=viewtpc) 😕

something else Fellow · 2,296 posts #4

there is no update of topic number here: $res1 = mysql_query("INSERT INTO files SET uid='".$uid."', origname='".$origname."', filename='".$uploadfile."', size='$size', extension='".$ext."'");

so how your going to request it in a topic or post ... i dont know 🙂

rap-4ever Developer · 180 posts #5

something else wrote: there is no update of topic number here: $res1 = mysql_query("INSERT INTO files SET uid='".$uid."', origname='".$origname."', filename='".$uploadfile."', size='$size', extension='".$ext."'");

so how your going to request it in a topic or post ... i dont know :)

i need function post id.... like this: $info = mysql_fetch_array(mysql_query("SELECT filename, size, extension, origname FROM files WHERE id='".$fileid."'"));

$fileid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_posts"));

echo "$usl: $fli$pst $topt $info[4]";

something else Fellow · 2,296 posts #6

yep i guess u could do it like that aslong as your sql field id is set to auto-increasement 🙂

i would probably use a diifernt field like post_id or pid in files 🙂

something else Fellow · 2,296 posts #8

pid will be post id number 🙂 .... without it how u going to know which post it belongs to 🙂

so will need to add pid to your sql also 🙂

WhiteWarrior Principal · 1,419 posts #10

rap-4ever wrote: where i need add pid field? in ibwf_posts or files ?

Think about it... a little thinking gets you along way.! hes told you everything you need to know, you just got to work out how/where it all goes 😉

its not hard..

rap-4ever Developer · 180 posts #11

i make filed pid,but i don`t know how to do this.... i think why i don't use this : add fields:

fileid int( 11 ) NOT NULL default '', filename varchar( 15 ) NOT NULL default '', extension varchar( 5 ) NOT NULL default '', size int( 11 ) NOT NULL default '0', origname varchar( 50 ) NOT NULL default '',

in ibwf_post and edit genproc.php

or just edit auto-increasement 267 to 1 😀

subzero Super moderator Fellow · 3,954 posts #13

WhiteWarrior wrote: Think about it... a little thinking gets you along way.! hes told you everything you need to know, you just got to work out how/where it all goes 😉

its not hard..

lol I like ya avatar lol worry now lol

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

rap-4ever Developer · 180 posts #15

i try to use this,but not working.... i don't know to create this...

$fileid = mysql_fetch_array(mysql_query("SELECT id FROM ibwf_posts")); $ikkk = mysql_fetch_array(mysql_query("SELECT id FROM files")); $info = mysql_fetch_array(mysql_query("SELECT filename, size, extension, origname FROM files")); $tpk = mysql_fetch_array(mysql_query("SELECT tid FROM files"));
$tpg = mysql_fetch_array(mysql_query("SELECT tid FROM ibwf_posts"));

if($fileid=$ikkk && $tpk=$tpg[2]){

echo "$usl: $fli$pst $topt $info[3]";

$dtot = date("d-m-y - H:i:s",$post[3]);

echo $dtot;

echo "

"; }else{ } }

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close