function video_delete_object($args) { $obj = $args['obj']; if (!isset($obj['type']) || $obj['type'] != 'video') { return false; } load_modules('glue'); if (!empty($obj['video-file'])) { $pn = array_shift(expl('.', $obj['name'])); delete_upload(array('pagename' => $pn, 'file' => $obj['video-file'], 'max_cnt' => 1)); } }
function download_delete_object($args) { $obj = $args['obj']; if (!isset($obj['type']) || $obj['type'] != 'download') { return false; } load_modules('glue'); $a = expl('.', $obj['name']); $ret = delete_upload(array('pagename' => $a[0], 'file' => $obj['download-file'], 'max_cnt' => 1)); if ($ret['#error']) { log_error('error', 'upload_delete_object: delete_upload returned ' . quot($ret['#error'])); } }
<?php defined('IN_DESTOON') or exit('Access Denied'); @ignore_user_abort(true); $session = new dsession(); if ($_SESSION['uploads']) { foreach ($_SESSION['uploads'] as $file) { delete_upload($file, $_userid); } $_SESSION['uploads'] = array(); }
$status = delete_file($id); generate_sitemap(); exec_action('page-delete'); redirect("pages.php?upd=edit-" . $status . "&id=" . $id . "&type=delete"); } } // are we deleting archives? if (isset($_GET['zip'])) { $zip = $_GET['zip']; $status = delete_zip($zip); redirect("archive.php?upd=del-" . $status . "&id=" . $zip); } // are we deleting uploads? if (isset($_GET['file'])) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $file = $_GET['file']; $status = delete_upload($file, $path); redirect("upload.php?upd=del-" . $status . "&id=" . $file . "&path=" . $path); } // are we deleting a folder? if (isset($_GET['folder'])) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $folder = $_GET['folder']; $target = GSDATAUPLOADPATH . $path . $folder; if (path_is_safe($target, GSDATAUPLOADPATH) && file_exists($target)) { rmdir($target); // delete thumbs folder rmdir(GSTHUMBNAILPATH . $path . $folder); redirect("upload.php?upd=del-success&id=" . $folder . "&path=" . $path); } }
$menus = array(array('上传记录', '?file=' . $file)); $id = isset($id) ? intval($id) : -1; $id > -1 && $id < 10 or $id = -1; if ($id == -1 && $action != 'part') { $action = 'part'; } if ($id > -1) { $table = $DT_PRE . 'upload_' . $id; } switch ($action) { case 'delete': $itemid or msg('请选择记录'); $itemids = is_array($itemid) ? implode(',', $itemid) : $itemid; $result = $db->query("SELECT fileurl FROM {$table} WHERE pid IN ({$itemids})"); while ($r = $db->fetch_array($result)) { delete_upload($r['fileurl'], 0); } $db->query("DELETE FROM {$table} WHERE pid IN ({$itemids})"); dmsg('删除成功', $forward); break; case 'delete_record': $itemid or msg('请选择记录'); $itemids = is_array($itemid) ? implode(',', $itemid) : $itemid; $db->query("DELETE FROM {$table} WHERE pid IN ({$itemids})"); dmsg('删除成功', $forward); break; case 'part': $lists = array(); for ($i = 0; $i < 10; $i++) { $r = array(); $r['table'] = $DT_PRE . 'upload_' . $i;
function delete($itemid) { if (is_array($itemid)) { foreach ($itemid as $v) { $this->delete($v, $all); } } else { $this->itemid = $itemid; $r = $this->get_one(); $userid = get_user($r['editor']); if ($r['content']) { delete_local($r['content'], $userid); } if ($r['thumb']) { delete_upload($r['thumb'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE itemid={$itemid}"); $this->db->query("DELETE FROM {$this->table_order} WHERE itemid={$itemid}"); } }
delete_file_content($id); generate_sitemap(); exec_action('page-delete'); redirect("cpages.php?upd=edit-success&id=" . $id . "&type=delete"); } } // are we deleting archives? if (isset($_GET['zip'])) { $zip = $_GET['zip']; $status = delete_zip($zip); redirect("archive.php?upd=del-" . $status . "&id=" . $zip); } // are we deleting uploads? if (isset($_GET['file'])) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $file = $_GET['file']; delete_upload($file, $path); redirect("upload.php?upd=del-success&id=" . $file . "&path=" . $path); } // are we deleting a folder? if (isset($_GET['folder'])) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $folder = $_GET['folder']; $target = GSDATAUPLOADPATH . $path . $folder; if (file_exists($target)) { rmdir($target); // delete thumbs folder rmdir(GSTHUMBNAILPATH . $path . $folder); redirect("upload.php?upd=del-success&id=" . $folder . "&path=" . $path); } }
function page_upload($args) { // only handle the file if the frontend wants us to if (empty($args['preferred_module']) || $args['preferred_module'] != 'page') { return false; } // check if supported file if (!in_array($args['mime'], array('image/jpeg', 'image/png', 'image/gif')) || $args['mime'] == '' && !in_array(filext($args['file']), array('jpg', 'jpeg', 'png', 'gif'))) { return false; } // check if there is already a background-image and delete it $obj = load_object(array('name' => $args['page'] . '.page')); if (!$obj['#error']) { $obj = $obj['#data']; if (!empty($obj['page-background-file'])) { delete_upload(array('pagename' => array_shift(expl('.', $args['page'])), 'file' => $obj['page-background-file'], 'max_cnt' => 1)); } } // set as background-image in page object $obj = array(); $obj['name'] = $args['page'] . '.page'; $obj['page-background-file'] = $args['file']; $obj['page-background-mime'] = $args['mime']; // update page object load_modules('glue'); $ret = update_object($obj); if ($ret['#error']) { log_msg('page_upload: error updating page object: ' . quot($ret['#data'])); return false; } else { // we don't actually render the object here, but signal the // frontend that everything went okay return true; } }
/** * Delete an IOTD. * * @param AUTO_LINK The ID of the IOTD to delete */ function delete_iotd($id) { $caption = $GLOBALS['SITE_DB']->query_value('iotd', 'caption', array('id' => $id)); $title = $GLOBALS['SITE_DB']->query_value('iotd', 'i_title', array('id' => $id)); log_it('DELETE_IOTD', strval($id), get_translated_text($caption)); delete_lang($caption); delete_lang($title); require_code('files2'); delete_upload('uploads/iotds', 'iotd', 'url', 'id', $id); delete_upload('uploads/iotds_thumbs', 'iotd', 'thumb_url', 'id', $id); // Delete from the database $GLOBALS['SITE_DB']->query_delete('iotd', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'iotds', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'iotds', 'trackback_for_id' => $id)); decache('main_iotd'); }
function delupload($username, $userid) { if (!$userid || !$username) { return; } $result = $this->db->query("SELECT fileurl FROM {$this->db->pre}upload_" . $userid % 10 . " WHERE username='******'"); while ($r = $this->db->fetch_array($result)) { delete_upload($r['fileurl'], $userid); } }
// Relative $relative = '../'; // Include common.php include 'inc/common.php'; login_cookie_check(); $nonce = $_GET['nonce']; if (!check_nonce($nonce, "delete", "deletefile.php")) { die("CSRF detected!"); } // are we deleting pages? if (isset($_GET['id'])) { $id = $_GET['id']; if ($id == 'index') { header('Location: pages.php?upd=edit-err&type=You cannot delete your homepage'); } else { delete_file($id); header("Location: pages.php?upd=edit-success&id=" . $id . "&type=delete"); } } // are we deleting archives? if (isset($_GET['zip'])) { $zip = $_GET['zip']; $status = delete_zip($zip); header("Location: archive.php?upd=del-" . $status . "&id=" . $zip); } // are we deleting uploads? if (isset($_GET['file'])) { $file = $_GET['file']; delete_upload($file); header("Location: upload.php?upd=del-success&id=" . $file); }
function delete($itemid, $all = true) { global $MOD, $L; if (is_array($itemid)) { foreach ($itemid as $v) { $this->delete($v); } } else { $this->itemid = $itemid; $r = $this->get_one(); $userid = get_user($r['username']); if ($r['thumb']) { delete_upload($r['thumb'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE itemid={$itemid}"); if ($r['username'] && $MOD['credit_del_credit']) { credit_add($r['username'], -$MOD['credit_del_credit']); credit_record($r['username'], -$MOD['credit_del_credit'], 'system', $L['honor_punish_reason'], 'ID:' . $this->itemid); } } }
function item_update($post) { global $_userid; $thumb = $post[0]['thumb']; $this->item_add($post[0]); unset($post[0]); foreach ($post as $k => $v) { if ($v['thumb']) { $thumb .= $v['thumb']; } if (isset($v['delete'])) { if ($v['thumb']) { delete_upload($v['thumb'], $_userid); } $this->item_delete($k); unset($post[$k]); } } if ($thumb) { clear_upload($thumb, $this->itemid); } $this->item_edit($post); return true; }
delete_upload($HOME['bannerf'], $_userid); } if ($HOME['banner1'] != $setting['banner1']) { delete_upload($HOME['banner1'], $_userid); } if ($HOME['banner2'] != $setting['banner2']) { delete_upload($HOME['banner2'], $_userid); } if ($HOME['banner3'] != $setting['banner3']) { delete_upload($HOME['banner3'], $_userid); } if ($HOME['banner4'] != $setting['banner4']) { delete_upload($HOME['banner4'], $_userid); } if ($HOME['banner5'] != $setting['banner5']) { delete_upload($HOME['banner5'], $_userid); } clear_upload($setting['background'] . $setting['logo'] . $setting['video'] . $setting['banner'] . $setting['bannerf'] . $setting['banner1'] . $setting['banner2'] . $setting['banner3'] . $setting['banner4'] . $setting['banner5']); $announce = $setting['announce']; unset($setting['announce']); $setting = dhtmlspecialchars($setting); $setting['announce'] = dsafe($announce); update_company_setting($_userid, $setting); dmsg($L['home_msg_save'], 'home.php?tab=' . $tab); } } else { $CS = cache_read('module-4.php'); $api_map = $CS['map']; $api_stats = $CS['stats']; $api_kf = $CS['kf']; $menu_f = ',';
function clear_upload($content = '', $itemid = 0) { global $CFG, $DT, $db, $session, $_userid; if (!is_object($session)) { $session = new dsession(); } if (!isset($_SESSION['uploads']) || !$_SESSION['uploads'] || !$content) { return; } $update = array(); foreach ($_SESSION['uploads'] as $file) { if (strpos($content, $file) === false) { delete_upload($file, $_userid); } else { if ($DT['uploadlog'] && $itemid) { $update[] = "'" . md5($file) . "'"; } } } if ($update) { $db->query("UPDATE {$db->pre}upload_" . $_userid % 10 . " SET itemid={$itemid} WHERE item IN (" . implode(',', $update) . ")"); } $_SESSION['uploads'] = array(); }
/** * Delete a news entry. * * @param AUTO_LINK The ID of the news to edit */ function delete_news($id) { $rows = $GLOBALS['SITE_DB']->query_select('news', array('title', 'news', 'news_article'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $title = $rows[0]['title']; $news = $rows[0]['news']; $news_article = $rows[0]['news_article']; $_title = get_translated_text($title); log_it('DELETE_NEWS', strval($id), $_title); require_code('files2'); delete_upload('uploads/grepimages', 'news', 'news_image', 'id', $id); $GLOBALS['SITE_DB']->query_delete('news', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('news_category_entries', array('news_entry' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'news', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'news', 'trackback_for_id' => $id)); delete_lang($title); delete_lang($news); require_code('attachments2'); require_code('attachments3'); if (!is_null($news_article)) { delete_lang_comcode_attachments($news_article, 'news', strval($id)); } require_code('seo2'); seo_meta_erase_storage('news', strval($id)); decache('main_news'); decache('side_news'); decache('side_news_archive'); decache('bottom_news'); }
function item_delete($itemid = 0) { global $_userid; if ($itemid) { $r = $this->db->get_one("SELECT thumb FROM {$this->table_item} WHERE itemid={$itemid}"); if ($r) { delete_upload($r['thumb'], $_userid); $this->db->query("DELETE FROM {$this->table_item} WHERE itemid={$itemid}"); } } else { $result = $this->db->query("SELECT thumb FROM {$this->table_item} WHERE item={$this->itemid}"); while ($r = $this->db->fetch_array($result)) { delete_upload($r['thumb'], $_userid); } $this->db->query("DELETE FROM {$this->table_item} WHERE item={$this->itemid}"); } }
/** * Delete a banner. * * @param ID_TEXT The name of the banner */ function delete_banner($name) { $caption = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'caption', array('name' => $name)); if (is_null($caption)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } log_it('DELETE_BANNER', $name, get_translated_text($caption)); delete_lang($caption); require_code('files2'); delete_upload('uploads/banners', 'banners', 'img_url', 'name', $name); decache('main_banner_wave'); decache('main_topsites'); // Delete from database $GLOBALS['SITE_DB']->query_delete('banners', array('name' => $name), '', 1); }
if (strpos($do->saveto, '.thumb.') !== false) { $local = str_replace('.thumb.' . $do->ext, '', $do->saveto); $remote = str_replace('.thumb.' . $do->ext, '', $exp[1]); $ftp->dftp_put($local, $remote); file_del(DT_ROOT . '/' . $local); $local = str_replace('.thumb.' . $do->ext, '.middle.' . $do->ext, $do->saveto); $remote = str_replace('.thumb.' . $do->ext, '.middle.' . $do->ext, $exp[1]); $ftp->dftp_put($local, $remote); file_del(DT_ROOT . '/' . $local); } } } } $fid = isset($fid) ? $fid : ''; if (isset($old) && $old && in_array($from, array('thumb', 'photo'))) { delete_upload($old, $_userid); } $_SESSION['uploads'][] = $swfupload ? str_replace('.thumb.' . $do->ext, '', $saveto) : $saveto; if ($DT['uploadlog']) { $db->query("INSERT INTO {$upload_table} (item,fileurl,filesize,fileext,upfrom,width,height,moduleid,username,ip,addtime,itemid) VALUES ('" . md5($saveto) . "','{$saveto}','{$do->file_size}','{$do->ext}','{$from}','{$img_w}','{$img_h}','{$moduleid}','{$_username}','{$DT_IP}','{$do->uptime}','{$itemid}')"); } if ($swfupload) { exit('FILEID:' . $saveto); } $pr = 'parent.document.getElementById'; if ($from == 'thumb') { $js .= 'try{' . $pr . '("d' . $fid . '").src="' . $saveto . '";}catch(e){}'; $js .= $pr . '("' . $fid . '").value="' . $saveto . '";'; $js .= 'window.parent.cDialog();'; } else { if ($from == 'album' || $from == 'photo') {
$itemid or msg('请选择记录'); $i = 0; foreach ($itemid as $id) { $r = $db->get_one("SELECT * FROM {$table} WHERE itemid='{$id}' AND status=2"); if ($r) { $username = $r['username']; $fd = $r['type']; $userid = get_user($username); if ($r['thumb']) { delete_upload($r['thumb'], $userid); } if ($r['thumb1']) { delete_upload($r['thumb1'], $userid); } if ($r['thumb2']) { delete_upload($r['thumb2'], $userid); } $db->query("DELETE FROM {$table} WHERE itemid={$id}"); if ($msg) { $content = $title = '您的' . $V[$fd] . '没有通过审核,请重新认证'; if ($reason) { $content .= '<br/>失败原因:' . nl2br($reason); } send_message($username, $title, $content); } if ($msg) { $t = $db->get_one("SELECT mobile FROM {$DT_PRE}member WHERE username='******'"); if ($t) { $content = '您的' . $V[$fd] . '没有通过审核,请重新认证'; if ($reason) { $content .= ',失败原因:' . $reason;
/** * Delete a download. * * @param AUTO_LINK The ID of the download to delete * @param boolean Whether to leave the actual file behind */ function delete_download($id, $leave = false) { $myrows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('name', 'description', 'comments'), array('id' => $id), '', 1); if (!array_key_exists(0, $myrows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $myrows[0]; log_it('DELETE_DOWNLOAD', strval($id), get_translated_text($myrow['name'])); delete_lang($myrow['name']); delete_lang($myrow['description']); delete_lang($myrow['comments']); require_code('seo2'); seo_meta_erase_storage('downloads_download', strval($id)); if (!$leave) { require_code('files2'); delete_upload('uploads/downloads', 'download_downloads', 'url', 'id', $id); } // Delete from database $GLOBALS['SITE_DB']->query_delete('download_downloads', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('download_logging', array('id' => $id)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $id)); $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $id)); $GLOBALS['SITE_DB']->query_update('download_downloads', array('out_mode_id' => NULL), array('out_mode_id' => $id), '', 1); if (addon_installed('galleries')) { // Delete gallery $name = 'download_' . strval($id); require_code('galleries2'); $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'parent_id', array('name' => 'download_' . strval($id))); if (!is_null($test)) { delete_gallery($name); } } decache('main_recent_downloads'); decache('main_top_downloads'); decache('main_download_category'); decache('main_download_tease'); }
function delete($itemid, $all = true) { global $MOD; if (is_array($itemid)) { foreach ($itemid as $v) { $this->delete($v, $all); } } else { $this->itemid = $itemid; $r = $this->get_one(); if ($all) { $userid = get_user($r['username']); if ($r['thumb']) { delete_upload($r['thumb'], $userid); } if ($r['content']) { delete_local($r['content'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE itemid={$itemid}"); $this->db->query("DELETE FROM {$this->table_data} WHERE itemid={$itemid}"); if ($r['username'] && $MOD['credit_del_resume']) { credit_add($r['username'], -$MOD['credit_del_resume']); credit_record($r['username'], -$MOD['credit_del_resume'], 'system', lang('my->credit_record_resume_del'), 'ID:' . $this->itemid); } } } }
/** * Delete a specified gallery. * * @param ID_TEXT The gallery codename */ function delete_gallery($name) { if ($name == '') { warn_exit(do_lang_tempcode('NO_DELETE_ROOT')); } $rows = $GLOBALS['SITE_DB']->query_select('galleries', array('*'), array('name' => $name), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } require_code('files2'); delete_upload('uploads/grepimages', 'galleries', 'rep_image', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_top_left', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_top_right', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_left', 'name', $name); delete_upload('uploads/watermarks', 'galleries', 'watermark_bottom_right', 'name', $name); log_it('DELETE_GALLERY', $name, get_translated_text($rows[0]['fullname'])); delete_lang($rows[0]['fullname']); delete_lang($rows[0]['description']); delete_lang($rows[0]['teaser']); // Images and videos are deleted, because we are deleting the _gallery_, not just a category (nobody is going to be deleting galleries with the expectation of moving the image to a different one in bulk - unlike download categories, for example). if (function_exists('set_time_limit')) { @set_time_limit(0); } do { $images = $GLOBALS['SITE_DB']->query_select('images', array('id'), array('cat' => $name), '', 200); foreach ($images as $image) { delete_image($image['id'], false); } } while ($images != array()); do { $videos = $GLOBALS['SITE_DB']->query_select('videos', array('id'), array('cat' => $name), '', 200); foreach ($videos as $video) { delete_video($video['id'], false); } } while ($images != array()); //... but the subgalleries remain $GLOBALS['SITE_DB']->query_update('galleries', array('parent_id' => $rows[0]['parent_id']), array('parent_id' => $name)); $GLOBALS['SITE_DB']->query_delete('galleries', array('name' => $name), '', 1); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'images', 'rating_for_id' => $name)); $GLOBALS['SITE_DB']->query_delete('rating', array('rating_for_type' => 'videos', 'rating_for_id' => $name)); require_code('seo2'); seo_meta_erase_storage('gallery', $name); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'galleries', 'category_name' => $name)); $GLOBALS['SITE_DB']->query_delete('gsp', array('module_the_name' => 'galleries', 'category_name' => $name)); decache('main_top_galleries'); decache('main_recent_galleries'); decache('main_root_galleries'); decache('side_root_galleries'); }
<?php defined('IN_DESTOON') or exit('Access Denied'); $tab = isset($tab) ? intval($tab) : 0; $all = isset($all) ? intval($all) : 0; if ($submit) { $tmp = ''; if ($MOD['flvstart'] != $setting['flvstart']) { delete_upload($MOD['flvstart']); $tmp .= $setting['flvstart']; } if ($MOD['flvend'] != $setting['flvend']) { delete_upload($MOD['flvend']); $tmp .= $setting['flvend']; } if ($tmp) { clear_upload($tmp); } if ($setting['split']) { $setting['fulltext'] = 0; cache_write($moduleid . '.part', $moduleid); } else { cache_delete($moduleid . '.part'); } foreach ($setting as $k => $v) { if (strpos($k, 'seo_') === false) { continue; } seo_check($v) or msg('SEO信息包含非法字符'); } update_setting($moduleid, $setting);
function delete($itemid, $all = true) { global $MOD; if (is_array($itemid)) { foreach ($itemid as $v) { $this->delete($v, $all); } } else { $this->itemid = $itemid; $r = $this->get_one(); if ($MOD['show_html']) { $_file = DT_ROOT . '/' . $MOD['moduledir'] . '/' . $r['linkurl']; if (is_file($_file)) { unlink($_file); } } if ($all) { $userid = get_user($r['username']); if ($r['thumb']) { delete_upload($r['thumb'], $userid); } if ($r['video']) { delete_upload($r['video'], $userid); } if ($r['content']) { delete_local($r['content'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE itemid={$itemid}"); $content_table = content_table($this->moduleid, $this->itemid, $this->split, $this->table_data); $this->db->query("DELETE FROM {$content_table} WHERE itemid={$itemid}"); if ($MOD['cat_property']) { $this->db->query("DELETE FROM {$this->db->pre}category_value WHERE moduleid={$this->moduleid} AND itemid={$itemid}"); } if ($r['username'] && $MOD['credit_del']) { credit_add($r['username'], -$MOD['credit_del']); credit_record($r['username'], -$MOD['credit_del'], 'system', lang('my->credit_record_del', array($MOD['name'])), 'ID:' . $this->itemid); } } } }
/** * resize an image object * * this function drops the reference to any currently resized version, * saves the resized image together with the original image in the page's * shared folder and updates the object file to use the resized version. * @param array $args arguments * key 'name' name of the objects * key 'width' width in px * key 'height' height in px * @return array response * true if the client is advised to reload the image, false if not */ function image_resize($args) { // check for gd if (!_gd_available()) { return response('Host does not have gd', 500); } // set requested width & height if (($width = @intval($args['width'])) == 0) { return response('Required argument "width" is zero or does not exist', 400); } if (($height = @intval($args['height'])) == 0) { return response('Required argument "height" is zero or does not exist', 400); } load_modules('glue'); // resolve symlinks $ret = object_get_symlink($args); if ($ret['#error']) { return $ret; } elseif ($ret['#data'] !== false) { log_msg('debug', 'image_resize: resolved object ' . quot($args['name']) . ' into ' . quot($ret['#data'])); $args['name'] = $ret['#data']; } // load object $obj = load_object($args); if ($obj['#error']) { return $obj; } else { $obj = $obj['#data']; } if (@intval($obj['image-file-width']) == 0 || @intval($obj['image-file-height']) == 0) { return response('Original dimensions are not available', 500); } // set pagename $pn = array_shift(expl('.', $obj['name'])); // resizing might not be necessary at all if (!empty($obj['image-resized-file']) && @intval($obj['image-resized-width']) == $width && @intval($obj['image-resized-height'] == $height)) { log_msg('debug', 'image_resize: width and height match the current resized file, no resize necessary'); return response(false); } // else remove any currently resized file if (!empty($obj['image-resized-file'])) { log_msg('info', 'image_resize: dropping reference to previous resized file ' . quot($obj['image-resized-file'])); delete_upload(array('pagename' => $pn, 'file' => $obj['image-resized-file'], 'max_cnt' => 1)); unset($obj['image-resized-file']); unset($obj['image-resized-width']); unset($obj['image-resized-height']); // update object file as well $ret = object_remove_attr(array('name' => $obj['name'], 'attr' => array('image-resized-file', 'image-resized-width', 'image-resized-height'))); if ($ret['#error']) { return $ret; } $was_resized = true; } else { $was_resized = false; } // check if width or height are larger than the original if (@intval($obj['image-file-width']) <= $width || @intval($obj['image-file-height']) <= $height) { log_msg('debug', 'image_resize: dimensions requested are larger or equal than the original file is, no resize necessary'); // the client need not reload the the image if we were using the // original before if (!$was_resized) { return response(false); } else { return response(true); } } // check if we really have a source image if (empty($obj['image-file-mime']) && empty($obj['image-file'])) { return response(false); } // TODO (later): make this a generic function // load source file $ext = filext($obj['image-file']); $fn = CONTENT_DIR . '/' . $pn . '/shared/' . $obj['image-file']; if ($obj['image-file-mime'] == 'image/jpeg' || in_array($ext, array('jpg', 'jpeg'))) { $orig = @imagecreatefromjpeg($fn); $dest_ext = 'jpg'; } elseif ($obj['image-file-mime'] == 'image/png' || $ext == 'png') { $orig = @imagecreatefrompng($fn); $dest_ext = 'png'; } elseif (is_ani($fn)) { // animated images shall not be resized log_msg('debug', 'image_resize: animated image, not resizing'); return response(true); } elseif ($obj['image-file-mime'] == 'image/gif' || $ext == 'gif') { $orig = @imagecreatefromgif($fn); // save gifs as png // TODO (later): check for animated gif (see php.net/manual/en/function.imagecreatefromgif.php) $dest_ext = 'png'; } else { return response('Unsupported source file format ' . quot($obj['image-file']), 500); } if ($orig === false) { return response('Error loading source file ' . quot($obj['image-file']), 500); } // get source file dimensions $orig_size = @getimagesize($fn); // create resized image if (($resized = @imagecreatetruecolor($width, $height)) === false) { @imagedestroy($orig); return response('Error creating the resized image', 500); } // preserve any alpha channel @imagealphablending($resized, false); @imagesavealpha($resized, true); // try to resize if (!@imagecopyresampled($resized, $orig, 0, 0, 0, 0, $width, $height, $orig_size[0], $orig_size[1])) { @imagedestroy($resized); @imagedestroy($orig); return response('Error resizing the source image', 500); } // setup destination filename $a = expl('.', $obj['image-file']); if (1 < count($a)) { // throw the previous extension away $fn = CONTENT_DIR . '/' . $pn . '/shared/' . implode('.', array_slice($a, 0, -1)) . '-' . $width . 'x' . $height . '.' . $dest_ext; } else { $fn = CONTENT_DIR . '/' . $pn . '/shared/' . $a[0] . '-' . $width . 'x' . $height . '.' . $dest_ext; } $m = umask(0111); if ($dest_ext == 'jpg') { $ret = @imagejpeg($resized, $fn, IMAGE_JPEG_QUAL); } else { if ($dest_ext == 'png') { // preserve any alpha channel @imagealphablending($resized, false); @imagesavealpha($resized, true); $ret = @imagepng($resized, $fn, IMAGE_PNG_QUAL); } } umask($m); // destroy images again @imagedestroy($resized); @imagedestroy($orig); if (!$ret) { return response('Error saving the resized image', 500); } else { log_msg('info', 'image_resize: created a resized image of ' . quot($obj['name']) . ' -> ' . quot(basename($fn))); } // the code above can take a while, so read in the object anew via // update_object() $update = array(); $update['name'] = $obj['name']; $update['image-resized-file'] = basename($fn); $update['image-resized-width'] = $width; $update['image-resized-height'] = $height; // we change width and height here as well since we are racing with the // save_object from the frontend after resize $update['object-width'] = $width . 'px'; $update['object-height'] = $height . 'px'; return update_object($update); }
$t or msg('记录不存在'); $U = userinfo($username); $U or msg('会员不存在'); $E = dstripslashes(unserialize($t['content'])); $userid = $U['userid']; $content_table = content_table(4, $userid, is_file(DT_CACHE . '/4.part'), $DT_PRE . 'company_data'); $t = $db->get_one("SELECT * FROM {$content_table} WHERE userid={$userid}"); $U['content'] = $t['content']; if (isset($E['regunit']) && !isset($E['capital'])) { $E['capital'] = $U['capital']; } if ($submit) { $sql1 = $sql2 = $sql3 = ''; if (in_array('thumb', $pass) && isset($E['thumb'])) { if ($U['thumb']) { delete_upload($U['thumb'], $userid); } $sql2 .= ",thumb='" . addslashes($E['thumb']) . "'"; } if (in_array('areaid', $pass) && isset($E['areaid'])) { $sql1 .= ",areaid='" . addslashes($E['areaid']) . "'"; $sql2 .= ",areaid='" . addslashes($E['areaid']) . "'"; } if (in_array('type', $pass) && isset($E['type'])) { $sql2 .= ",type='" . addslashes($E['type']) . "'"; } if (in_array('business', $pass) && isset($E['business'])) { $sql2 .= ",business='" . addslashes($E['business']) . "'"; } if (in_array('regyear', $pass) && isset($E['regyear'])) { $sql2 .= ",regyear='" . addslashes($E['regyear']) . "'";
function delete($aid) { if (is_array($aid)) { foreach ($aid as $v) { $this->delete($v); } } else { $this->aid = $aid; $a = $this->get_one(); $filename = ad_name($a); file_del(DT_CACHE . '/htm/' . $filename); $userid = get_user($a['username']); if ($a['image_src']) { delete_upload($a['image_src'], $userid); } if ($a['flash_src']) { delete_upload($a['flash_src'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE aid={$aid}"); $this->db->query("UPDATE {$this->table_place} SET ads=ads-1 WHERE pid={$a['pid']}"); } }
function delete($itemid, $all = true) { global $MOD, $table; if (is_array($itemid)) { foreach ($itemid as $v) { $this->delete($v, $all); } } else { $r = $this->get_one(); if ($MOD['list_html']) { $_file = DT_ROOT . '/' . $MOD['moduledir'] . '/' . $r['linkurl'] . $DT['index'] . '.' . $DT['file_ext']; if (is_file($_file)) { unlink($_file); } $i = 1; while ($i) { $_file = DT_ROOT . '/' . $MOD['moduledir'] . '/' . listurl(array('catid' => $r['itemid'], 'catdir' => $r['filepath'], 'catname' => $r['title']), $i); if (is_file($_file)) { unlink($_file); $i++; } else { break; } } } if ($all) { $userid = get_user($r['username']); if ($r['thumb']) { delete_upload($r['thumb'], $userid); } $this->db->query("DELETE FROM {$this->table} WHERE itemid={$itemid}"); $this->db->query("DELETE FROM {$table}_fans WHERE gid={$itemid}"); $this->db->query("UPDATE {$table} SET status=0 WHERE gid={$itemid}"); } } }
die; } // Delete archive if (isset($_GET['zip'])) { $zip = $_GET['zip']; $status = delete_zip($zip) ? 'success' : 'error'; exec_action('zip-delete'); // @hook zip-delete deleting archive zip redirect("archive.php?upd=del-" . $status . "&id=" . $zip); die; } // Delete upload file if (isset($_GET['file']) && getDef('GSALLOWUPLOADDELETE', true)) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $file = $_GET['file']; $status = delete_upload($file, $path) ? 'success' : 'error'; exec_action('upload-delete'); // @hook upload-delete deleting uploads file redirect("upload.php?upd=del-" . $status . "&id=" . $file . "&path=" . $path); die; } // Delete upload folders if (isset($_GET['folder']) && getDef('GSALLOWUPLOADDELETE', true)) { $path = isset($_GET['path']) ? $_GET['path'] : ""; $folder = $_GET['folder']; $status = delete_upload_dir($path . $folder) ? 'success' : 'error'; exec_action('upload-folder-delete'); // @hook upload-folder-delete deleting uploads folder redirect("upload.php?upd=del-" . $status . "&id=" . $folder . "&path=" . $path); die; }