/** * 画像を削除 */ public static function remove($target, $to_blacklist = false) { $removed_files = array(); if (empty($target)) { return $removed_files; } if (!is_array($target)) { if (is_integer($target) || ctype_digit($target)) { $id = (int) $target; if ($id > 0) { $target = array($id); } else { return $removed_files; } } else { P2Util::pushInfoHtml('<p>WARNING! IC2_DatabaseManager::remove(): 不正な引数</p>'); return $removed_files; } } // トランザクションの開始 $ta = new IC2_DataObject_Images(); $db = $ta->getDatabaseConnection(); if ($db->phptype == 'pgsql') { $ta->query('BEGIN'); } elseif ($db->phptype == 'sqlite') { $db->query('BEGIN;'); } // 画像を削除 foreach ($target as $id) { $icdb = new IC2_DataObject_Images(); $icdb->whereAdd("id = {$id}"); if ($icdb->find(true)) { // キャッシュしているファイルを削除 $t1 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_PC); $t2 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_MOBILE); $t3 = new IC2_Thumbnailer(IC2_Thumbnailer::SIZE_INTERMD); $srcPath = $t1->srcPath($icdb->size, $icdb->md5, $icdb->mime); $t1Path = $t1->thumbPath($icdb->size, $icdb->md5, $icdb->mime); $t2Path = $t2->thumbPath($icdb->size, $icdb->md5, $icdb->mime); $t3Path = $t3->thumbPath($icdb->size, $icdb->md5, $icdb->mime); if (file_exists($srcPath)) { unlink($srcPath); $removed_files[] = $srcPath; } if (file_exists($t1Path)) { unlink($t1Path); $removed_files[] = $t1Path; } if (file_exists($t2Path)) { unlink($t2Path); $removed_files[] = $t2Path; } if (file_exists($t3Path)) { unlink($t3Path); $removed_files[] = $t3Path; } // ブラックリスト送りの準備 if ($to_blacklist) { $_blacklist = new IC2_DataObject_BlackList(); $_blacklist->size = $icdb->size; $_blacklist->md5 = $icdb->md5; if ($icdb->mime == 'clamscan/infected' || $icdb->rank == -4) { $_blacklist->type = 2; } elseif ($icdb->rank < 0) { $_blacklist->type = 1; } else { $_blacklist->type = 0; } } // 同一画像を検索 $remover = new IC2_DataObject_Images(); $remover->whereAddQuoted('size', '=', $icdb->size); $remover->whereAddQuoted('md5', '=', $icdb->md5); //$remover->whereAddQuoted('mime', '=', $icdb->mime); // SizeとMD5で十分 $remover->find(); while ($remover->fetch()) { // ブラックリスト送りにする if ($to_blacklist) { $blacklist = clone $_blacklist; $blacklist->uri = $remover->uri; $blacklist->insert(); } // テーブルから抹消 $remover->delete(); } } } // トランザクションのコミット if ($db->phptype == 'pgsql') { $ta->query('COMMIT'); } elseif ($db->phptype == 'sqlite') { $db->query('COMMIT;'); } return $removed_files; }
$show_exif = false; case 2: $popup = false; break; default: $popup = true; } $r_type = 1; } $items = array(); if (!empty($_SERVER['REQUEST_URI'])) { $k_backto = '&from=' . rawurlencode($_SERVER['REQUEST_URI']); } else { $k_backto = ''; } while ($icdb->fetch()) { // 検索結果を配列にし、レンダリング用の要素を付加 // 配列どうしなら+演算子で要素を追加できる // (キーの重複する値を上書きしたいときはarray_merge()を使う) $img = $icdb->toArray(); mb_convert_variables('CP932', 'UTF-8', $img); // ランク・メモは変更されることが多く、一覧用のデータキャッシュに影響を与えないように別に処理する $status = array(); $status['rank'] = $img['rank']; $status['rank_f'] = $img['rank'] == -1 ? 'あぼーん' : $img['rank']; if ($img['rank'] == -1) { $status['rank_i'] = '<img src="img/sn1a.png" width="16" height="16">'; } elseif ($img['rank'] > 0 && $img['rank'] <= 5) { $status['rank_i'] = str_repeat('<img src="img/s1a.png" width="16" height="16">', $img['rank']); } else { $status['rank_i'] = '';