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

Reply
 
Thread Tools Display Modes
  #1  
Old 01-23-2005, 10:02 AM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default WYSIWYG - What is needed to make it work?

Hello,

I try to combine the WYSIWYG and vBGarage..

Here's what I already have but that doesn't work..

The editors shows up and everything but whatever I enter it doesn't get saved

It does work, however, if I choose vB's basic editor.


Can you help me out, please?
PHP Code:
 /*======================================================================*\
 || #################################################################### ||
 || # vBGarage v3.1.1                              # ||
 || # ---------------------------------------------------------------- # ||
 || # Copyright ?2000?2004 magnus. All Rights Reserved.                # ||
 || # https://vborg.vbsupport.ru/showthread.php?t=63681          # ||
 || #################################################################### ||
 \*======================================================================*/
 // Updated by: noppid @ www.lakecs.com
 // This is not official or for distrubtion.
 // added length limit to text field
 // added striping of html and php code from user text input fields
 // strip tags code from php.net and vBulletin
 
 // ####################### SET PHP ENVIRONMENT ###########################
 error_reporting(E_ALL & ~E_NOTICE);
 
 // #################### DEFINE IMPORTANT CONSTANTS #######################
 define('NO_REGISTER_GLOBALS', 1);
 define('THIS_SCRIPT', 'vbgarage');
 
 // ################### PRE-CACHE TEMPLATES AND DATA ######################
 // get special phrase groups
 $phrasegroups = array(
     'user',
     'cpglobal',
     'posting'
 );
 
 // get special data templates from the datastore
 $specialtemplates = array(
     'smiliecache',
     'bbcodecache'
 );
 
 // pre-cache templates used by all actions
 $globaltemplates = array(
     'vbgarage_editgarage',
     'vbgarage_editimagebits',
     'vbgarage_imagebits',
     'vbgarage_listbits',
     'vbgarage_listgarage',
     'vbgarage_popup',
     'vbgarage_viewgarage'    
 );
 
 // pre-cache templates used by specific actions
 $actiontemplates = array();
 
 // ######################### REQUIRE BACK-END ############################
 require_once('./global.php');
 require_once('./includes/functions_bbcodeparse.php');
 require_once('./includes/functions_user.php');
 require_once('./includes/adminfunctions.php');
 require_once('./includes/functions_editor.php');
 require_once('./includes/functions_bigthree.php');
 // #######################################################################
 // ######################## START MAIN SCRIPT ############################
 // #######################################################################
 
 if (!$vboptions[vbgenable] AND !can_administer())
 {
     print_no_permission();
 }
 
 if (empty($_REQUEST['do']))
 {
     $_REQUEST['do'] = 'list';
 }
 
 $textareacols = fetch_textarea_width();
 
 // ############################################################################
 // ############################### EDIT GARAGE ################################
 // ############################################################################
 
 
 if ($_REQUEST['do'] == 'editgarage')
 {
     if (can_administer() && $_REQUEST[id])
     {
         $id = $_REQUEST[id];
     }
     else
     {
         $id = $bbuserinfo['userid'];
     }
     
     $user = fetch_userinfo($id);
 
     if (!$bbuserinfo['userid'])
     {
         print_no_permission();
     }
   
     
     if ($permissions['genericpermissions'] & CANVBGARAGE) {
     
         $result_data = $DB_site->query("
             SELECT year,make,model,text FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id
         ");
         
         $count = 0;
         $data = $DB_site->fetch_Array($result_data);
         
         // (nop)
         $data['year'] = unhtmlspecialchars($data['year']);
         $data['make'] = unhtmlspecialchars($data['make']);
         $data['model'] = unhtmlspecialchars($data['model']);
         $data['text'] = unhtmlspecialchars($data['text']);
         // (nop)
     
     // start description        
     construct_edit_toolbar($data['text'], 0,0,1,1);    
     
     
         $result_image = $DB_site->query("
             SELECT vbgarageid,name FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
         ");
     
         while ($image = $DB_site->fetch_Array($result_image))
         {
             
             
             $count++;
             eval('$editimagebits .= "' . fetch_template('vbgarage_editimagebits') . '";');
         }
     
         $navbits = construct_navbits(array('' => 'Pagodengarage bearbeiten'));
         eval('$navbar = "' . fetch_template('navbar') . '";');
     
         eval('print_output("' . fetch_template('vbgarage_editgarage') . '");');
     }
     else
     {
         print_no_permission();
     }
 }
 
 if ($_REQUEST['do'] == 'edit')
 {
     globalize($_POST, array('year', 'make', 'model'));
     
     
     // ### PREP INPUT (should eventually all come in array direct from form) ###
     if (isset($_POST['WYSIWYG_HTML']))
     {
         require_once('./includes/functions_wysiwyg.php');
         $newpost['message'] = convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], 0);
     }
     else
     {
         $newpost['message'] = $_POST['message'];
     }
     
 
     if (can_administer() && $_REQUEST[id])
     {
         $id = $_POST[id];
     }
     else
     {
         $id = $bbuserinfo['userid'];
     }
 
     if (!$bbuserinfo['userid'])
     {
         print_no_permission();
     }
     
 
     
     
     if ($permissions['genericpermissions'] & CANVBGARAGE) {    
         if (empty($year) OR empty($make) OR empty($id))
         {
             eval (print_standard_error('error_requiredfields'));
         }
     
         if (!empty($_FILES['src']['tmp_name'])) {
             $name = $_FILES['src']['name'];
             //(nop) not implemented in this version
             //$data = addslashes( gzcompress(fread(fopen($_FILES['src']['tmp_name'], "r"), filesize($_FILES['src']['tmp_name'])), 1)  );
             $data = addslashes( fread(fopen($_FILES['src']['tmp_name'], "r"), filesize($_FILES['src']['tmp_name']))  );
             $type = $_FILES['src']['type'];
     
             // '" . $DB_site->escape_string($data) . "'
             $DB_site->query("
                 INSERT INTO " . TABLE_PREFIX . "vbgarage_images (userid, name, data, type) VALUES ($id, '" . addslashes($name) . "', '$data' , '" . addslashes($type) . "')
             ");
         }
             
         $result_user = $DB_site->query("
             SELECT * FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id
         ");
     
         $user = $DB_site->fetch_Array($result_user);
     
         if (empty($user)) {
             $DB_site->query("
                 INSERT INTO " . TABLE_PREFIX . "vbgarage_users 
                 (userid, year, make, model, text, lastactivity) 
                 VALUES 
                 ($id, '" . addslashes($year) . "', '" . addslashes($make) . "', '" . addslashes($model) . "', $text, '" . time() . "')
             ");
         }
         else
         {
             $DB_site->query("
                 UPDATE " . TABLE_PREFIX . "vbgarage_users SET year = '" . addslashes($year) . "', 
                 make = '" . addslashes($make) . "', 
                 model = '" . addslashes($model) . "', 
                 text = '" . addslashes($newpost['message']) . "', lastactivity = '" . time() . "' WHERE userid = $id
             ");
         }
     
         $result_image = $DB_site->query("
             SELECT vbgarageid,name FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
         ");
     
         if (!empty($result_image))
         {
             while ($image = $DB_site->fetch_Array($result_image))
             {
                 if ($_POST['delete'.$image['vbgarageid']])
                 {
                     $DB_site->query("
                         DELETE FROM " . TABLE_PREFIX . "vbgarage_images WHERE vbgarageid = $image[vbgarageid] LIMIT 1
                     ");
                 }
             }
         }
         Header("Location: $vboptions[bburl]/garage.php?do=editgarage&id=$id");
     }
     else
     {
         print_no_permission();
     }
 }
 
 if ($_REQUEST['do'] == 'delgarage')
 {
     globalize($_REQUEST, array('id' => INT));
     
     if (!$bbuserinfo['userid'] OR $bbuserinfo['usergroupid']!=6)
     {
         print_no_permission();
     }
     
     if (empty($id))
     {
         eval (print_standard_error('error_requiredfields'));
     }
     
     $DB_site->query("
         DELETE FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id
     "); 
 
     $DB_site->query("
         DELETE FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
     "); 
 
     $DB_site->query("
         DELETE FROM " . TABLE_PREFIX . "vbgarage_comments WHERE vbgarageid = $id
     "); 
     
     Header("Location: $vboptions[bburl]/garage.php?do=list");
 }
 
 
 // ############################################################################
 // ############################### VIEW GARAGE ################################
 // ############################################################################
 
 if ($_REQUEST['do'] == 'view')
 {
     globalize($_REQUEST, array('id' => INT));
     
     $result_data = $DB_site->query("
         SELECT * FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id LIMIT 1
     ");
     
     $data = $DB_site->fetch_Array($result_data);
     
     // (nop)
     $data['year'] = unhtmlspecialchars($data['year']);
     $data['make'] = unhtmlspecialchars($data['make']);
     $data['model'] = unhtmlspecialchars($data['model']);
     $data['text'] = unhtmlspecialchars($data['text']);
     // (nop)
     
     $data['text'] = parse_bbcode($data['text'],0, 1);
     
     $result_image = $DB_site->query("
         SELECT vbgarageid,name FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
     ");
     
     $user = fetch_userinfo($id);
 
     while ($image = $DB_site->fetch_Array($result_image))
     {
         eval('$imagebits .= "' . fetch_template('vbgarage_imagebits') . '";');
     }
     
     
     $result_comment = $DB_site->query("
         SELECT * FROM " . TABLE_PREFIX . "vbgarage_comments WHERE vbgarageid = $id
     ");
     
     while ($comment = $DB_site->fetch_Array($result_comment))
     {        
         // (nop)
         
         
         $comment['pagetext'] = parse_bbcode($comment['pagetext'],0, 1);
         $comment['dateline'] = vbdate($vboptions['dateformat'],$comment['dateline'],true);
         eval('$commentbits .= "' . fetch_template('vbgarage_commentbits') . '";');
     }
     
     $navbits = construct_navbits(array('' => 'Pagodengarage'));
     eval('$navbar = "' . fetch_template('navbar') . '";');
     
     eval('print_output("' . fetch_template('vbgarage_viewgarage') . '");');
 }    
 
 // ############################################################################
 // ############################# LIST ALL GARAGES #############################
 // ############################################################################
 
 if ($_REQUEST['do'] == 'list')
 {
     globalize($_REQUEST, array('pagenumber' => INT, 'perpage' => INT));
     
     $perpage = intval($perpage);
 
     if ($perpage == 0 or $perpage > 200) 
     {
         $perpage = 25;
     }
 
     if (intval($pagenumber) == 0) 
     {
         $pagenumber = 1;
     }
 
     $limitlower = ($pagenumber - 1) * $perpage + 1;
     $limitupper = ($pagenumber) * $perpage;
     $counter = 0;
 
     $garagecount = $DB_site->query_first("
         SELECT COUNT(*) AS garages FROM " . TABLE_PREFIX . "vbgarage_users
     ");
 
     $numberpages = $garagecount['garages'] / $perpage;
     $numberpages = ceil($numberpages);    
     
     if (!isset($pagenumber) or ($pagenumber < 1) or ($pagenumber > $numberpages))
     $pagenumber = 1;
 
     $pos = ($pagenumber - 1) * $perpage;
 
     $result_list = $DB_site->query("
         SELECT * FROM " . TABLE_PREFIX . "vbgarage_users ORDER BY userid ASC LIMIT $pos,$perpage
     ");
     
     $counter = 0;
     $count = 0;
 
     while ($list = $DB_site->fetch_Array($result_list) AND $counter++ < $perpage)
     {
         $count++;
         // (nop)
         $list['year'] = unhtmlspecialchars($list['year']);
         $list['make'] = unhtmlspecialchars($list['make']);
         $list['model'] = unhtmlspecialchars($list['model']);
         $list['text'] = unhtmlspecialchars($list['text']);
         // (nop)
         
         $list['lastactivity'] = vbdate($vboptions['dateformat'],$list['lastactivity'],true);
 
         $user = fetch_userinfo($list[userid]);
 
         eval('$listbits .= "' . fetch_template('vbgarage_listbits') . '";');
     }
     
     $result_latest = $DB_site->query("
         SELECT * FROM " . TABLE_PREFIX . "vbgarage_images ORDER BY vbgarageid DESC LIMIT 5
     ");
     
     while ($latest = $DB_site->fetch_Array($result_latest))
     {
         eval('$latestbits .= "' . fetch_template('vbgarage_latestbits') . '";');
     }
 
     $pagenav = construct_page_nav($garagecount[garages],"garage.php?$session[sessionurl]do=$_REQUEST[do]&perpage=$perpage");
 
     $navbits = construct_navbits(array('' => 'Pagodengarage'));
     eval('$navbar = "' . fetch_template('navbar') . '";');
     
     eval('print_output("' . fetch_template('vbgarage_listgarage') . '");');
 }
 
 // ############################################################################
 // ############################# GARAGE COMMENTS ##############################
 // ############################################################################
 
 if ($_REQUEST['do'] == 'addcomment')
 {    
     globalize($_REQUEST, array('comment', 'id' => INT));
 
     if (!$bbuserinfo['userid'])
     {
         print_no_permission();
     }
 
     if (empty($id) OR empty($comment))
     {
         eval (print_standard_error('error_requiredfields'));
     }
 
     // shorten comment field to 1000 characters (nop)
     $comment = substr($comment,0,1000);
         
     // strip code from input for all user vars (nop)
     while($comment != strip_tags($comment)) 
     {
             $comment = strip_tags($comment);
            }
     $comment = htmlspecialchars_uni($comment);
     // end strip codes (nop)
         
     $DB_site->query("
         INSERT INTO " . TABLE_PREFIX . "vbgarage_comments (vbgarageid, username, pagetext, dateline) VALUES ('$id', '" . addslashes($bbuserinfo[username]) . "', '" . addslashes($comment) . "', '" . time() . "')
     ");
     
     eval(print_standard_redirect('redirect_postthanks'));
 }
 
 if ($_REQUEST['do'] == 'delcomment')
 {
     globalize($_REQUEST, array('id' => INT));
     
     if (!$bbuserinfo['userid'] OR $bbuserinfo['usergroupid']!=6)
     {
         print_no_permission();
     }
     
     if (empty($id))
     {
         eval (print_standard_error('error_requiredfields'));
     }
     
     $DB_site->query("
         DELETE FROM " . TABLE_PREFIX . "vbgarage_comments WHERE id = $id LIMIT 1
     "); 
 
     eval(print_standard_redirect('redirect_deletethread'));
 }
 
 // ############################################################################
 // ############################# IMAGE FUNCTIONS ##############################
 // ############################################################################
 
 if ($_REQUEST['do'] == 'getimage')
 {
     globalize($_REQUEST, array('id' => INT));
 
     $result_image = $DB_site->query("
         SELECT data,type FROM ". TABLE_PREFIX ."vbgarage_images WHERE vbgarageid = $id LIMIT 1
     ");
     
     while ($image = $DB_site->fetch_Array($result_image))
     {         
         Header ("Content-type: $type");         
         // (nop) not implemented in this version
         //echo  gzuncompress ( $image['data'] ); 
         echo  $image['data'];  
         $type = $image['type']; 
     } 
 }
 
 if ($_REQUEST['do'] == 'popup')
 {
     globalize($_REQUEST, array('image', 'id' => INT));
     
     eval('print_output("' . fetch_template('vbgarage_popup') . '");');
 }
 
 if ($_REQUEST['do'] == 'thumb')
 {
     globalize($_REQUEST, array('width', 'id' => INT));
  
     if (empty($id) OR empty($width))
     {
         eval (print_standard_error('error_requiredfields'));
     }
 
     $result_image = $DB_site->query("
         SELECT data FROM " . TABLE_PREFIX ."vbgarage_images WHERE vbgarageid = $id LIMIT 1
     ");
     
     $image = $DB_site->fetch_Array($result_image);
     // (nop) not implemented in this version
     //$image['data'] = gzuncompress ( $image['data'] );
     $thumb['file'] = imagecreatefromstring($image['data']); 
     $thumb['height'] = imagesy($thumb['file']) / imagesx($thumb['file']) * $width; 
     $thumb['data'] = imagecreatetruecolor($width,$thumb['height']); 
 
     imagecopyresampled($thumb['data'],$thumb['file'],0,0,0,0,$width,$thumb['height'],ImageSX($thumb['file']),ImageSY($thumb['file']));
     imagejpeg($thumb['data']);
     
     imagedestroy ($thumb['file']); 
     imagedestroy ($thumb['data']); 
 }
 
 
 /*======================================================================*\
 || ####################################################################
 || # CVS: $RCSfile: vbgarage.php,v $ - $Revision: 3.1.1 $
 || ####################################################################
 \*======================================================================*/ 
Reply With Quote
  #2  
Old 01-23-2005, 10:13 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try this: https://vborg.vbsupport.ru/showthread.php?t=66895
Reply With Quote
  #3  
Old 01-23-2005, 10:24 AM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your reply but doesn't help much

If I fill in some text into the database via PHPMYadmin the editor shows them correctly.

When I edit this text via the WYSIWYG-editor it doesn't overwrite the text I added before which must have something todo with:

PHP Code:
     if (isset($_POST['WYSIWYG_HTML']))
     {
         require_once('./includes/functions_wysiwyg.php');
         $newpost['message'] = convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], 0);
     }
     else
     {
         $newpost['message'] = &$_POST['message'];
     } 
The code seems to empty the variable.. Whatever I enter, it doesn't get saved.

  1. What's already in the database: TEST
  2. What I see when I want to edit the field via the editor: TEST
  3. What I get when I enter 'BLAAAAAA' to the editor and click 'save': TEST
Reply With Quote
  #4  
Old 01-23-2005, 10:38 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

silly question but in your file you do have $newpost['message'] = $vbgarage['text']; right?

here's an example of me doing what you want to do
PHP Code:
    // get message
    $newpost['message'] = htmlspecialchars_uni($groupinfo['pagetext']);

    // get the checked option for auto subscription
    $emailchecked = fetch_emailchecked($groupinfo);

    if ($previewpost)
    {
        // if we're previewing why do we need to edit the reason?
        $newpost['reason'] = $edit['reason'];
    }
    else if ($bbuserinfo['userid'] == $postinfo['edit_userid'])
    {
        // Only carry the reason over if the editing user owns the previous edit
        $newpost['reason'] = $postinfo['edit_reason'];
    }

    $groupinfo['username'] = iif($groupinfo[edit_username], $groupinfo[edit_username], $groupinfo[username]);
    $groupinfo['postdate'] = iif($groupinfo[edit_dateline], vbdate($vboptions['dateformat'], $groupinfo[edit_dateline]), vbdate($vboptions['dateformat'], $groupinfo[dateline]));
    $groupinfo['posttime'] = iif($groupinfo[edit_dateline], vbdate($vboptions['timeformat'], $groupinfo[edit_dateline]), vbdate($vboptions['timeformat'], $groupinfo[dateline]));

    // if this is a mod edit, then log it
    if ($bbuserinfo['userid'] != $groupinfo['userid'] AND can_moderate($groupinfo['forumid'], 'caneditgroups'))
    {
        $string = construct_phrase($vbphrase['group_x_edited'], $groupinfo['title']);
        $modlogsql[] = "($bbuserinfo[userid], " . TIMENOW . ", $groupinfo[forumid], $groupinfo[threadid], $groupid, '" . addslashes($string) . "')";
    }

    require_once('./includes/functions_databuild.php');

    $stylevar[imgdir_editor] = "" . $vboptions[bburl] . "/" . $stylevar[imgdir_editor] . "";
    $smilie['smiliepath'] = "" . $vboptions[bburl] . "/" . $smilie[smiliepath] . "";
//    $smilie['smiliepath'] = preg_replace('#$smilie[smiliepath]#', "$vboptions[bburl]/$smilie[smiliepath]", $smilie[smiliepath]); 
    construct_edit_toolbar($newpost['message'], 0, $groupinfo['groupid']); 
i got a bit confused with your file as you had the construct_edit_toolbar() and then you were playing around with the $newpost array after that.
Reply With Quote
  #5  
Old 01-23-2005, 10:46 AM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok here's a completely new question
PHP Code:

  
  if ($_REQUEST['do'] == 'editgarage')
  {
  // show the editor, fill it with the information I got from the database
  
  // $data = $DB_site->fetch_Array() ...
  
  construct_edit_toolbar($data['text'], 0,0,1,1);    
  
  }
  
  if ($_REQUEST['do'] == 'edit')
  {
  // take what I entered to the editor and save it to the database
      
      if (isset($_POST['WYSIWYG_HTML']))
      {
          require_once('./includes/functions_wysiwyg.php');
          $text = convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], 0);
      }
      else
      {
          $text = &$_POST['text'];
      }
  
      
      // ^ Iam not sure about that one.. How do I get the value from the editor to add it to my database?
      // $_POST['WYSIWYG_HTML'] holds what has already been entered to the editor before
      // $_POST['text'] is totally empty
  
  
  
  } 
Reply With Quote
  #6  
Old 01-23-2005, 10:55 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

why are you requiring the functions_wysiwyg, include the functions_databuild that should include the wysiyg functions file
Reply With Quote
  #7  
Old 01-23-2005, 10:56 AM
trafix's Avatar
trafix trafix is offline
 
Join Date: Dec 2002
Location: Australia
Posts: 1,021
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what is the fuss ..... only takes 1 line of code and a couple of requires ....

i use
PHP Code:
    construct_edit_toolbar('', 0, 'calendar'); 
in the code that evaluates the form template

in the template use

HTML Code:
<!-- WYSIWYG / non WYSIWYG posting box -->
$messagearea
<!-- end WYSIWYG / non WYSIWYG posting box -->
and after submit

globalise
'message' => STR,

and use
PHP Code:
if (isset($_POST['WYSIWYG_HTML']))
    {
        require_once('./includes/functions_wysiwyg.php');
        $newpost['message'] = convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], $vboptions['allowhtml']);
    }
    else
    {
        $newpost['message'] = &$_POST['message'];
    } 
and enter it in the database with
PHP Code:
'" . addslashes($newpost[message]) . "' 
Reply With Quote
  #8  
Old 01-23-2005, 10:56 AM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oh and include the functions_newpost too
Reply With Quote
  #9  
Old 01-23-2005, 11:06 AM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

trafix: I did what you said but the database doesn't get filled with the data


Here's what I got now:
PHP Code:
/*======================================================================*\
|| #################################################################### ||
|| # vBGarage v3.1.1                              # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright ?2000?2004 magnus. All Rights Reserved.                # ||
|| # https://vborg.vbsupport.ru/showthread.php?t=63681          # ||
|| #################################################################### ||
\*======================================================================*/
// Updated by: noppid @ www.lakecs.com
// This is not official or for distrubtion.
// added length limit to text field
// added striping of html and php code from user text input fields
// strip tags code from php.net and vBulletin

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'vbgarage');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(
    'user',
    'cpglobal',
    'posting'
);

// get special data templates from the datastore
$specialtemplates = array(
    'smiliecache',
    'bbcodecache'
);

// pre-cache templates used by all actions
$globaltemplates = array(
    'vbgarage_editgarage',
    'vbgarage_editimagebits',
    'vbgarage_imagebits',
    'vbgarage_listbits',
    'vbgarage_listgarage',
    'vbgarage_popup',
    'vbgarage_viewgarage'    
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
require_once('./includes/functions_bbcodeparse.php');
require_once('./includes/functions_user.php');
require_once('./includes/adminfunctions.php');
require_once('./includes/functions_editor.php');
require_once('./includes/functions_bigthree.php');
require_once('./includes/functions_newpost.php');
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

if (!$vboptions[vbgenable] AND !can_administer())
{
    print_no_permission();
}

if (empty($_REQUEST['do']))
{
    $_REQUEST['do'] = 'list';
}

$textareacols = fetch_textarea_width();

// ############################################################################
// ############################### EDIT GARAGE ################################
// ############################################################################


if ($_REQUEST['do'] == 'editgarage')
{
    if (can_administer() && $_REQUEST[id])
    {
        $id = $_REQUEST[id];
    }
    else
    {
        $id = $bbuserinfo['userid'];
    }
    
    $user = fetch_userinfo($id);

    if (!$bbuserinfo['userid'])
    {
        print_no_permission();
    }
  
    
    if ($permissions['genericpermissions'] & CANVBGARAGE) {
    
        $result_data = $DB_site->query("
            SELECT year,make,model,text FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id
        ");
        
        $count = 0;
        $data = $DB_site->fetch_Array($result_data);
        
        // (nop)
        $data['year'] = unhtmlspecialchars($data['year']);
        $data['make'] = unhtmlspecialchars($data['make']);
        $data['model'] = unhtmlspecialchars($data['model']);
        $data['text'] = unhtmlspecialchars($data['text']);
        // (nop)
    
    // start description        
     construct_edit_toolbar('', 0, 'nonforum'); 
    
    
        $result_image = $DB_site->query("
            SELECT vbgarageid,name FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
        ");
    
        while ($image = $DB_site->fetch_Array($result_image))
        {
            
            
            $count++;
            eval('$editimagebits .= "' . fetch_template('vbgarage_editimagebits') . '";');
        }
    
        $navbits = construct_navbits(array('' => 'Pagodengarage bearbeiten'));
        eval('$navbar = "' . fetch_template('navbar') . '";');
    
        eval('print_output("' . fetch_template('vbgarage_editgarage') . '");');
    }
    else
    {
        print_no_permission();
    }
}

elseif ($_REQUEST['do'] == 'edit')
{
    globalize($_POST, array('year', 'make', 'model', 'message' => STR));
    
    if (isset($_POST['WYSIWYG_HTML']))
    {
        require_once('./includes/functions_wysiwyg.php');
        $newpost['message'] = convert_wysiwyg_html_to_bbcode($_POST['WYSIWYG_HTML'], $vboptions['allowhtml']);
    }
    else
    {
        $newpost['message'] = &$_POST['message'];
    } 
    
    

    if (can_administer() && $_REQUEST[id])
    {
        $id = $_POST[id];
    }
    else
    {
        $id = $bbuserinfo['userid'];
    }

    if (!$bbuserinfo['userid'])
    {
        print_no_permission();
    }
    

    
    
    if ($permissions['genericpermissions'] & CANVBGARAGE) {    
        if (empty($year) OR empty($make) OR empty($id))
        {
            eval (print_standard_error('error_requiredfields'));
        }
    
        if (!empty($_FILES['src']['tmp_name'])) {
            $name = $_FILES['src']['name'];
            //(nop) not implemented in this version
            //$data = addslashes( gzcompress(fread(fopen($_FILES['src']['tmp_name'], "r"), filesize($_FILES['src']['tmp_name'])), 1)  );
            $data = addslashes( fread(fopen($_FILES['src']['tmp_name'], "r"), filesize($_FILES['src']['tmp_name']))  );
            $type = $_FILES['src']['type'];
    
            // '" . $DB_site->escape_string($data) . "'
            $DB_site->query("
                INSERT INTO " . TABLE_PREFIX . "vbgarage_images (userid, name, data, type) VALUES ($id, '" . addslashes($name) . "', '$data' , '" . addslashes($type) . "')
            ");
        }
            
        $result_user = $DB_site->query("
            SELECT * FROM " . TABLE_PREFIX . "vbgarage_users WHERE userid = $id
        ");
    
        $user = $DB_site->fetch_Array($result_user);
    
        if (empty($user)) {
            $DB_site->query("
                INSERT INTO " . TABLE_PREFIX . "vbgarage_users 
                (userid, year, make, model, text, lastactivity) 
                VALUES 
                ($id, '" . addslashes($year) . "', '" . addslashes($make) . "', '" . addslashes($model) . "', '" . addslashes($newpost[message]) . "' , '" . time() . "')
            ");
        }
        else
        {
            $DB_site->query("
                UPDATE " . TABLE_PREFIX . "vbgarage_users SET year = '" . addslashes($year) . "', 
                make = '" . addslashes($make) . "', 
                model = '" . addslashes($model) . "', 
                text = '" . addslashes($newpost[message]) . "' , lastactivity = '" . time() . "' WHERE userid = $id
            ");
        }
    
        $result_image = $DB_site->query("
            SELECT vbgarageid,name FROM " . TABLE_PREFIX . "vbgarage_images WHERE userid = $id
        ");
    
        if (!empty($result_image))
        {
            while ($image = $DB_site->fetch_Array($result_image))
            {
                if ($_POST['delete'.$image['vbgarageid']])
                {
                    $DB_site->query("
                        DELETE FROM " . TABLE_PREFIX . "vbgarage_images WHERE vbgarageid = $image[vbgarageid] LIMIT 1
                    ");
                }
            }
        }
        Header("Location: $vboptions[bburl]/garage.php?do=editgarage&id=$id");
    }
    else
    {
        print_no_permission();
    }
} 
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 02:21 AM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.