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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2011, 03:12 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default URGENT - [4.0.7 cms] insert and display attachments in CMS article

As i said before in another thread am working in a mirgation from joomla/fireboard to vBulletin CMS, and now an working in upload the old image attachments into the vBulletin database;
to import correctly sections, I previously added two fields to the cms_node tab,called oldjoomlaid and oldjoomlasec and use it as reference here.
I already revised twice my script but am having problems in display the image in the article; instead of the image it appears the link "ATTACHMENT XXXX"; do i forget to set any parameter anywhere?

Thanks for the help.

Saimon69

PHP Code:
<?php
   
/**
    * Associate Pics to Articles
    * this script should capture the pictures from the cms_article table 
    * (if contained as images in the pagetext field), pass it through GD,
    * upload it as BLOB and combine it again to the related vBulletin articles
    * hope this works ^^; 
    *
    * modification: since the original img tag has been filtered in the imported articles, 
    * now the data has to be taken from the original joomla database.
    *
    * @Package:        Migration
    * @Date:        01-04-2010 16:54:00 -0800
    *
    */
    
    //new: put a GET 'mode' value: if 0 or none = test, if 1 = real    

$mode $_GET['mode'];
if(!
$mode || $mode == ''){
$mode 0;
}
    
//=============================================================================
    
    //initialize variables
    
    
ini_set('max_execution_time'3000);

    require(
'includes/db_connection.php');

    
define('BASE_ATT_PATH','http://localhost/vbcms/');

//define all arrays and paths
    
$jarticles = array();
    
    
$vbarticles = array();
    
$vbattachedpics = array();
    
    
$vbattach 'temp/';
    
$vbattachthumb 'temp/';
    
    
$now time();
    
    print 
'actual time is: '.$now.'<br/>';
    
    
//configure the attachment type
$attachtypes = array(
                array(
'ext'=>'gif','mimetype'=>'Content-type: image/gif''maxW'=>620,'maxH'=>280,'maxsize'=>20000,'th'=>1),
                array(
'ext'=>'jpeg','mimetype'=>'Content-type: image/jpeg''maxW'=>620,'maxH'=>280,'maxsize'=>20000'th'=>1),
                array(
'ext'=>'jpg','mimetype'=>'Content-type: image/jpeg''maxW'=>620,'maxH'=>280,'maxsize'=>100000'th'=>1),
                array(
'ext'=>'jpe','mimetype'=>'Content-type: image/jpeg''maxW'=>620,'maxH'=>280,'maxsize'=>20000'th'=>1),
                array(
'ext'=>'png','mimetype'=>'Content-type: image/png''maxW'=>620,'maxH'=>280,'maxsize'=>20000'th'=>1),
                array(
'ext'=>'bmp','mimetype'=>'Content-type: image/bitmap''maxW'=>620,'maxH'=>280,'maxsize'=>20000'th'=>1),
                );
    
//==================================================================
// So in old site articles the images are not stored as attachments in the database
// but as linked files and inserted in the article body as HTML links;
// this script will retrieve the link, upload the picture in the DB and update the
// tables in the vbulletin database.
//
// new modifications: parse the old old site articles to retrieve the enclosed image from the text
// and parse the inserted 'oldjoomlaid' number in the vbulletin cms_node table, since the content
// have been filtered.
//===================================================================
    
connect_oldsite();

//tags to get the image
$filtermosimagetag "#<div class=\"mosimage\"( .*?)>(.*?)<\/div><\/div>#";
$filterimgtag="/src=\"(.*?)\"/";

$sql0 "SELECT id, introtext FROM jos_content";

$res0 mysql_query($sql0);

