public function update() { $name = $this->getActionName(); $model = D($name); if (false === ($data = $model->create())) { $this->error($model->getError()); } // 更新数据 $list = $model->save(); $id = $data[$model->getPk()]; if (false !== $list) { vendor("common"); $share_id = $model->where("goods_id = '{$id}'")->getField('share_id'); deleteCache('share/' . getDirsById($share_id) . '/imgs'); deleteCache('share/' . getDirsById($share_id) . '/detail'); $this->saveLog(1, $id); //$this->assign ( 'jumpUrl', Cookie::get ( '_currentUrl_' ) ); $this->success(L('EDIT_SUCCESS')); } else { //错误提示 $this->saveLog(0, $id); $this->error(L('EDIT_ERROR')); } }
public function deleteShareIds($uid) { deleteCache('user/' . getDirsById($uid) . '/shares'); }
public function deleteTopic($tid) { global $_FANWE; $topic = TopicService::getTopicById($tid); if (empty($topic)) { return; } FanweService::instance()->cache->loadCache('forums'); $forum_id = $topic['fid']; $forum = $_FANWE['cache']['forums']['all'][$forum_id]; $share_id = $topic['share_id']; $share = FS('Share')->getShareById($share_id); FS('Share')->deleteShare($share_id); $res = FDB::query('SELECT * FROM ' . FDB::table('forum_post') . ' WHERE tid = ' . $tid); while ($data = FDB::fetch($res)) { TopicService::deletePost($data['share_id'], false); } FDB::query('DELETE FROM ' . FDB::table('forum_post') . ' WHERE tid = ' . $tid); FDB::query('DELETE FROM ' . FDB::table('user_attention') . ' WHERE type=\'bar\' AND rec_id = ' . $tid); FDB::query('DELETE FROM ' . FDB::table('forum_thread') . ' WHERE tid = ' . $tid); FDB::query('UPDATE ' . FDB::table('forum') . ' SET thread_count = thread_count - 1 WHERE fid = ' . $forum_id); if ($forum['parent_id'] > 0) { FDB::query('UPDATE ' . FDB::table('forum') . ' SET thread_count = thread_count - 1 WHERE fid = ' . $forum['parent_id']); } FS('Medal')->runAuto($share['uid'], 'forums'); clearCacheDir('topic/thread/' . getDirsById($tid) . '/'); }
public function deleteUser($ids) { vendor("common"); @set_time_limit(0); if (function_exists('ini_set')) { ini_set('max_execution_time', 0); } $id_arr = explode(',', $ids); $ids = implode(',', $id_arr); if (empty($ids)) { return false; } //==================添加第三方整合会员添加 chenfq 2011-10-14================ foreach ($id_arr as $uid) { $user = $this->getById($uid); $user_field = fanweC('INTEGRATE_FIELD_ID'); $integrate_id = intval($user[$user_field]); if ($integrate_id > 0) { FS("Integrate")->adminInit(fanweC('INTEGRATE_CODE'), fanweC('INTEGRATE_CONFIG')); FS("Integrate")->delUser($integrate_id); //exit; } } //==================添加第三方整合会员添加chenfq 2011-10-14================ $condition = array('uid' => array('in', $id_arr)); if (false !== $this->where($condition)->delete()) { D('AskPost')->where($condition)->delete(); D('AskThread')->where($condition)->delete(); D('ForumPost')->where($condition)->delete(); D('ForumThread')->where($condition)->delete(); D('ManageLog')->where($condition)->delete(); D('SecondGoods')->where($condition)->delete(); D('ShareComment')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_category WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_match WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'share_tags WHERE share_id IN (SELECT share_id FROM ' . C("DB_PREFIX") . 'share WHERE uid IN (' . $ids . '))'); $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE uid IN (' . $ids . ')'); while ($data = FDB::fetch($res)) { $key = getDirsById($data['share_id']); clearCacheDir('share/' . $key); clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } D('Share')->where($condition)->delete(); D('ShareGoods')->where($condition)->delete(); D('SharePhoto')->where($condition)->delete(); D('UserAttention')->where($condition)->delete(); D('UserAuthority')->where($condition)->delete(); D('UserCount')->where($condition)->delete(); //删除喜欢收藏 $list = M()->query('SELECT uid,COUNT(uid) AS ccount FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET collects = collects - ' . $data['ccount'] . ' WHERE uid = ' . $data['uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_collect WHERE c_uid IN (' . $ids . ')'); //删除粉丝关注 $list = M()->query('SELECT uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ') GROUP BY uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = fans - 1 WHERE uid = ' . $data['uid']); } $list = M()->query('SELECT f_uid FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ') GROUP BY f_uid'); foreach ($list as $data) { M()->query('UPDATE ' . C("DB_PREFIX") . 'user_count SET fans = follows - 1 WHERE uid = ' . $data['f_uid']); } M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE f_uid IN (' . $ids . ')'); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_follow WHERE uid IN (' . $ids . ')'); D('UserDaren')->where($condition)->delete(); D('UserMedal')->where($condition)->delete(); D('UserMeTags')->where($condition)->delete(); M()->query('DELETE FROM ' . C("DB_PREFIX") . 'user_msg WHERE author_id IN (' . $ids . ')'); D('UserMsgRel')->where($condition)->delete(); D('UserNotice')->where($condition)->delete(); D('UserProfile')->where($condition)->delete(); D('UserStatistics')->where($condition)->delete(); D('UserStatus')->where($condition)->delete(); foreach ($id_arr as $uid) { $this->deleteUserAvatar($uid); } return true; } else { return false; } }
/** * * @param $origin_path 原始物理图片地址 * @param array $sizes 缩略图大小信息 为空则取后台设置 可生成多个缩略图 数组 参数1 为宽度, 参数2为高度, 参数3为处理方式:0(缩放,默认),1(剪裁), 参数4为是否水印 默认为 0(不生成水印) array( array(300,300,0,0), array(100,100,0,0), ... ), * @param $path 存储的路径 * @param $file_name 保存的文件名 * @param $del_temp 是否删除临时文件 * @param $id 关联编号,将根据编号生成目录 * * 返回 复制成功的信息,如为false则复制失败 * array( * 'path' => xxx //物理路径 * 'url' => xxx //相对路径 * ); * * by fzmatthew */ function copyImage($origin_path, $sizes = array(), $path = 'share', $del_temp = true, $id = 0) { global $_FANWE; static $size_setting = NULL, $image = NULL; if ($image === NULL) { include_once fimport('class/image'); $image = new Image(); } if ($path == 'temp') { $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H'); } else { if ($id > 0) { $dir = './public/upload/' . $path . '/' . getDirsById($id); } else { $dir = './public/upload/' . $path . '/' . fToDate(NULL, 'Y/m/d'); } } makeDir(FANWE_ROOT . $dir); $file_name = md5(microtime(true)) . random('6') . '.jpg'; $file_path = FANWE_ROOT . $dir . "/" . $file_name; $bln = false; if (file_exists($origin_path) && @copy($origin_path, $file_path)) { $bln = true; } else { $data = getUrlContent($origin_path); if (!empty($data) && @file_put_contents($file_path, $data) > 0) { $bln = true; } } if ($bln) { $info = $image->getImageInfo($file_path); if ($info['type'] != 'jpg' && $info['type'] != 'jpeg') { if (!$image->convertType($file_path, $file_path)) { return false; } } $water_image = $_FANWE['setting']['water_image']; if (!empty($water_image)) { $water_image = FANWE_ROOT . $water_image; } $water_mark = intval($_FANWE['setting']['water_mark']); $alpha = intval($_FANWE['setting']['water_alpha']); $place = intval($_FANWE['setting']['water_position']); if ($sizes !== false && empty($sizes)) { if ($size_setting === NULL) { if (!isset($_FANWE['cache']['image_sizes'])) { FanweService::instance()->cache->loadCache('image_sizes'); } $size_setting = $_FANWE['cache']['image_sizes']; } $sizes = $size_setting; } foreach ($sizes as $size) { if ($size[0] > 0 || $size[1] > 0) { $thumb_bln = false; $thumb_type = isset($size[2]) ? intval($size[2]) : 0; if ($thumb = $image->thumb($file_path, $size[0], $size[1], $thumb_type)) { if (isset($size[3]) && intval($size[3]) > 0) { $image->water($thumb['path'], $water_image, $alpha, $place); } } } } if ($del_temp) { @unlink($origin_path); } return array('path' => $file_path, 'url' => $dir . "/" . $file_name, 'width' => $info[0], 'height' => $info[1]); } else { return false; } }
/** * 更新浏览主题的会员编号集合缓存 */ public function updateTopicLooksCache($tid, $uid) { global $_FANWE; if ($_FANWE['uid'] == 0 || $_FANWE['uid'] == $uid) { return; } $uids = AskService::getTopicLooksCache($tid); if (!isset($uids[$_FANWE['uid']])) { if (count($uids) > 100) { array_shift($uids); } $uids[$_FANWE['uid']] = 1; setCache('ask/thread/' . getDirsById($tid) . '/looks', $uids); } }
public function removeComment() { //删除指定记录 $result = array('isErr' => 0, 'content' => ''); $id = $_REQUEST['id']; if (!empty($id)) { $model = D('ShareComment'); $pk = 'comment_id'; $condition = array($pk => array('in', explode(',', $id))); $count = $model->where($condition)->count(); $comments = $model->where($condition)->findAll(); if (false !== $model->where($condition)->delete()) { Vendor("common"); $share_id = $_REQUEST['share_id']; $key = getDirsById($share_id); clearCacheDir('share/' . $key . '/commentlist'); D('Share')->where("share_id = '{$share_id}'")->setDec('comment_count', $count); FS('Share')->updateShareCache($share_id, 'comments'); $this->saveLog(1, $id); } else { $this->saveLog(0, $id); $result['isErr'] = 1; $result['content'] = L('REMOVE_ERROR'); } } else { $result['isErr'] = 1; $result['content'] = L('ACCESS_DENIED'); } die(json_encode($result)); }
public function deleteAlbumItem($share_id, $is_update = true) { $share_id = (int) $share_id; if (!$share_id) { return false; } $rec = FDB::fetchFirst('SELECT * FROM ' . FDB::table('album_rec') . ' WHERE ashare_id = ' . $share_id); if ($rec) { FDB::delete('album_rec', 'ashare_id = ' . $share_id); FDB::query('UPDATE ' . FDB::table('share_rec') . " SET rec_count = rec_count - 1 WHERE share_id = " . $rec['share_id']); $res = FDB::query('SELECT share_id FROM ' . FDB::table('share_rec') . ' WHERE rec_count = 0'); $id_list = array(); while ($data = FDB::fetch($res)) { $id_list[$data['share_id']] = $data['share_id']; } if (count($id_list) > 0) { $ids = implode(',', $id_list); $res = FDB::query('SELECT share_id FROM ' . FDB::table('share') . ' WHERE share_id IN (' . $ids . ')'); while ($data = FDB::fetch($res)) { unset($id_list[$data['share_id']]); } foreach ($id_list as $id) { $key = getDirsById($id); clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } } FDB::delete('share_rec', 'share_id = ' . $rec['share_id'] . ' AND rec_count = 0'); } if ($is_update) { $album_id = (int) FDB::resultFirst('SELECT album_id FROM ' . FDB::table('album_share') . ' WHERE share_id = ' . $share_id); FDB::delete('album_share', ' share_id = ' . $share_id); AlbumService::updateAlbumByShare($album_id, $share_id, false); AlbumService::updateAlbum($album_id); } FS('Share')->deleteShare($share_id); }
public function deleteShareImages($share_id, $server_code) { if (empty($server_code)) { $key = getDirsById($share_id); clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } else { $server = FS("Image")->getServer($server_code); if ($server) { $args = array(); $args['share_id'] = $share_id; $server = FS("Image")->getImageUrlToken($args, $server, 1); FS("Image")->sendRequest($server, 'removeshare'); } } }
public function deleteShare($share_id, $is_score = true) { $share = ShareService::getShareById($share_id); if (!empty($share)) { $goods_count = FDB::resultFirst('SELECT COUNT(goods_id) FROM ' . FDB::table('share_goods') . ' WHERE share_id = ' . $share_id); $photo_count = FDB::resultFirst('SELECT COUNT(photo_id) FROM ' . FDB::table('share_photo') . ' WHERE share_id = ' . $share_id); $collect_count = FDB::resultFirst('SELECT COUNT(c_uid) FROM ' . FDB::table('user_collect') . ' WHERE share_id = ' . $share_id); FDB::delete('share', 'share_id = ' . $share_id); FDB::delete('share_goods', 'share_id = ' . $share_id); //FDB::delete('share_photo','share_id = '.$share_id); FDB::delete('share_category', 'share_id = ' . $share_id); FDB::delete('share_comment', 'share_id = ' . $share_id); FDB::delete('share_match', 'share_id = ' . $share_id); FDB::delete('share_tags', 'share_id = ' . $share_id); FDB::delete('user_collect', 'share_id = ' . $share_id); $pattern = "/#([^\f\n\r\t\v]{1,80}?)#/"; if (preg_match($pattern, $share['content'])) { FS("Event")->deleteEvent($share_id); } $pattern = "/@([^\f\n\r\t\v@ ]{2,20}?)(?:\\:| )/"; if (preg_match($pattern, $share['content'])) { FDB::delete('atme', 'share_id = ' . $share_id); } if (defined('MANAGE_HANDLER') && MANAGE_HANDLER && $is_score) { if (!in_array($share['type'], array('fav', 'album_best', 'album_rec'))) { if ($share['rec_uid'] == 0 && in_array($share['share_data'], array('goods', 'photo', 'goods_photo'))) { FS("User")->updateUserScore($share['uid'], 'delete_share', 'image', $share['content'], $share_id); } else { FS("User")->updateUserScore($share['uid'], 'delete_share', 'default', $share['content'], $share_id); } } } FDB::query('UPDATE ' . FDB::table('user_count') . ' SET shares = shares - 1, photos = photos - ' . $photo_count . ', goods = goods - ' . $goods_count . ', collects = collects - ' . $collect_count . ' WHERE uid = ' . $share['uid']); $key = getDirsById($share_id); clearCacheDir('share/' . $key); $count = (int) FDB::resultFirst('SELECT COUNT(share_id) FROM ' . FDB::table('share_rec') . ' WHERE share_id = ' . $share_id); if ($count == 0) { clearDir(PUBLIC_ROOT . './upload/share/' . $key, true); } } }