Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2003, 06:28 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to add attachments from control panel?

I am trying to add something to the admin control panel to add attachments into the database without going through all the checks. This way (as I am the only admin), I can add attachments without having the checks etc, and no posts/threads.

What would be the code to add the file into the databse? I keep getting /var/tmp/xxxxxxxx kinda stuff and I know its not right.
Reply With Quote
  #2  
Old 05-17-2003, 07:04 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

NM, figured it out I think...

I edited attachments.php and renamed it to what I want to use to pull those attachments...

It works well with zip files but no so well with images...

It says downloading picture for around 1-2 mins...then halts...

This is whats inside the php file.

PHP Code:
<?php
error_reporting
(7);

$noheader=1;

require(
"./global.php");

$attachmentinfo=$DB_site->query_first("SELECT filename,filedata,dateline
                            FROM dwipfiles
                            WHERE filesid='
$filesid'");

if (
$noshutdownfunc) {
  
$DB_site->query("UPDATE dwipfiles SET counter=counter+1 WHERE filesid='$filesid'");
} else {
  
$shutdownqueries[]="UPDATE LOW_PRIORITY dwipfiles SET counter=counter+1 WHERE filesid='$filesid'";
}

header("Cache-control: max-age=31536000");
header("Expires: " gmdate("D, d M Y H:i:s",time()+31536000) . "GMT");
header("Last-Modified: " gmdate("D, d M Y H:i:s",$attachmentinfo[dateline]) . "GMT");
header("Content-disposition: inline; filename=$attachmentinfo[filename]");
header("Content-Length: ".strlen($attachmentinfo[filedata]));
$extension=strtolower(substr(strrchr($attachmentinfo[filename],"."),1));

if (
$extension=='gif') {
  
header('Content-type: image/gif');
} elseif (
$extension=='jpg' or $extension=='jpeg') {
  
header('Content-type: image/jpeg');
} elseif (
$extension=='png') {
  
header('Content-type: image/png');
} elseif (
$extension=='pdf') {
  
header('Content-type: application/pdf');
} else {
  
header('Content-type: unknown/unknown');
}
echo 
$attachmentinfo[filedata];

?>
Reply With Quote
  #3  
Old 05-17-2003, 07:11 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you get this figured out, I would be interested in trying it out.
Reply With Quote
  #4  
Old 05-17-2003, 08:10 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

shouldnt be too hard, just create an edited attachment.php and put a form in it to add a new attachment and create a post id for it when you do so, or add an aditional filed to attachments like adminattachid and then you could insert them that way i guess
Reply With Quote
  #5  
Old 05-17-2003, 08:18 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah I got it that far, it inserts it into the database...

But when you call from attachments.php like file (above)...

You can get the ZIP files, txt files BUT

On images, it just sits there saying Downloading picture.

It will never show the picture no matter how long I wait. unsure why. Is there soemthing special I have to do ?
Reply With Quote
  #6  
Old 05-17-2003, 08:20 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is what I have in the upload section for the attachment..

PHP Code:
  $filesize=@filesize($getfile);
  
$filenum fopen($getfile,"rb");
  
$filestuff fread($filenum,$filesize);
  
fclose($filenum);

  
$DB_site->query("INSERT INTO dwipfiles (filesid,title,userid,pagetext,dateline,groupid,filename,filedata) VALUES (NULL,'".addslashes($title)."','$bbuserinfo[userid]','".addslashes($pagetext)."','".time()."','".addslashes($groupid)."','".addslashes($attachment_name)."','".addslashes($filestuff)."')"); 
Like I said, only pictures are giving me problems so maybe I need to add something special for them?
Reply With Quote
  #7  
Old 05-17-2003, 08:20 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thats cause ur not inserting anything to filedata... have a wee looky at the attachments table and see whats needED
Reply With Quote
  #8  
Old 05-17-2003, 08:22 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Its getting added into filedata, or I wouldnt be able to get the zip files, txt files

Let me post whole thing
Reply With Quote
  #9  
Old 05-17-2003, 08:24 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// ###################### Start Upload #######################
if ($action=="uploadfile") {

  
doformheader("files","douploadfile",1);

  
maketableheader("Upload a New File");
  
makeuploadcode("File","getfile");

  
makechoosercode("File Group","groupid","filegroup",$files[groupid]);
  
makeinputcode("Name (optional)","title");

  
maketextareacode("File Text","pagetext","",25,120);

  
doformfooter("Upload Now");

}

// ###################### Start DoUpload #######################

// ###################### Start DoUpload #######################
if ($HTTP_POST_VARS['action']=="douploadfile") {

    
$getfile $HTTP_POST_FILES['getfile']['tmp_name'];

  
$attachment_name $HTTP_POST_FILES['getfile']['name'];

  
$HTTP_POST_VARS['action']="insertfile";
}

// ###################### Start Insert #######################
if ($HTTP_POST_VARS['action']=="insertfile") {

  
$filesize=@filesize($getfile);
  
$filenum fopen($getfile,"rb");
  
$filestuff fread($filenum,$filesize);
  
fclose($filenum);

  
$DB_site->query("INSERT INTO dwipfiles (filesid,title,userid,pagetext,dateline,groupid,filename,filedata) VALUES (NULL,'".addslashes($title)."','$bbuserinfo[userid]','".addslashes($pagetext)."','".time()."','".addslashes($groupid)."','".addslashes($attachment_name)."','".addslashes($filestuff)."')");

  
$action="modify";

  echo 
"<p>Record added</p>";


Like I said, it uploads it into the database, and I can call it out with attachment.php like page but images are either corrupt or missing a flag of some sort cause zip, txt files are fine.
Reply With Quote
  #10  
Old 05-17-2003, 08:27 PM
mADmAX` mADmAX` is offline
 
Join Date: Dec 2001
Posts: 93
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have also verified the filedata column and its there even though you cant understand the code =P
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:23 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05457 seconds
  • Memory Usage 2,290KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete