vB Accelerator Optimise attachments processing 0.9 0 hide_errors(); $db->query_write("ALTER TABLE " . TABLE_PREFIX . "attachment ADD INDEX `vba_coverage` ( `attachmentid` , `filedataid` , `userid` ) "); $db->show_errors();]]> hide_errors(); $db->query_write("ALTER TABLE " . TABLE_PREFIX . "attachment DROP INDEX vba_coverage"); $db->show_errors();]]> Accelerate fullsize attachments downloads attachment_display options['vb_acc_nginx']) { @fclose($fp); require_once(DIR . '/includes/functions_file.php'); $attachuri = fetch_attachment_path( $attachmentinfo['uploader'], $attachmentinfo['filedataid'], (bool)$vbulletin->GPC['thumb'], $vbulletin->options['vb_acc_www_path_posts'] ); header('X-Accel-Redirect: ' . $attachuri); // update views counter if ( !$vbulletin->GPC['thumb'] AND connection_status() == 0 AND $lastbyte == ($attachmentinfo['filesize'] - 1)) { if ($vbulletin->options['attachmentviewslive']) { // doing it as they happen; not using a DM to avoid overhead $db->query_write(" UPDATE " . TABLE_PREFIX . "attachment SET counter = counter + 1 WHERE attachmentid = $attachmentinfo[attachmentid] "); } else { // or doing it once an hour $db->query_write(" INSERT INTO " . TABLE_PREFIX . "attachmentviews (attachmentid) VALUES ($attachmentinfo[attachmentid]) "); } } exit; }]]> Replace Thumbnails Links for HTML global_complete options['vb_acc_cdn_list'] = trim($vbulletin->options['vb_acc_cdn_list']); if (!empty($vbulletin->options['vb_acc_cdn_list'])) { $cdn_list = explode("\n", $vbulletin->options['vb_acc_cdn_list']); $cdn_list = array_map('trim', $cdn_list); foreach ($cdn_list as $key=>$cdn) { if ('/' == $cdn[strlen($cdn)-1]) { $cdn_list[$key] = substr($cdn, 0, -1); } } } else { $cdn_list[] = $vbulletin->options['bburl']; } } // Only procees if "attachment.php" exists in output html if (strpos($output, 'attachment.php')) { // get thumbnails list $pattern = '#src=\"((?:' . preg_quote($vbulletin->options['bburl'] . '/') . ')?' . 'attachment.php\?' . preg_quote("{$vbulletin->session->vars['sessionurl']}") . 'attachmentid=(\d+)[\w:\d&=;]*thumb=1[\w:\d&=;]*)\"#'; preg_match_all($pattern, $output, $matches, PREG_SET_ORDER); $attachment_ids = array(); $attachments = array(); $transformed_attachments = array(); foreach ($matches as $val) { list( , $url,$attachment_id) = $val; $attachment_ids[] = $attachment_id; $attachments[$attachment_id] = $url; $transformed_attachments[$attachment_id] = $url; } if (!empty($attachment_ids)) { require_once(DIR . '/includes/functions_file.php'); // todo maybe add index to "attachment" table? $sql = 'SELECT a.attachmentid, a.filedataid, fd.userid as uploader FROM ' . TABLE_PREFIX . 'attachment AS a INNER JOIN ' . TABLE_PREFIX . 'filedata AS fd USING (filedataid) WHERE a.attachmentid IN (' . implode(', ', $attachment_ids) . ')'; $result = $vbulletin->db->query_read($sql); $position = 0; while ($row = $vbulletin->db->fetch_array($result)) { $path = $cdn_list[$position] . $vbulletin->options['vb_acc_www_path_posts']; // extract timestamp preg_match('#&d=(\d+)#', $transformed_attachments[$row['attachmentid']], $timestamp); $transformed_attachments[$row['attachmentid']]= fetch_attachment_path( $row['uploader'], $row['filedataid'], true, $path ) . '?d='. $timestamp[1]; $position = ++$position % count($cdn_list); } } // replace old thumb attachements links if (!empty($attachments)) { $output = str_replace($attachments, $transformed_attachments, $output); } } // Only procees if "asset.php" exists in output html if (strpos($output, 'asset.php')) { require_once(DIR . '/includes/functions_file.php'); // get thumbnails list $pattern = '#src=\"(asset.php\?' . preg_quote("{$vbulletin->session->vars['sessionurl']}") . 'fid=(\d+)&uid=(\d+)&d=(\d+))\"#'; preg_match_all($pattern, $output, $matches, PREG_SET_ORDER); $attachment_ids = array(); $attachments = array(); $transformed_attachments = array(); $position = 0; foreach ($matches as $val) { list( , $url,$attachment_fid,$attachment_uid,$attachment_timestamp) = $val; $attachments[$attachment_fid] = $url; $path = $cdn_list[$position] . $vbulletin->options['vb_acc_www_path_posts']; $transformed_attachments[$attachment_fid]= fetch_attachment_path( $attachment_uid, $attachment_fid, true, $path ) . '?d=' . $attachment_timestamp; $position = ++$position % count($cdn_list); } // replace thumb links if (!empty($attachments)) { $output = str_replace($attachments, $transformed_attachments, $output); } }]]> Replace Thumbnails Links for XML xml_print_output options['vb_acc_cdn_list'] = trim($vbulletin->options['vb_acc_cdn_list']); if (!empty($vbulletin->options['vb_acc_cdn_list'])) { $cdn_list = explode("\n", $vbulletin->options['vb_acc_cdn_list']); $cdn_list = array_map('trim', $cdn_list); foreach ($cdn_list as $key=>$cdn) { if ('/' == $cdn[strlen($cdn)-1]) { $cdn_list[$key] = substr($cdn, 0, -1); } } } else { $cdn_list[] = $vbulletin->options['bburl']; } } // Only procees if "attachment.php" exists in output html if (strpos($this->doc, 'attachment.php')) { // get thumbnails list $pattern = '#src=\"((?:' . preg_quote($vbulletin->options['bburl'] . '/') . ')?' . 'attachment.php\?' . preg_quote("{$vbulletin->session->vars['sessionurl']}") . 'attachmentid=(\d+)[\w:\d&=;]*thumb=1[\w:\d&=;]*)\"#'; preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER); $attachment_ids = array(); $attachments = array(); $transformed_attachments = array(); foreach ($matches as $val) { list( , $url,$attachment_id) = $val; $attachment_ids[] = $attachment_id; $attachments[$attachment_id] = $url; $transformed_attachments[$attachment_id] = $url; } if (!empty($attachment_ids)) { require_once(DIR . '/includes/functions_file.php'); // todo maybe add index to "attachment" table? $sql = 'SELECT a.attachmentid, a.filedataid, fd.userid as uploader FROM ' . TABLE_PREFIX . 'attachment AS a INNER JOIN ' . TABLE_PREFIX . 'filedata AS fd USING (filedataid) WHERE a.attachmentid IN (' . implode(', ', $attachment_ids) . ')'; $result = $vbulletin->db->query_read($sql); $position = 0; while ($row = $vbulletin->db->fetch_array($result)) { $path = $cdn_list[$position] . $vbulletin->options['vb_acc_www_path_posts']; // extract timestamp preg_match('#&d=(\d+)#', $transformed_attachments[$row['attachmentid']], $timestamp); $transformed_attachments[$row['attachmentid']]= fetch_attachment_path( $row['uploader'], $row['filedataid'], true, $path ) . '?d='. $timestamp[1]; $position = ++$position % count($cdn_list); } } // replace old thumb attachements links if (!empty($attachments)) { $this->doc = str_replace($attachments, $transformed_attachments, $this->doc); } } // Only procees if "asset.php" exists in output html if (strpos($this->doc, 'asset.php')) { require_once(DIR . '/includes/functions_file.php'); // get thumbnails list $pattern = '#src=\"(asset.php\?' . preg_quote("{$vbulletin->session->vars['sessionurl']}") . 'fid=(\d+)&uid=(\d+)&d=(\d+))\"#'; preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER); $attachment_ids = array(); $attachments = array(); $transformed_attachments = array(); $position = 0; foreach ($matches as $val) { list( , $url,$attachment_fid,$attachment_uid,$attachment_timestamp) = $val; $attachments[$attachment_fid] = $url; $path = $cdn_list[$position] . $vbulletin->options['vb_acc_www_path_posts']; $transformed_attachments[$attachment_fid]= fetch_attachment_path( $attachment_uid, $attachment_fid, true, $path ) . '?d=' . $attachment_timestamp; $position = ++$position % count($cdn_list); } // replace thumb links if (!empty($attachments)) { $this->doc = str_replace($attachments, $transformed_attachments, $this->doc); } }]]>
http://img1.myforum.com
http://img2.myforum.com
http://img3.myforum.com
http://img4.myforum.com

If don't use mirrors - leave this field blank or set to forum domain.]]>

Other webservers don't catch X-Accel-Redirect headers!!!]]>
free /uploads free textarea boolean yesno 0