while(
$row0 mysql_fetch_object($res0)){

//i extract introtext here since i have to parse it for the image file
$itext $row0->introtext;

if(
preg_match($filtermosimagetag,$itext)){

print 
'<b>this one match!</b><br/>';

preg_match($filtermosimagetag,$itext,$retmosarr);

print 
'retmosarr:<br/>';
print_r($retmosarr);
print 
'<br/><br/>';

//the usual return pattern of preg_match of this regexp is the following:
//array(3) {
//  [0]=>  string(281) "<div class="mosimage"  style=" float: left;" align="center"><img src="images/rubriche/mechtrade.jpg" width="150" height="150" hspace="6" 
// alt="Sample image" title="Sample image" border="0" /></div>"
//  [1]=>  string(38) "  style=" float: left;" align="center""
//  [2]=>  string(209) "<img src="images/rubriche/mechtrade.jpg" width="150" height="150" hspace="6"
// alt="Sample image" title="Sample image" border="0" />"
//}
// corresponding to the capturing groups; will take the second element to regexp the image name - this might change however

$imgfiltered $retmosarr[2];

print 
'imgfiltered:'.$imgfiltered.'<br/>';

preg_match($filterimgtag,$imgfiltered,$retimgarr);

//the return pattern for this regexp is the following:
//array(2) {
//  [0]=>  string(35) "src="images/rubriche/posaobama.jpg""
//  [1]=>  string(29) "images/rubriche/posaobama.jpg"
//}
//will need the second capturing group and split it to retrieve image filename and extension


$imgnamefarray explode('/',$retimgarr[1]);

//the last element of imgnamefilteredarray is the image name

$imagename $imgnamefarray[(count($imgnamefarray))-1];

print 
'imgname is:'.$imagename.'<br/>';

array_push($jarticles,array(     'id'=>$row0->id,
    
'introtext' =>$itext,
    
'imgurl' => $retimgarr[1],
    
'imgname' => $imagename,
                                
));

//end if

}// end while
    

print 'jarticles contains '.count($jarticles).' elements<br/>';


//==================================================================
// part two - connect vbulletin DB and populate vbarticles
//==================================================================
//connect the database

    
connect_vbcms();

//query for articles and user id and salt

$sql "SELECT cms_node.nodeid, cms_node.userid, cms_node.contentid, cms_node.oldjoomlaid, cms_article.pagetext, user.salt
FROM cms_node, cms_article, user
WHERE cms_node.contentid = cms_article.contentid
AND cms_node.contenttypeid =18 AND cms_node.oldjoomlaid != 0 AND user.userid = cms_node.userid ORDER BY cms_node.nodeid"
//remove order by... limit 50 - is for tests !!!IMPORTANT

$res mysql_query($sql);

while(
$row mysql_fetch_object($res)){

array_push($vbarticles, array(    'nodeid'=>$row->nodeid,
    
'userid'=>$row->userid,
    
'salt'=> $row->salt,
    
'contentid'=>$row->contentid,
    
'pagetext'=>$row->pagetext,
    
'time'=>$now,
    
'imageurl'=>'',
    
'oldjoomlaid'=>$row->oldjoomlaid,
));
//end while

print 'vbarticles contains '.count($vbarticles).' filtered elements<br/>';

//==================================================================

//This is the cycle to align the two arrays in one


foreach($vbarticles as $i=>$value){
    foreach (
$jarticles as $j=>$value){
        if(
$vbarticles[$i]['oldjoomlaid'] == $jarticles[$j]['id']){
            
$vbarticles[$i]['imageurl'] = $jarticles[$j]['imgurl'];
        
        
        } 
//end if vbarticles
    
//end foreach jarticles
//end foreach vbarticles

//===================================================================
// foreach to process the images and update databases

foreach($vbarticles as $i=>$value){
if(
$vbarticles[$i]['imageurl']!=''){

print 
'i index = '.$i .'<br/>';
print 
'currentindex: '.$vbarticles[$i]['nodeid'].'<br/>';

    
$attachmentpathArray explode('/',$vbarticles[$i]['imageurl']);
    
$filename urlencode($attachmentpathArray[(count($attachmentpathArray)-1)]);
    
$loaderurl str_replace(' ',"%20",$vbarticles[$i]['imageurl']);
    
    
$fnnoext substr($filename,0,-4);
    
$fnext substr($filename,-3);
    
    
$retrievefile BASE_ATT_PATH $loaderurl;
    
    
//debug string
    
print'retrievefile: '.$retrievefile.'<br/>';
    
switch(
strtolower($fnext)){
    case 
'gif':
    
$file1 imagecreatefromgif($retrievefile);

    
$imgPar retrieveImgParams('gif',$attachtypes);
    break;
    
    case 
'jpeg':
    
$file1 imagecreatefromjpeg($retrievefile);
    
$imgPar retrieveImgParams('jpeg',$attachtypes);
    break;

    case 
'jpg':
    
$file1 imagecreatefromjpeg($retrievefile);
    
$imgPar retrieveImgParams('jpg',$attachtypes);
    break;

    case 
'jpe':
    
$file1 imagecreatefromjpeg($retrievefile);
    
$imgPar retrieveImgParams('jpe',$attachtypes);
    break;
    
    case 
'png':
    
$file1 imagecreatefrompng($retrievefile);
    
$imgPar retrieveImgParams('png',$attachtypes);
    break;

    case 
'bmp':
    
$file1 imagecreatefrombmp($retrievefile);
    
$imgPar retrieveImgParams('bmp',$attachtypes);
    break;
//end switch


print 'the file '.$retrievefile.' <u>is an image</u> (or so i think)<br/>';

    
$maxsizeW $imgPar['maxW'];
    
$maxsizeH $imgPar['maxH'];

    
$mimeType $imgPar['mimetype'];
    
$imgext $imgPar['ext'];
    
    
//determine sizes
    
$imgsize getimagesize($retrievefile);
    
$img1w $imgsize[0];
    
$img1h $imgsize[1];
    
$ratio round($img1w/$img1h,2);

    
//determine size for pic
    
$img1w = ($img1w >$maxsizeW ) ? $maxsizeW $img1w;
    
$img1h = ($img1h >$maxsizeH ) ? $maxsizeH $img1h;

    
//determine size for thumbnail
    
$img2w = ($img1w >100 ) ? 100 $img1w;
    
$img2h =  round($img2w/$ratio); //rounded width/ratio
    //create the pic
    
$attach imagecreatetruecolor($img1w,$img1h);
    
imagecopyresampled($attach,$file1,0,0,0,0,$img1w,$img1h,$img1w,$img1h); 

    
//create the thumbnail
    
$attachthumb imagecreatetruecolor($img2w,$img2h);
    
imagecopyresampled($attachthumb,$file1,0,0,0,0,$img2w,$img2h,$img1w,$img1h); 

    
ob_start();        

switch(
strtolower($imgext)){
    case 
'gif':
    
$imgrendered $vbattach.$fnnoext.'.'.$imgext;
    
imagegif($attach$imgrendered);
    break;
    
    case 
'jpeg':
    
$imgrendered $vbattach.$fnnoext.'.'.$imgext;
    
imagejpeg($attach,$imgrendered,80);
    break;
    
    case 
'jpg':
    
$imgrendered $vbattach.$fnnoext.'.'.$imgext;
    
imagejpeg($attach,$imgrendered,80);
    break;
    
    case 
'jpe':
    
$imgrendered $vbattach.$fnnoext.'.'.$imgext;
    
imagejpeg($attach,$imgrendered,80);
    break;
    
    case 
'png':
    
$imgrendered $vbattach.$fnnoext.'.'.$imgext;
    
imagepng($attach,$imgrendered);
    break;
    
    case 
'bmp':
    
$imgrendered $vbattach.$fnnoext.'.png';
    
//store it as png since bmp support in GD is non existent
    
imagepng($attach,$imgrendered);
    break;
    

//end switch $ext
    
ob_end_clean();

ob_start();        

        
//all thumbnails are stored as png
        
$thumbrendered $vbattachthumb.$fnnoext."_thu.png";
        
imagepng($attachthumb,$thumbrendered);

ob_end_clean();


//=============================================================================
// process the file        
            
// start with storing the pic in the filedata table        

$myattach addslashes(file_get_contents($imgrendered));
$myattachfilesize filesize($imgrendered);
$myattachhash md5_file($imgrendered);

    
$myattachthumb addslashes(file_get_contents($thumbrendered));
    
$myattachthumbfilesize filesize($thumbrendered);

        
//prepare the mysql query for filedata

//new: since have the problem that same attachment can be added to the post more times, will
//check that the same file is not already present

$sql11 "INSERT INTO filedata    (    filedataid,
        userid,
        dateline,
        thumbnail_dateline,
        filedata,
        filesize,
        filehash,
        thumbnail,
        thumbnail_filesize,
        extension,
        refcount,
        width,
        height,
        thumbnail_width,
        thumbnail_height

    ) VALUES (
        NULL,
        "
.$vbarticles[$i]['userid'].",
        "
.$now.",
        "
.$now.",
        '"
.$myattach."',
        "
.$myattachfilesize.",
        '"
.$myattachhash."',
        '"
.$myattachthumb."',
        "
.$myattachthumbfilesize.",
        '"
.$imgext."',
        1,
        "
.$img1w.",
        "
.$img1h.",
        "
.$img2w.",
        "
.$img2h."
    )"
;


//dummy query to display what is going on                                    
$sql11b "INSERT INTO filedata    (    filedataid,
    userid,
    dateline,
    thumbnail_dateline,
    filedata,
    filesize,
    filehash,
    thumbnail,
    thumbnail_filesize,
    extension,
    refcount,
    width,
    height,
    thumbnail_width,
    thumbnail_height

) VALUES (
    NULL,
    "
.$vbarticles[$i]['userid'].",
    "
.$now.",
    "
.$now.",
    '[attachbinary]',
    "
.$myattachfilesize.",
    '"
.$myattachhash."',
    '[thumbbinary]',
    "
.$myattachthumbfilesize.",
    '"
.$imgext."',
    1,
    "
.$img1w.",
    "
.$img1h.",
    "
.$img2w.",
    "
.$img2h."

)"
;

@
fclose($imgrendered); 
@
fclose($thumbrendered); 

    
    print 
'sql11 ='.$sql11b.'<br/>';    
if(
$mode == '1'){
    print 
'real insert<br/>';
    
$res11 mysql_query($sql11) or die('Invalid query: ' mysql_error());
    }
        
 
$filedataindex =     mysql_insert_id();
    
printf("Records inserted: %d\n"mysql_affected_rows());
        
    

 print 
'filedataindex = '.$filedataindex.'<br/>';
    
sleep(1);
    
//sql query for table attachment
//retrieve if there are already records linked to that post
//build the settings field
//========================================================================================
// the settings field is made like this:
//    a:7:{
//    s:9:"alignment";s:4:"left";
//    s:4:"size"; s:8:"fullsize";
//    s:7:"caption"; s:0:"";
//    s:7:"linkurl"; s:0:"";
//    s:6:"styles"; s:0:"";
//    s:11:"description"; s:0:"";
//    s:5:"title"; s:14:"currencypuzzle";
//    }
// is a serialized array
//========================================================================================

$attachsetting = array('alignment' => 'left',
    
'size' => 'fullsize',    
    
'caption' => '',    
    
'linkurl' => '',    
    
'styles' => '',    
    
'description' => '',    
    
'title' => '',        
);
    
    
//define posthash
// in the vbulletin code, the posthash is calcolated as following:
// $posthash = md5(TIMENOW . $vbulletin->userinfo['userid'] . $vbulletin->userinfo['salt']);

$myposthash md5($now.$vbarticles[$i]['userid'].$vbarticles[$i]['salt']);    
    
$sql12 "INSERT INTO attachment (    attachmentid,
    contenttypeid,
    contentid,
    userid,
    dateline,
    filedataid,
    state,
    counter,
    posthash,
    filename,
    caption,
    reportthreadid,
    settings,
    displayorder,
    importattachmentid
    
    ) VALUES (
    NULL,
    18,
    "
.$vbarticles[$i]['contentid'].",
    "
.$vbarticles[$i]['userid'].",
    "
.$now.",
    "
.$filedataindex.",
    'visible',
    0,
    '"
.$myposthash."',
    '"
.$fnnoext.'.'.$imgext."',
    NULL,
    0,
    '"
serialize($attachsetting) ."',
    0,
    0

    )"
;
                                        
    print 
'sql12 ='.$sql12.'<br/>';    
if(
$mode == '1'){
        print 
'real insert<br/>';    
        
$res12 mysql_query($sql12) or die('Invalid query: ' mysql_error());
        }
        
    
$attachmentid mysql_insert_id();
        
printf("Records inserted: %d\n"mysql_affected_rows());


print
'attachmentid is: '.$attachmentid.'<br/>';    
//    sql query for attachmentcategoryuser
    
$sql13 "INSERT INTO attachmentcategoryuser (    filedataid,
    userid,
    categoryid,
    filename,
    dateline
    )    VALUES (
    "
.$filedataindex.",
    "
.$vbarticles[$i]['userid'].",
    0,
    '"
.$fnnoext.'.'.$imgext."',
    "
.$now."
    )"
;
    
    print 
'sql13 ='.$sql13.'<br/>';    
    if(
$mode == '1'){
    print 
'real insert<br/>';
    
$res13 mysql_query($sql13) or die('Invalid query: ' mysql_error());
    }
    
    
printf("Records inserted: %d\n"mysql_affected_rows());
        
        
//and at last fix the article table adding there is an attach
//first get the content of the pagetext
//need to insert the BBCODE [ATTACH]attachnumber[/ATTACH]
    
$removeimgtag "#\[ATTACH=CONFIG\](.*?)\[\/ATTACH\]#"//regEx for remove img

$newcontent preg_replace($removeimgtag,' ',$vbarticles[$i]['pagetext']);
$newcontent str_replace(chr(39),'&rsquo;',$newcontent);

$newcontentpage '[ATTACH=CONFIG]'.$attachmentid.'[/ATTACH]'.chr(13).chr(10).$newcontent;
print 
'newcontent = '.$newcontentpage.'<br/>';
    
//    print 'pagetext = '.$pagetext.'<br/>';
//$pw = 'http://192.168.1.112/vbcms/';
    
$pw '';
    
$attachlink $pw.'attachment.php?attachmentid='.$attachmentid.'&cid=18';
    
    
//TODO: make the query that modifies article    

    
$sql14 "UPDATE cms_article SET previewimage = '".$attachlink."',imagewidth = ".$img2w.", imageheight= ".$img2h.", pagetext = '".$newcontentpage."', previewtext = '".$newcontentpage."' WHERE contentid = ".$vbarticles[$i]['contentid']." ";

    
$sql14b "UPDATE cms_article SET previewimage = '".$attachlink."',imagewidth = ".$img2w.", imageheight= ".$img2h.", pagetext = '[text]', previewtext = '[text]' WHERE contentid = ".$vbarticles[$i]['contentid']." ";
    
    print 
'sql14 ='.$sql14b.'<br/>';    
    
    if(
$mode == '1'){
        print 
'real insert<br/>';
        
$res14 mysql_query($sql14) or die('Invalid query: ' mysql_error());
        
printf("Records inserted: %d\n"mysql_affected_rows());
    }
    
    if(
$querycnt<50){
    
$querycnt++;
    } else {
    print 
'sleep<br/>';
//    sleep(5);
    
$querycnt 0;
    }

            
//end if vbarticles
//end foreach


//=============================================================================
//imagecreatefrombmp function from php.net since GD does not support bmp directly

function imagecreatefrombmp($p_sFile){
    
//    Load the image into a string
    
$file    =    fopen($p_sFile,"rb");
    
$read    =    fread($file,10);
    while(!
feof($file)&&($read<>""))
        
$read    .=    fread($file,1024);
   
    
$temp    =    unpack("H*",$read);
    
$hex    =    $temp[1];
    
$header    =    substr($hex,0,108);
   
    
//    Process the header
    //    Structure: http://www.fastgraph.com/help/bmp_header_format.html
    
if (substr($header,0,4)=="424d")
    {
        
//    Cut it in parts of 2 bytes
        
$header_parts    =    str_split($header,2);
       
        
//    Get the width        4 bytes
        
$width            =    hexdec($header_parts[19].$header_parts[18]);
       
        
//    Get the height        4 bytes
        
$height            =    hexdec($header_parts[23].$header_parts[22]);
       
        
//    Unset the header params
        
unset($header_parts);
    }
   
    
//    Define starting X and Y
    
$x                =    0;
    
$y                =    1;
   
    
//    Create newimage
    
$image            =    imagecreatetruecolor($width,$height);
   
    
//    Grab the body from the image
    
$body            =    substr($hex,108);

    
//    Calculate if padding at the end-line is needed
    //    Divided by two to keep overview.
    //    1 byte = 2 HEX-chars
    
$body_size        =    (strlen($body)/2);
    
$header_size    =    ($width*$height);

    
//    Use end-line padding? Only when needed
    
$usePadding        =    ($body_size>($header_size*3)+4);
   
    
//    Using a for-loop with index-calculation instaid of str_split to avoid large memory consumption
    //    Calculate the next DWORD-position in the body
    
for ($i=0;$i<$body_size;$i+=3)
    {
    
//    Calculate line-ending and padding
    
if ($x>=$width)
    {
    
//    If padding needed, ignore image-padding
    //    Shift i to the ending of the current 32-bit-block
    
if ($usePadding)
        
$i    +=    $width%4;
   
    
//    Reset horizontal position
    
$x    =    0;
   
    
//    Raise the height-position (bottom-up)
    
$y++;
   
    
//    Reached the image-height? Break the for-loop
    
if ($y>$height)
        break;
    }
   
    
//    Calculation of the RGB-pixel (defined as BGR in image-data)
    //    Define $i_pos as absolute position in the body
    
$i_pos    =    $i*2;
    
$r        =    hexdec($body[$i_pos+4].$body[$i_pos+5]);
    
$g        =    hexdec($body[$i_pos+2].$body[$i_pos+3]);
    
$b        =    hexdec($body[$i_pos].$body[$i_pos+1]);
   
    
//    Calculate and draw the pixel
    
$color    =    imagecolorallocate($image,$r,$g,$b);
    
imagesetpixel($image,$x,$height-$y,$color);
   
    
//    Raise the horizontal position
    
$x++;
    }
   
    
//    Unset the body / free the memory
    
unset($body);
   
    
//    Return image-object
    
return $image;
//end function 
    
//=============================================================================
//function that parse the attachtypes array and return the values for the file format


function retrieveImgParams($type,$attachtypes){

//    global $attacthypes;

//    print_r($attachtypes);

print 'type = '.$type.'<br/>';

foreach (
$attachtypes as $i=>$value){
if(
$attachtypes[$i]['ext'] == $type){

return array(    
'ext'=> $attachtypes[$i]['ext'],
    
'mimetype'=> $attachtypes[$i]['mimetype'],
    
'maxW'=> $attachtypes[$i]['maxW'],
    
'maxH'=> $attachtypes[$i]['maxH'],
    
'maxsize'=> $attachtypes[$i]['maxsize'],
    
'th'=> $attachtypes[$i]['th'],
    );
//end if
}//end foreach
//end function

?>
Reply With Quote
  #2  
Old 01-14-2011, 02:40 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

:bump: anyone can tell me how to fix it?
Reply With Quote
  #3  
Old 01-14-2011, 04:12 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Check vbulletin cms > permissions and make sure the usergroup has Can Download Attachment checked.
Reply With Quote
  #4  
Old 01-14-2011, 05:15 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Am doing my test with the Admin user, i suppose that one should have the permission but will double check; however am talking about the inline images in the CMS posts; sometimes i wonder if i am uploading in the right format or need in example to base64_encode the picture and the thumbnail (not doing it now AFAICR)
Reply With Quote
  #5  
Old 01-18-2011, 10:43 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Check vbulletin cms > permissions and make sure the usergroup has Can Download Attachment checked.
I did the double check and set up download attachments for unregistered users and users awaiting confirmation/moderation; in the article same thing, in the section list view some of the articles show the thumbnail; wonder if i am doing something wrong in the way i save the images in the DB... in example do the pictures need to be base64 encoded?

--------------- Added [DATE]1295400699[/DATE] at [TIME]1295400699[/TIME] ---------------

Just did a test, the attachment seems not to be encoded on base64; any further ideas?

- permissions: check
- base64: check
some unknown to me flag?

Saimon69

--------------- Added [DATE]1295401759[/DATE] at [TIME]1295401759[/TIME] ---------------

Further update: it is me to insert the tag [ ATTACH= CONF1G ] num [/ATTACH ] (deliberately misspelled here) in the text; i know that but i wonder if i am using the right parameters to make the pic showing inline in the article.

--------------- Added [DATE]1295466596[/DATE] at [TIME]1295466596[/TIME] ---------------

Today's update: i checked the permissions for the usergroups and put can download attachment in all of those, to no avail; furthermore the problem is that now the imported pics thumbnails appears correctly in the list view of the section but inside the article they do not appear as such, just the ATTACH (num) link - if i edit the article i see the pic correctly in the editing field, and if i try to set position and alignment and then save, the pic is appearing correctly in the article; so at this point i wonder what is the parameter that I need to set somewhere in the DB to make the inline pictures being treated as such....

Saimon69
Reply With Quote
  #6  
Old 01-19-2011, 11:08 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Further update: i wonder if headers have something to do with this....
Reply With Quote
  #7  
Old 01-20-2011, 03:46 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Something else to look for... a link is shown if there is no thumbnail image to show. Are thumbnails getting created?
Reply With Quote
  #8  
Old 01-20-2011, 02:47 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@lynne
good question, this is the part that takes care of the thumbnail rendering:

PHP Code:

                
//determine size for thumbnail
                
$img2w = ($img1w >100 ) ? 100 $img1w;
                
$img2h =  round($img2w/$ratio); //rounded width/ratio

    //create the thumbnail
                
$attachthumb imagecreatetruecolor($img2w,$img2h);
                
imagecopyresampled($attachthumb,$file1,0,0,0,0,$img2w,$img2h,$img1w,$img1h); 

        
ob_start();        
        
                
//all thumbnails are stored as png
                
$thumbrendered $vbattachthumb.$fnnoext."_thu.png";
                
imagepng($attachthumb,$thumbrendered);

        
ob_end_clean(); 
I create the thumbnails as PNG files, same thing worked for creating the avatar pics in another script; instead for thumbnails in the forum attachments I rendered them in jpeg; should i pass to jpeg instead?

Saimon69

--------------- Added [DATE]1295545471[/DATE] at [TIME]1295545471[/TIME] ---------------

BTW, i tried to generate thumbs as jpeg and same results; the problem is with the full online image; is generated too but does not appear in the post.
Reply With Quote
  #9  
Old 01-20-2011, 04:06 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a reason you don't use the vb code to do this? Check out the function fetch_thumbnail in class_image.php and class_upload.php has the code vb uses for uploading the images. vBulletin doesn't store thumbnails as name_thu.png, they are stored as xxxx.thumb
Reply With Quote
  #10  
Old 01-20-2011, 04:18 PM
saimon69 saimon69 is offline
 
Join Date: Jun 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well the main reason is that i dont understand too well vb datamanager and internals yet and have little OOP experience, so i have to go on with what i have and plus time is getting tight; will try to fix the script and see what is happening

--------------- Added [DATE]1295547599[/DATE] at [TIME]1295547599[/TIME] ---------------

btw xxxx is the thumbnail id? comes from attachment id or from filedata id? plus are those functions used also in the CMS?

--------------- Added [DATE]1295549158[/DATE] at [TIME]1295549158[/TIME] ---------------

that count because means that i have to upload the pic first and keep thumbnails data empty, then insert the thumbnail data AFTER an id for either filedataid or attachmentid is created and therefore modify my importer according to which id i have to use - or maybe i misunderstood and xxxx is the filename?
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 08:46 AM.


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.05553 seconds
  • Memory Usage 2,485KB
  • 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
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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