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

Reply
 
Thread Tools Display Modes
  #1  
Old 09-20-2008, 10:18 AM
neopets neopets is offline
 
Join Date: Jul 2008
Posts: 19
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Attachments With RSS postings

So I have a specific RSS feed that includes one image in each feed that I'd like to attach to the new thread being created.

In includes/cron/rssposeter.php

PHP Code:
            // insert item as thread
                
case 'thread':
                default:
                {
                    if(
$feed['special'] == 1){
                        
                                
$poststarttime TIMENOW;
                                
$posthash md5($poststarttime $feed['userid'] . $vbulletin->userinfo['salt']);
                                
$postinfo = array('posthash' => $posthash);
                                
$forumid $feed['forumid'];
                                
$foruminfo fetch_foruminfo($forumid);
                                
                                
$zimage file_get_contents($ximage[1][0]);
            
                                
$filenamez basename($ximage[1][0]);
                                
                                
$fp fopen('/tmp/'.$filenamez'w');
                                
fwrite($fp$zimage);
                                
fclose($fp);
                                
                                
$tmp_name '/tmp/'.$filenamez;
                                
$fsize filesize($tmp_name);
                                
                                require_once(
DIR '/includes/class_upload.php');
                            require_once(
DIR '/includes/class_image.php');
                                
                        
$attachdata =& datamanager_init('Attachment'$vbulletinERRTYPE_ARRAY);
                        
$upload =& new vB_Upload_Attachment($vbulletin);                        
                        
$image =& vB_Image::fetch_library($vbulletin);
                        
                        
$upload->data =& $attachdata;
                        
$upload->image =& $image;
                  
                        
                        
$upload->foruminfo =& $foruminfo;
                        
$upload->postinfo =& $postinfo;
                        
$attachment = array(
                            
'name'     =>& $filenamez,
                            
'tmp_name' =>& $tmp_name,
                            
'error'    =>&  $zok,
                            
'size'     =>& $fsize,
                        );
                        
                        if (
$attachmentid $upload->process_upload($attachment)) {
                            
$itemdata->set_info('attachmentid'$attachmentid);
                        }
                        else {
                            exit;
                        }
            
              }
                    
                    
// init thread/firstpost datamanager
                    
$itemdata =& datamanager_init('Thread_FirstPost'$vbulletin$error_type'threadpost');
                    
$itemdata->set_info('forum'fetch_foruminfo($feed['forumid']));
                    
$itemdata->set_info('user'$feed);
                    
$itemdata->set_info('is_automated''rss');
                    
$itemdata->set_info('chop_title'true);
                    
$itemdata->set('iconid'$feed['iconid']);
                    
$itemdata->set('sticky', ($feed['rssoptions'] & $vbulletin->bf_misc_feedoptions['stickthread'] ? 0));
                    
$itemdata->set('forumid'$feed['forumid']);
                    
$itemdata->set('prefixid'$feed['prefixid']);
                    
$itemdata->set('userid'$feed['userid']);
                    
$itemdata->set('title'strip_bbcode(convert_wysiwyg_html_to_bbcode($feed['xml']->parse_template($feed['titletemplate'], $item))));
                    
$itemdata->set('pagetext'$pagetext);
                    
$itemdata->set('visible', ($feed['rssoptions'] & $vbulletin->bf_misc_feedoptions['moderatethread'] ? 1));
                    
$itemdata->set('allowsmilie', ($feed['rssoptions'] & $vbulletin->bf_misc_feedoptions['allowsmilies']) ? 0);
                    
$itemdata->set('showsignature', ($feed['rssoptions'] & $vbulletin->bf_misc_feedoptions['showsignature']) ? 0);
                    
$itemdata->set('ipaddress''');
                    
$threadactiontime = (($feed['threadactiondelay'] > 0) ? (TIMENOW $feed['threadactiondelay']  * 3600) : 0);

                    if (
$itemid $itemdata->save())
                    {
                        
$itemtype 'thread';
                        
$itemtitle $itemdata->fetch_field('title');
                        
$itemlink "../showthread.php?t=$itemid";

                        if (
defined('IN_CONTROL_PANEL'))
                        {
                            echo 
"<li><a href=\"$itemlink\" target=\"feed\">$itemtitle</a></li>";
                        }

                        
$rsslog_insert_sql[] = "($item[rssfeedid]$itemid, '$itemtype', '" $vbulletin->db->escape_string($uniquehash) . "', '" $vbulletin->db->escape_string($item['contenthash']) . "', " TIMENOW ", $threadactiontime)";
                        
$cronlog_items["$item[rssfeedid]"][] = "\t<li>$vbphrase[$itemtype] <a href=\"$itemlink\" target=\"logview\"><em>$itemtitle</em></a></li>";
                    }
                    break;
                }
            } 

The part in
PHP Code:
if($feed['special'] == 1){ 
I know I'm getting the image and storing it properly. I'm not storing the attachment correctly.

I think it's because the code is meant for the image using $vbulletin->input->clean_gpc('f', 'attachment', TYPE_FILE);

But since I'm using an rss feed to create an image there is no $_FILE

Anyone know how I can fix this? It stops at the exit command. Means $upload->process_upload is not working
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 03:51 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05742 seconds
  • Memory Usage 2,305KB
  • 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
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete