/** * Additional data to update after a delete call (such as denormalized values in other tables). * * @param boolean Do the query? */ function post_delete($doquery = true) { $pictures = array(); $picture_sql = $this->registry->db->query_read("\n\t\t\tSELECT albumpicture.pictureid, picture.idhash, picture.extension\n\t\t\tFROM " . TABLE_PREFIX . "albumpicture AS albumpicture\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "picture AS picture ON (albumpicture.pictureid = picture.pictureid)\n\t\t\tWHERE albumpicture.albumid = " . $this->fetch_field('albumid')); while ($picture = $this->registry->db->fetch_array($picture_sql)) { $pictures["{$picture['pictureid']}"] = $picture; } if ($pictures) { if ($this->registry->options['album_dataloc'] != 'db') { // remove from fs foreach ($pictures as $picture) { @unlink(fetch_picture_fs_path($picture)); @unlink(fetch_picture_fs_path($picture, true)); } } $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t"); // delete based on picture id as this means that when a picture is deleted, // it's removed from all albums automatically $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "albumpicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t"); $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "picturecomment\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t"); require_once DIR . '/includes/functions_picturecomment.php'; build_picture_comment_counters($this->fetch_field('userid')); $groups = array(); $groups_sql = $this->registry->db->query_read("\n\t\t\t\tSELECT DISTINCT socialgroup.*\n\t\t\t\tFROM " . TABLE_PREFIX . "socialgrouppicture AS socialgrouppicture\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "socialgroup AS socialgroup ON (socialgroup.groupid = socialgrouppicture.groupid)\n\t\t\t\tWHERE socialgrouppicture.pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t"); while ($group = $this->registry->db->fetch_array($groups_sql)) { $groups[] = $group; } $this->registry->db->query_write("\n\t\t\t\tDELETE FROM " . TABLE_PREFIX . "socialgrouppicture\n\t\t\t\tWHERE pictureid IN (" . implode(',', array_keys($pictures)) . ")\n\t\t\t"); foreach ($groups as $group) { $groupdata =& datamanager_init('SocialGroup', $this->registry, ERRTYPE_SILENT); $groupdata->set_existing($group); $groupdata->rebuild_picturecount(); $groupdata->save(); } } $this->remove_usercss_background_image(); ($hook = vBulletinHook::fetch_hook('albumdata_delete')) ? eval($hook) : false; return true; }
/** * Any code to run after deleting * * @param Boolean Do the query? */ function post_delete($doquery = true) { require_once DIR . '/includes/functions_album.php'; $picture = array_merge($this->existing, $this->picture); @unlink(fetch_picture_fs_path($picture)); @unlink(fetch_picture_fs_path($picture, true)); return parent::post_delete($doquery); }
header('Content-transfer-encoding: binary'); if ($imageinfo['filesize']) { header('Content-Length: ' . $imageinfo['filesize']); } header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $imageinfo['dateline']) . ' GMT'); header('ETag: "' . $imageinfo['dateline'] . '-' . $imageinfo['pictureid'] . ($vbulletin->GPC['thumb'] ? '-thumb' : '') . '"'); if ($imageinfo['extension'] == 'jpg' or $imageinfo['extension'] == 'jpeg') { header('Content-type: image/jpeg'); } else { if ($imageinfo['extension'] == 'png') { header('Content-type: image/png'); } else { header('Content-type: image/gif'); } } $db->close(); if ($vbulletin->options['album_dataloc'] == 'db') { echo $imageinfo['filedata']; } else { @readfile(fetch_picture_fs_path($imageinfo, $vbulletin->GPC['thumb'])); } } else { header('Content-type: image/gif'); readfile(DIR . '/' . $vbulletin->options['cleargifurl']); } /*======================================================================*\ || #################################################################### || # Downloaded: 08:19, Wed Nov 5th 2008 || # CVS: $RCSfile$ - $Revision: 26684 $ || #################################################################### \*======================================================================*/
$tempfilename = $vbulletin->options['tmppath'] . '/' . md5(uniqid(microtime()) . $vbulletin->userinfo['userid']); } else { $tempfilename = tempnam(ini_get('upload_tmp_dir'), 'vbthumb'); } } $pictures = $db->query_read("\n\t\tSELECT *\n\t\tFROM " . TABLE_PREFIX . "picture\n\t\tWHERE pictureid >= " . $vbulletin->GPC['startid'] . "\n\t\tORDER BY pictureid\n\t\tLIMIT " . $vbulletin->GPC['perpage']); while ($picture = $db->fetch_array($pictures)) { $maxid = $picture['pictureid']; echo construct_phrase($vbphrase['processing_x'], $picture['pictureid']); if ($vbulletin->options['album_dataloc'] == 'db') { $filename = $tempfilename; $filenum = fopen($filename, 'wb'); fwrite($filenum, $picture['filedata']); fclose($filenum); } else { $filename = fetch_picture_fs_path($picture); } $thumbnail = $image->fetch_thumbnail("picture.{$picture['extension']}", $filename, $vbulletin->options['album_thumbsize'], $vbulletin->options['album_thumbsize'], $vbulletin->GPC['quality']); if (!empty($thumbnail['filedata'])) { $picturedata =& datamanager_init(fetch_picture_dm_name(), $vbulletin, ERRTYPE_SILENT, 'picture'); $picturedata->set_existing($picture); $picturedata->setr_info('thumbnail', $thumbnail['filedata']); $picturedata->set('thumbnail_dateline', TIMENOW); $picturedata->set('thumbnail_width', $thumbnail['width']); $picturedata->set('thumbnail_height', $thumbnail['height']); $picturedata->save(); unset($picturedata); } echo '<br />'; vbflush(); }
/** * Verifies that the picture filesystem path is created as necessary. * * @param array Array of picture info (to deduce the path) * @param boolean True if you want to verify the thunbnail path * * @return string|bool Path if successful, false otherwise */ function verify_picture_fs_path($pictureinfo, $thumb = false) { global $vbulletin; if (!function_exists('vbmkdir')) { require_once DIR . '/includes/functions_file.php'; } $path = fetch_picture_fs_path($pictureinfo, $thumb, false); if (vbmkdir($path)) { return $path; } else { return false; } }